refactor(block): use block? instead of repetition?

This commit is contained in:
Paul Chavard 2022-09-29 17:42:53 +02:00
parent 79abca8945
commit 462cc41caa
13 changed files with 38 additions and 33 deletions

View file

@ -20,12 +20,12 @@ class EditableChamp::EditableChampComponent < ApplicationComponent
{
class: "editable-champ-#{@champ.type_champ} #{'hidden' if !@champ.visible?}",
id: @champ.input_group_id,
data: { controller: stimulus_controller }
data: { controller: stimulus_controller, block: @champ.block? }
}
end
def stimulus_controller
if !@champ.repetition? && @champ.fillable?
if !@champ.block? && @champ.fillable?
# This is an editable champ. Lets find what controllers it might need.
controllers = []

View file

@ -1,5 +1,5 @@
.editable-champ{ html_options }
- if @champ.repetition?
- if @champ.block?
%h3.header-subsection= @champ.libelle
- if @champ.description.present?
%p.notice= string_to_html(@champ.description, false)
@ -9,5 +9,5 @@
- if @champ.type_champ == "titre_identite"
%p.notice Carte nationale didentité (uniquement le recto), passeport, titre de séjour ou autre justificatif didentité. Formats acceptés : jpg/png
= @form.hidden_field :id, value: @champ.id, data: @champ.repetition? ? { id: true } : {}
= @form.hidden_field :id, value: @champ.id, data: @champ.block? ? { id: true } : {}
= render component_class.new(form: @form, champ: @champ, seen_at: @seen_at)