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).
coverage: 91.428% (+0.01%) from 91.416%
when pulling bfeffe3a809c619674c074ca7952f71b6b558e96 on exclude-fields-poc
into dc8e987a2c32c72c51a63eb7c3b8638c6e9de4f3 on main.
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).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
).