Merge pull request #1104 from sgmap/template-refactor

Mutualize a duplicated render instruction
This commit is contained in:
gregoirenovel 2017-12-15 10:58:40 +01:00 committed by GitHub
commit 410a12b966
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 9 additions and 37 deletions

View file

@ -0,0 +1,5 @@
module ChampHelper
def is_not_header_nor_explication?(champ)
!['header_section', 'explication'].include?(champ.type_champ)
end
end

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.text_field :value, = form.text_field :value,
'data-address': 'true', 'data-address': 'true',
placeholder: champ.libelle, placeholder: champ.libelle,

View file

@ -1,3 +1,6 @@
.champ .champ
- if is_not_header_nor_explication?(champ)
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}", = render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}",
locals: { champ: champ, form: form, seen_at: seen_at } locals: { champ: champ, form: form }

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.check_box :value, = form.check_box :value,
{ required: champ.mandatory }, { required: champ.mandatory },
'on', 'on',

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
.radios .radios
%label %label
= form.radio_button :value, 'M.' = form.radio_button :value, 'M.'

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.date_field :value, = form.date_field :value,
value: champ.value, value: champ.value,
placeholder: 'JJ/MM/AAAA', placeholder: 'JJ/MM/AAAA',

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
- parsed_value = champ.value.present? ? DateTime.parse(champ.value) : DateTime.now - parsed_value = champ.value.present? ? DateTime.parse(champ.value) : DateTime.now
.datetime .datetime

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.select :value, = form.select :value,
Champ.departements, Champ.departements,
required: champ.mandatory required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
- dossier = Dossier.find_by(id: champ.value) - dossier = Dossier.find_by(id: champ.value)
- show_text_summary = dossier.present? - show_text_summary = dossier.present?
- show_warning = !show_text_summary && champ.value.present? - show_warning = !show_text_summary && champ.value.present?

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
- if champ.drop_down_list && champ.drop_down_list.options.any? - if champ.drop_down_list && champ.drop_down_list.options.any?
= form.select :value, = form.select :value,
champ.drop_down_list.options, champ.drop_down_list.options,

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.email_field :value, = form.email_field :value,
placeholder: champ.libelle, placeholder: champ.libelle,
required: champ.mandatory required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.check_box :value, = form.check_box :value,
{ required: champ.mandatory }, { required: champ.mandatory },
'on', 'on',

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
- if champ.drop_down_list && champ.drop_down_list.options.any? - if champ.drop_down_list && champ.drop_down_list.options.any?
= form.select :value, = form.select :value,
champ.drop_down_list.options, champ.drop_down_list.options,

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.number_field :value, = form.number_field :value,
placeholder: champ.libelle, placeholder: champ.libelle,
required: champ.mandatory required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.select :value, = form.select :value,
Champ.pays, Champ.pays,
required: champ.mandatory required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.phone_field :value, = form.phone_field :value,
placeholder: champ.libelle, placeholder: champ.libelle,
required: champ.mandatory required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.select :value, = form.select :value,
Champ.regions, Champ.regions,
required: champ.mandatory required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.text_field :value, = form.text_field :value,
placeholder: champ.libelle, placeholder: champ.libelle,
required: champ.mandatory required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
~ form.text_area :value, ~ form.text_area :value,
row: 6, row: 6,
placeholder: champ.description, placeholder: champ.description,

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
.radios .radios
%label %label
= form.radio_button :value, true = form.radio_button :value, true