one less indirection

This commit is contained in:
simon lehericey 2024-09-16 18:10:35 +02:00
parent b3ad237fa1
commit f1a606da6d
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
8 changed files with 3 additions and 20 deletions

View file

@ -2,7 +2,7 @@
class EditableChamp::DropDownListComponent < EditableChamp::EditableChampBaseComponent class EditableChamp::DropDownListComponent < EditableChamp::EditableChampBaseComponent
def render? def render?
@champ.options? @champ.drop_down_options.any?
end end
def select_class_names def select_class_names

View file

@ -1,4 +1,4 @@
- if @champ.options? - if @champ.drop_down_options.any?
.fr-fieldset__element.fr-mb-0 .fr-fieldset__element.fr-mb-0
.fr-select-group .fr-select-group
= render EditableChamp::ChampLabelComponent.new form: @form, champ: @champ, seen_at: @seen_at = render EditableChamp::ChampLabelComponent.new form: @form, champ: @champ, seen_at: @seen_at

View file

@ -1,4 +1,4 @@
- if @champ.options? - if @champ.drop_down_options.any?
- if @champ.render_as_checkboxes? - if @champ.render_as_checkboxes?
= @form.collection_check_boxes :value, @champ.enabled_non_empty_options, :to_s, :to_s do |b| = @form.collection_check_boxes :value, @champ.enabled_non_empty_options, :to_s, :to_s do |b|
- capture do - capture do

View file

@ -31,7 +31,6 @@ class Champ < ApplicationRecord
:description, :description,
:drop_down_options, :drop_down_options,
:drop_down_other?, :drop_down_other?,
:drop_down_options?,
:drop_down_list_enabled_non_empty_options, :drop_down_list_enabled_non_empty_options,
:drop_down_secondary_libelle, :drop_down_secondary_libelle,
:drop_down_secondary_description, :drop_down_secondary_description,

View file

@ -16,10 +16,6 @@ class Champs::DropDownListChamp < Champ
enabled_non_empty_options.size >= THRESHOLD_NB_OPTIONS_AS_AUTOCOMPLETE enabled_non_empty_options.size >= THRESHOLD_NB_OPTIONS_AS_AUTOCOMPLETE
end end
def options?
drop_down_options?
end
def html_label? def html_label?
!render_as_radios? !render_as_radios?
end end

View file

@ -3,10 +3,6 @@
class Champs::LinkedDropDownListChamp < Champ class Champs::LinkedDropDownListChamp < Champ
delegate :primary_options, :secondary_options, to: :type_de_champ delegate :primary_options, :secondary_options, to: :type_de_champ
def options?
drop_down_options?
end
def primary_value def primary_value
if value.present? if value.present?
JSON.parse(value)[0] JSON.parse(value)[0]

View file

@ -3,10 +3,6 @@
class Champs::MultipleDropDownListChamp < Champ class Champs::MultipleDropDownListChamp < Champ
validate :values_are_in_options, if: -> { value.present? && validate_champ_value_or_prefill? } validate :values_are_in_options, if: -> { value.present? && validate_champ_value_or_prefill? }
def options?
drop_down_options?
end
def enabled_non_empty_options def enabled_non_empty_options
drop_down_list_enabled_non_empty_options drop_down_list_enabled_non_empty_options
end end

View file

@ -566,10 +566,6 @@ class TypeDeChamp < ApplicationRecord
end end
end end
def drop_down_options?
drop_down_options.any?
end
def drop_down_options def drop_down_options
Array.wrap(super) Array.wrap(super)
end end