Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PoC] Add ability to exclude fields from automatic forms and tables #519

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

spohlenz
Copy link
Member

This is a proof of concept PR for an alternative way to support excluding fields from automatic tables and forms, as seen in #517 and #416.

It adds the ability to specify the :exclude option when defining an automatic table or form (i.e. without a block).

Trestle.resource(:articles) do
  table exclude: [:updated_at, :created_at]
  form exclude: [:updated_at, :created_at]
end

The advantage I see to this approach is that it confines the exclusion logic to the automatic form and table classes where it is most relevant. One disadvantage perhaps is that it is slightly harder to re-use specific exclusions between resources via adapter methods/modules.

A logical next step would be to add global configuration options for the default excluded fields (e.g. Trestle.config.default_table_exclusions / Trestle.config.default_form_exclusions).

@coveralls
Copy link

Coverage Status

coverage: 91.428% (+0.01%) from 91.416%
when pulling bfeffe3 on exclude-fields-poc
into dc8e987 on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants