From c7f2293c1561e6477fcf59f58f50f7960e359fe7 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Fri, 28 Dec 2018 16:16:41 +0100 Subject: [PATCH] Extract the dossier_link champ view in a partial --- app/views/shared/champs/dossier_link/_show.html.haml | 11 +++++++++++ app/views/shared/dossiers/_champs.html.haml | 12 +----------- 2 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 app/views/shared/champs/dossier_link/_show.html.haml diff --git a/app/views/shared/champs/dossier_link/_show.html.haml b/app/views/shared/champs/dossier_link/_show.html.haml new file mode 100644 index 000000000..4868bcb5e --- /dev/null +++ b/app/views/shared/champs/dossier_link/_show.html.haml @@ -0,0 +1,11 @@ +- dossier = Dossier.includes(:procedure).find_by(id: champ.to_s) +- if dossier + - path = dossier_linked_path(current_gestionnaire, dossier) + - if path.present? + = link_to("Dossier nº #{dossier.id}", path, target: '_blank') + - else + Dossier nº #{dossier.id} + %br + = sanitize(dossier.text_summary) +- else + Pas de dossier associé diff --git a/app/views/shared/dossiers/_champs.html.haml b/app/views/shared/dossiers/_champs.html.haml index f8688a4d6..698aee6fd 100644 --- a/app/views/shared/dossiers/_champs.html.haml +++ b/app/views/shared/dossiers/_champs.html.haml @@ -21,17 +21,7 @@ = "#{c.libelle} :" %td.rich-text %span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) } - - dossier = Dossier.includes(:procedure).find_by(id: c.to_s) - - if dossier - - path = dossier_linked_path(current_gestionnaire, dossier) - - if path.present? - = link_to("Dossier nº #{dossier.id}", path, target: '_blank') - - else - Dossier nº #{dossier.id} - %br - = sanitize(dossier.text_summary) - - else - Pas de dossier associé + = render partial: "shared/champs/dossier_link/show", locals: { champ: c } - when TypeDeChamp.type_champs.fetch(:piece_justificative) %th.libelle = "#{c.libelle} :"