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
def render?
@champ.options?
@champ.drop_down_options.any?
end
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-select-group
= 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?
= @form.collection_check_boxes :value, @champ.enabled_non_empty_options, :to_s, :to_s do |b|
- capture do

View file

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

View file

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

View file

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

View file

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

View file

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