From d42e4385469ab8503f14d97f8d8bb4817b12fa30 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 16 Oct 2017 17:01:12 +0200 Subject: [PATCH] Extract the pieces jointes part into a partial --- .../new_gestionnaire/avis/show.html.haml | 22 +----------------- .../dossiers/_pieces_jointes.html.haml | 20 ++++++++++++++++ .../new_gestionnaire/dossiers/show.html.haml | 23 +------------------ 3 files changed, 22 insertions(+), 43 deletions(-) create mode 100644 app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml diff --git a/app/views/new_gestionnaire/avis/show.html.haml b/app/views/new_gestionnaire/avis/show.html.haml index 71e65f588..0cba43551 100644 --- a/app/views/new_gestionnaire/avis/show.html.haml +++ b/app/views/new_gestionnaire/avis/show.html.haml @@ -23,24 +23,4 @@ - if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? .backoffice-title Pièces jointes .card - %table.table.vertical - %tbody - - if @dossier.procedure.cerfa_flag? - %tr - %th Formulaire : - %td - - if @dossier.cerfa_available? - = link_to 'Télécharger', @dossier.cerfa.last.content_url, class: 'button', target: :blank - - else - Pièce non fournie - - - @dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative| - %tr - %th= "#{type_de_piece_justificative.libelle} :" - %td - - pj = @dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id) - - if pj.present? - Pièce fournie - - = link_to "Consulter", pj.content_url, class: "link", target: :blank - - else - Pièce non fournie + = render partial: "new_gestionnaire/dossiers/pieces_jointes", locals: { dossier: @dossier } diff --git a/app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml b/app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml new file mode 100644 index 000000000..b25240793 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml @@ -0,0 +1,20 @@ +%table.table.vertical + %tbody + - if dossier.procedure.cerfa_flag? + %tr + %th Formulaire : + %td + - if @dossier.cerfa_available? + = link_to "Télécharger", @dossier.cerfa.last.content_url, class: "link", target: :blank + - else + Pièce non fournie + + - dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative| + %tr + %th= "#{type_de_piece_justificative.libelle} :" + %td + - pj = dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id) + - if pj.present? + = link_to "Télécharger", pj.content_url, class: "link", target: :blank + - else + Pièce non fournie diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index febaaea70..99aeec9cb 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -22,25 +22,4 @@ - if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? .backoffice-title Pièces jointes .card - %table.table.vertical - %tbody - - if @dossier.procedure.cerfa_flag? - %tr - %th Formulaire : - %td - - if @dossier.cerfa_available? - Pièce fournie - - = link_to "Consulter", @dossier.cerfa.last.content_url, class: "link", target: :blank - - else - Pièce non fournie - - - @dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative| - %tr - %th= "#{type_de_piece_justificative.libelle} :" - %td - - pj = @dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id) - - if pj.present? - Pièce fournie - - = link_to "Consulter", pj.content_url, class: "link", target: :blank - - else - Pièce non fournie + = render partial: "pieces_jointes", locals: { dossier: @dossier }