diff --git a/app/components/editable_champ/linked_drop_down_list_component.rb b/app/components/editable_champ/linked_drop_down_list_component.rb index 44775a170..f2ae949de 100644 --- a/app/components/editable_champ/linked_drop_down_list_component.rb +++ b/app/components/editable_champ/linked_drop_down_list_component.rb @@ -5,6 +5,10 @@ class EditableChamp::LinkedDropDownListComponent < EditableChamp::EditableChampB :fieldset end + def render? + @champ.drop_down_options.any? + end + private def secondary_label diff --git a/app/components/editable_champ/linked_drop_down_list_component/linked_drop_down_list_component.html.haml b/app/components/editable_champ/linked_drop_down_list_component/linked_drop_down_list_component.html.haml index 9ecebce20..9d8b7856c 100644 --- a/app/components/editable_champ/linked_drop_down_list_component/linked_drop_down_list_component.html.haml +++ b/app/components/editable_champ/linked_drop_down_list_component/linked_drop_down_list_component.html.haml @@ -1,19 +1,18 @@ -- if @champ.drop_down_options.any? - .fr-fieldset__element.fr-mb-0 - .fr-select-group - = render EditableChamp::ChampLabelComponent.new form: @form, champ: @champ, seen_at: @seen_at +.fr-fieldset__element.fr-mb-0 + .fr-select-group + = render EditableChamp::ChampLabelComponent.new form: @form, champ: @champ, seen_at: @seen_at - = @form.select :primary_value, @champ.primary_options, {}, required: @champ.required?, class: 'fr-select fr-mb-3v', id: @champ.input_id, aria: { describedby: @champ.describedby_id } + = @form.select :primary_value, @champ.primary_options, {}, required: @champ.required?, class: 'fr-select fr-mb-3v', id: @champ.input_id, aria: { describedby: @champ.describedby_id } - - if @champ.has_secondary_options_for_primary? - .secondary - .fr-fieldset__element - .fr-select-group - = @form.label :secondary_value, for: "#{@champ.input_id}-secondary", class: 'fr-label' do - - sanitize(secondary_label) - - if @champ.drop_down_secondary_description.present? - .notice{ id: "#{@champ.describedby_id}-secondary" } - = render SimpleFormatComponent.new(@champ.drop_down_secondary_description, allow_a: true) - = @form.select :secondary_value, @champ.secondary_options[@champ.primary_value], {}, required: @champ.required?, class: 'fr-select', id: "#{@champ.input_id}-secondary", aria: { describedby: "#{@champ.describedby_id}-secondary" } - - else - = @form.hidden_field :secondary_value, value: '' +- if @champ.has_secondary_options_for_primary? + .secondary + .fr-fieldset__element + .fr-select-group + = @form.label :secondary_value, for: "#{@champ.input_id}-secondary", class: 'fr-label' do + - sanitize(secondary_label) + - if @champ.drop_down_secondary_description.present? + .notice{ id: "#{@champ.describedby_id}-secondary" } + = render SimpleFormatComponent.new(@champ.drop_down_secondary_description, allow_a: true) + = @form.select :secondary_value, @champ.secondary_options[@champ.primary_value], {}, required: @champ.required?, class: 'fr-select', id: "#{@champ.input_id}-secondary", aria: { describedby: "#{@champ.describedby_id}-secondary" } +- else + = @form.hidden_field :secondary_value, value: '' diff --git a/app/components/editable_champ/multiple_drop_down_list_component/multiple_drop_down_list_component.html.haml b/app/components/editable_champ/multiple_drop_down_list_component/multiple_drop_down_list_component.html.haml index 15b4b3acb..cb5954738 100644 --- a/app/components/editable_champ/multiple_drop_down_list_component/multiple_drop_down_list_component.html.haml +++ b/app/components/editable_champ/multiple_drop_down_list_component/multiple_drop_down_list_component.html.haml @@ -1,13 +1,12 @@ -- if @champ.drop_down_options.any? - - if @champ.render_as_checkboxes? - = @form.collection_check_boxes :value, @champ.enabled_non_empty_options, :to_s, :to_s do |b| - - capture do - .fr-fieldset__element - .fr-checkbox-group - = b.check_box(checked: @champ.selected_options.include?(b.value), aria: { describedby: @champ.describedby_id }, id: @champ.checkbox_id(b.value), class: 'fr-checkbox-group__checkbox') - %label.fr-label{ for: @champ.checkbox_id(b.value) } - = b.text +- if @champ.render_as_checkboxes? + = @form.collection_check_boxes :value, @champ.enabled_non_empty_options, :to_s, :to_s do |b| + - capture do + .fr-fieldset__element + .fr-checkbox-group + = b.check_box(checked: @champ.selected_options.include?(b.value), aria: { describedby: @champ.describedby_id }, id: @champ.checkbox_id(b.value), class: 'fr-checkbox-group__checkbox') + %label.fr-label{ for: @champ.checkbox_id(b.value) } + = b.text - - else - %react-fragment - = render ReactComponent.new "ComboBox/MultiComboBox", **react_props +- else + %react-fragment + = render ReactComponent.new "ComboBox/MultiComboBox", **react_props diff --git a/app/models/champs/multiple_drop_down_list_champ.rb b/app/models/champs/multiple_drop_down_list_champ.rb index 3641100e7..081c6547f 100644 --- a/app/models/champs/multiple_drop_down_list_champ.rb +++ b/app/models/champs/multiple_drop_down_list_champ.rb @@ -88,6 +88,10 @@ class Champs::MultipleDropDownListChamp < Champ end end + def render? + @champ.drop_down_options.any? + end + private def values_are_in_options