ElixirTeSS / TeSS

Training e-Support Service using Ruby on Rails.
Other
12 stars 12 forks source link

option to disable material form options in config #839

Closed mikesndrs closed 1 year ago

mikesndrs commented 1 year ago

Summary of changes

Disable form options in config

Motivation and context

Some providers get demotivated from the huge amount of fields

Checklist

abotzki commented 1 year ago

On a general note, I'd like to emphasize that we should highlight the most important fields and explain why we would not hide the one or the other field. So, we need to better explain why which fields are asked to fill in.

On Tue, 9 May 2023 at 14:33, Finn Bacall @.***> wrote:

@.**** commented on this pull request.

I wonder if there's a nice way to integrate this into simple_form to make the code a bit more concise.

I'm thinking something to allow us to do something like:

<%= f.input :licence, collection: licence_options_for_select, input_html: { title: t('materials.hints.licence') },
            prompt: 'Select a licence...', errors: @material.errors[:licence], field_lock: true,
            hidden: TeSS::Config.feature['materials_disabled'] %>

We currently do this for the field_lock thing, it's a "componenet" https://github.com/heartcombo/simple_form#custom-components

https://github.com/ElixirTeSS/TeSS/blob/16fd72dd025a8975f3c48e90d6380ff1f54b386f/config/initializers/simple_form/field_lock_component.rb#L1-L17

https://github.com/ElixirTeSS/TeSS/blob/16fd72dd025a8975f3c48e90d6380ff1f54b386f/config/initializers/simple_form_bootstrap.rb#L16

https://github.com/ElixirTeSS/TeSS/blob/e02eab76d19a5e341fc6a2caf4f6a330f1ca03e1/app/helpers/application_helper.rb#L350-L355

There are various things you can do with the form elements that I've not explored completely: https://github.com/heartcombo/simple_form#the-wrappers-api

I'm thinking the "component" could check if the current input's name is present in the provide "disabled" list, and if so, add a CSS class to the wrapping div that hides it from the page.

Not 100% sure if this is possible, but I think it would be a cleaner solution and allow us in the future to have a kind of "advanced mode" switch as mentioned in the call today.

— Reply to this email directly, view it on GitHub https://github.com/ElixirTeSS/TeSS/pull/839#pullrequestreview-1418520248, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJDCI5CXHZFA4IIWDNYBPKTXFI2SPANCNFSM6AAAAAAXTEVMCU . You are receiving this because you are subscribed to this thread.Message ID: @.***>