♻️ rename method for clarity
This commit is contained in:
parent
0159a10969
commit
a07446da6c
6 changed files with 10 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
class TypesDeChamp::PrefillDropDownListTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp
|
class TypesDeChamp::PrefillDropDownListTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp
|
||||||
def possible_values_list
|
def all_possible_values
|
||||||
if drop_down_other?
|
if drop_down_other?
|
||||||
drop_down_list_enabled_non_empty_options.insert(
|
drop_down_list_enabled_non_empty_options.insert(
|
||||||
0,
|
0,
|
||||||
|
@ -11,6 +11,6 @@ class TypesDeChamp::PrefillDropDownListTypeDeChamp < TypesDeChamp::PrefillTypeDe
|
||||||
end
|
end
|
||||||
|
|
||||||
def example_value
|
def example_value
|
||||||
possible_values_list.first
|
all_possible_values.first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class TypesDeChamp::PrefillPaysTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp
|
class TypesDeChamp::PrefillPaysTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp
|
||||||
def possible_values_list
|
def all_possible_values
|
||||||
countries.map { |country| "#{country[:code]} (#{country[:name]})" }
|
countries.map { |country| "#{country[:code]} (#{country[:name]})" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class TypesDeChamp::PrefillRegionTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp
|
class TypesDeChamp::PrefillRegionTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp
|
||||||
def possible_values_list
|
def all_possible_values
|
||||||
regions.map { |region| "#{region[:code]} (#{region[:name]})" }
|
regions.map { |region| "#{region[:code]} (#{region[:name]})" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ class TypesDeChamp::PrefillRepetitionTypeDeChamp < TypesDeChamp::PrefillTypeDeCh
|
||||||
def possible_values
|
def possible_values
|
||||||
[
|
[
|
||||||
I18n.t("views.prefill_descriptions.edit.possible_values.#{type_champ}_html"),
|
I18n.t("views.prefill_descriptions.edit.possible_values.#{type_champ}_html"),
|
||||||
subchamps_possible_values_list
|
subchamps_all_possible_values
|
||||||
].join("</br>").html_safe # rubocop:disable Rails/OutputSafety
|
].join("</br>").html_safe # rubocop:disable Rails/OutputSafety
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class TypesDeChamp::PrefillRepetitionTypeDeChamp < TypesDeChamp::PrefillTypeDeCh
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def subchamps_possible_values_list
|
def subchamps_all_possible_values
|
||||||
"<ul>" + prefillable_subchamps.map do |prefill_type_de_champ|
|
"<ul>" + prefillable_subchamps.map do |prefill_type_de_champ|
|
||||||
"<li>#{prefill_type_de_champ.libelle}: #{prefill_type_de_champ.possible_values}</li>"
|
"<li>#{prefill_type_de_champ.libelle}: #{prefill_type_de_champ.possible_values}</li>"
|
||||||
end.join + "</ul>"
|
end.join + "</ul>"
|
||||||
|
|
|
@ -27,7 +27,7 @@ class TypesDeChamp::PrefillTypeDeChamp < SimpleDelegator
|
||||||
[possible_values_list_display, link_to_all_possible_values].compact.join('<br>').html_safe # rubocop:disable Rails/OutputSafety
|
[possible_values_list_display, link_to_all_possible_values].compact.join('<br>').html_safe # rubocop:disable Rails/OutputSafety
|
||||||
end
|
end
|
||||||
|
|
||||||
def possible_values_list
|
def all_possible_values
|
||||||
return [] unless prefillable?
|
return [] unless prefillable?
|
||||||
|
|
||||||
[I18n.t("views.prefill_descriptions.edit.possible_values.#{type_champ}_html")]
|
[I18n.t("views.prefill_descriptions.edit.possible_values.#{type_champ}_html")]
|
||||||
|
@ -56,14 +56,14 @@ class TypesDeChamp::PrefillTypeDeChamp < SimpleDelegator
|
||||||
end
|
end
|
||||||
|
|
||||||
def too_many_possible_values?
|
def too_many_possible_values?
|
||||||
possible_values_list.count > POSSIBLE_VALUES_THRESHOLD
|
all_possible_values.count > POSSIBLE_VALUES_THRESHOLD
|
||||||
end
|
end
|
||||||
|
|
||||||
def possible_values_list_display
|
def possible_values_list_display
|
||||||
if too_many_possible_values?
|
if too_many_possible_values?
|
||||||
I18n.t("views.prefill_descriptions.edit.possible_values.#{type_champ}_html").html_safe # rubocop:disable Rails/OutputSafety
|
I18n.t("views.prefill_descriptions.edit.possible_values.#{type_champ}_html").html_safe # rubocop:disable Rails/OutputSafety
|
||||||
else
|
else
|
||||||
possible_values_list.to_sentence
|
all_possible_values.to_sentence
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
= t("views.prefill_descriptions.edit.possible_values.title")
|
= t("views.prefill_descriptions.edit.possible_values.title")
|
||||||
%td
|
%td
|
||||||
.fr-grid-row.fr-grid-row--gutters.fr-py-5w
|
.fr-grid-row.fr-grid-row--gutters.fr-py-5w
|
||||||
- @type_de_champ.possible_values_list.each do |possible_value|
|
- @type_de_champ.all_possible_values.each do |possible_value|
|
||||||
.fr-col-lg-3.fr-col-md-4.fr-col-sm-6.fr-col-12
|
.fr-col-lg-3.fr-col-md-4.fr-col-sm-6.fr-col-12
|
||||||
= possible_value
|
= possible_value
|
||||||
%tr
|
%tr
|
||||||
|
|
Loading…
Reference in a new issue