Mutualize some code

This commit is contained in:
gregoirenovel 2018-12-28 20:35:06 +01:00
parent 5014e3f4c1
commit 66c633a1e5

View file

@ -2,52 +2,29 @@
%tbody %tbody
- champs.reject(&:exclude_from_view?).each do |c| - champs.reject(&:exclude_from_view?).each do |c|
%tr %tr
- case c.type_champ - if c.type_champ == TypeDeChamp.type_champs.fetch(:header_section)
- when TypeDeChamp.type_champs.fetch(:header_section)
%th.header-section{ colspan: 3 } %th.header-section{ colspan: 3 }
= c.libelle = c.libelle
- when TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)
%th.libelle
= "#{c.libelle} :"
%td.rich-text
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
= render partial: "shared/champs/multiple_drop_down_list/show", locals: { champ: c }
- when TypeDeChamp.type_champs.fetch(:dossier_link)
%th.libelle
= "#{c.libelle} :"
%td.rich-text
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
= render partial: "shared/champs/dossier_link/show", locals: { champ: c }
- when TypeDeChamp.type_champs.fetch(:piece_justificative)
%th.libelle
= "#{c.libelle} :"
%td.rich-text
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
= render partial: "shared/champs/piece_justificative/show", locals: { champ: c }
- when TypeDeChamp.type_champs.fetch(:textarea)
%th.libelle
= "#{c.libelle} :"
%td.rich-text
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
= render partial: "shared/champs/text_area/show", locals: { champ: c }
- when TypeDeChamp.type_champs.fetch(:siret)
%th.libelle
= "#{c.libelle} :"
%td.rich-text
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
= render partial: "shared/champs/siret/show", locals: { champ: c, profile: profile }
- when TypeDeChamp.type_champs.fetch(:carte)
%th.libelle
= "#{c.libelle} :"
%td.rich-text
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
= render partial: "shared/champs/carte/show", locals: { champ: c }
- else - else
%th.libelle %th.libelle
= "#{c.libelle} :" = "#{c.libelle} :"
%td.rich-text %td.rich-text
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) } %span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
= sanitize(c.to_s) - case c.type_champ
- when TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)
= render partial: "shared/champs/multiple_drop_down_list/show", locals: { champ: c }
- when TypeDeChamp.type_champs.fetch(:dossier_link)
= render partial: "shared/champs/dossier_link/show", locals: { champ: c }
- when TypeDeChamp.type_champs.fetch(:piece_justificative)
= render partial: "shared/champs/piece_justificative/show", locals: { champ: c }
- when TypeDeChamp.type_champs.fetch(:textarea)
= render partial: "shared/champs/text_area/show", locals: { champ: c }
- when TypeDeChamp.type_champs.fetch(:siret)
= render partial: "shared/champs/siret/show", locals: { champ: c, profile: profile }
- when TypeDeChamp.type_champs.fetch(:carte)
= render partial: "shared/champs/carte/show", locals: { champ: c }
- else
= sanitize(c.to_s)
- if c.type_champ != TypeDeChamp.type_champs.fetch(:header_section) - if c.type_champ != TypeDeChamp.type_champs.fetch(:header_section)
%td.updated-at %td.updated-at
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) } %span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }