trestle icon indicating copy to clipboard operation
trestle copied to clipboard

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

Open spohlenz opened this issue 1 year ago • 1 comments

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).

spohlenz avatar Oct 31 '24 21:10 spohlenz