From 5fc0eb11f57f51fe7b32318819941161fe498e80 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Thu, 19 Sep 2024 17:11:14 +0200 Subject: [PATCH] rename remaining drop_down_list_enabled_non_empty_options(other: true) -> drop_down_options_with_other --- app/components/editable_champ/drop_down_list_component.rb | 2 +- .../drop_down_list_component.html.haml | 2 +- app/models/champ.rb | 2 +- app/models/logic/champ_value.rb | 2 +- app/models/type_de_champ.rb | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/components/editable_champ/drop_down_list_component.rb b/app/components/editable_champ/drop_down_list_component.rb index 58412ced9..8d1ac7204 100644 --- a/app/components/editable_champ/drop_down_list_component.rb +++ b/app/components/editable_champ/drop_down_list_component.rb @@ -31,7 +31,7 @@ class EditableChamp::DropDownListComponent < EditableChamp::EditableChampBaseCom class: 'fr-mt-1w', name: @form.field_name(:value), selected_key: @champ.selected, - items: @champ.drop_down_list_enabled_non_empty_options(other: true).map { _1.is_a?(Array) ? _1 : [_1, _1] }, + items: @champ.drop_down_options_with_other.map { _1.is_a?(Array) ? _1 : [_1, _1] }, empty_filter_key: @champ.drop_down_other? ? Champs::DropDownListChamp::OTHER : nil, 'aria-describedby': @champ.describedby_id, 'aria-labelledby': @champ.labelledby_id) diff --git a/app/components/editable_champ/drop_down_list_component/drop_down_list_component.html.haml b/app/components/editable_champ/drop_down_list_component/drop_down_list_component.html.haml index 0fdf14c2c..3d38158c9 100644 --- a/app/components/editable_champ/drop_down_list_component/drop_down_list_component.html.haml +++ b/app/components/editable_champ/drop_down_list_component/drop_down_list_component.html.haml @@ -22,7 +22,7 @@ = render ReactComponent.new "ComboBox/SingleComboBox", **react_props - else = @form.select :value, - @champ.drop_down_list_enabled_non_empty_options(other: true), + @champ.drop_down_options_with_other, { selected: @champ.selected, include_blank: true }, required: @champ.required?, id: @champ.input_id, diff --git a/app/models/champ.rb b/app/models/champ.rb index 0b5e7cbf5..9daa99d41 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -31,7 +31,7 @@ class Champ < ApplicationRecord :description, :drop_down_options, :drop_down_other?, - :drop_down_list_enabled_non_empty_options, + :drop_down_options_with_other, :drop_down_secondary_libelle, :drop_down_secondary_description, :collapsible_explanation_enabled?, diff --git a/app/models/logic/champ_value.rb b/app/models/logic/champ_value.rb index cb0ac0e27..688d2c113 100644 --- a/app/models/logic/champ_value.rb +++ b/app/models/logic/champ_value.rb @@ -128,7 +128,7 @@ class Logic::ChampValue < Logic::Term elsif operator_name.in?([Logic::InDepartementOperator.name, Logic::NotInDepartementOperator.name]) || tdc.type_champ.in?([MANAGED_TYPE_DE_CHAMP.fetch(:communes), MANAGED_TYPE_DE_CHAMP.fetch(:epci), MANAGED_TYPE_DE_CHAMP.fetch(:departements), MANAGED_TYPE_DE_CHAMP.fetch(:address)]) APIGeoService.departements.map { ["#{_1[:code]} – #{_1[:name]}", _1[:code]] } else - tdc.drop_down_list_enabled_non_empty_options(other: true).map { _1.is_a?(Array) ? _1 : [_1, _1] } + tdc.drop_down_options_with_other.map { _1.is_a?(Array) ? _1 : [_1, _1] } end end diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 653544927..d65bb609d 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -480,8 +480,8 @@ class TypeDeChamp < ApplicationRecord Array.wrap(super) end - def drop_down_list_enabled_non_empty_options(other: false) - if other && drop_down_other? + def drop_down_options_with_other + if drop_down_other? drop_down_options + [[I18n.t('shared.champs.drop_down_list.other'), Champs::DropDownListChamp::OTHER]] else drop_down_options