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,
'data-address': 'true',
placeholder: champ.libelle,

View file

@ -1,3 +1,6 @@
.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}",
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,
{ required: champ.mandatory },
'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
%label
= 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,
value: champ.value,
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
.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,
Champ.departements,
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)
- show_text_summary = dossier.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?
= form.select :value,
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,
placeholder: champ.libelle,
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,
{ required: champ.mandatory },
'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?
= form.select :value,
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,
placeholder: champ.libelle,
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,
Champ.pays,
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,
placeholder: champ.libelle,
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,
Champ.regions,
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,
placeholder: champ.libelle,
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,
row: 6,
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
%label
= form.radio_button :value, true