refactor(drop_down_list_champ): other option

This commit is contained in:
Paul Chavard 2021-10-26 20:42:17 +02:00 committed by kara Diaby
parent f1f2b76a3d
commit 8154daf847
5 changed files with 60 additions and 91 deletions

View file

@ -1,5 +1,4 @@
%input{ type: "text",
value: champ.other_value_present? ? champ.value : "",
class: class_name,
maxlength: "200",
placeholder: "Saisissez ici" }
.drop_down_other{ class: champ.other_value_present? ? '' : 'hidden' }
.notice
%p Veuillez saisir votre autre choix
= form.text_field :value_other, { maxlength: "200", placeholder: "Saisissez ici", disabled: !champ.other_value_present? }

View file

@ -10,23 +10,13 @@
%label.blank-radio
= form.radio_button :value, ''
Non renseigné
- if champ.drop_down_other?
%label
= form.radio_button :value, '', class: "radio_button_drop_down_other", id: "radio_button_drop_down_other_#{champ.id}", checked: champ.other_value_present?
= form.radio_button :value, Champs::DropDownListChamp::OTHER, checked: champ.other_value_present?
Autre
- if champ.drop_down_other?
.notice.drop_down_other_radio_notice{ style: "#{champ.other_value_present? ? "display:block" : "display:none"}" }
%p Veuillez saisir votre autre choix
= render partial: "shared/dossiers/drop_down_other_input", locals: { champ: champ, class_name: "text_field_drop_down_other_radio" }
- else
= form.select :value,
champ.drop_down_other? ? champ.options.concat(["Autre"]) : champ.options,
{ selected: champ.other_value_present? ? "Autre" : champ.value,
required: champ.mandatory? },
{ class: champ.drop_down_other? ? "select_drop_down_other" : ""}
= form.select :value, champ.options, { selected: champ.selected, required: champ.mandatory? }
- if champ.drop_down_other?
.notice.drop_down_other_select_notice{ style: "#{champ.other_value_present? ? "display:block" : "display:none"}" }
= render partial: "shared/dossiers/drop_down_other_input", locals: { champ: champ, class_name: "text_field_drop_down_other_select" }
- if champ.drop_down_other?
= render partial: "shared/dossiers/drop_down_other_input", locals: { form: form, champ: champ }