From 1da69a77302422a6651869236d2c8190b34e8886 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 13 Apr 2018 16:42:49 +0200 Subject: [PATCH] Dossier: extract edition view to shared template --- .../new_user/dossiers/modifier.html.haml | 64 +------------------ app/views/shared/dossiers/_edit.html.haml | 63 ++++++++++++++++++ 2 files changed, 64 insertions(+), 63 deletions(-) create mode 100644 app/views/shared/dossiers/_edit.html.haml diff --git a/app/views/new_user/dossiers/modifier.html.haml b/app/views/new_user/dossiers/modifier.html.haml index de6867daa..96b4ef745 100644 --- a/app/views/new_user/dossiers/modifier.html.haml +++ b/app/views/new_user/dossiers/modifier.html.haml @@ -3,66 +3,4 @@ .container %h1= @dossier.procedure.libelle - .container - - if notice_url(@dossier.procedure).present? - %p - Pour vous aider à remplir votre dossier, vous pouvez consulter - = link_to 'le guide de cette démarche', notice_url(@dossier.procedure), { target: '_blank' } - - %p.thanks Les champs avec une asterisque (*) sont obligatoires. - - = form_for @dossier, html: { class: 'form', multipart: true } do |f| - = f.fields_for :champs, @dossier.champs do |champ_form| - - champ = champ_form.object - = render partial: "shared/dossiers/editable_champs/editable_champ", - locals: { champ: champ, form: champ_form } - - - tpjs = @dossier.types_de_piece_justificative.order('order_place ASC') - - if tpjs.present? - .card.featured - .card-title - Pièces-jointes - - - tpjs.each do |tpj| - .pj-input - %label{ for: "piece_justificative_#{tpj.id}" } - = tpj.libelle - - if tpj.mandatory? - %span.mandatory * - - %p.piece-description= tpj.description - - - if tpj.lien_demarche.present? - %p.piece-description - Récupérer le formulaire vierge pour mon dossier : - = link_to "Télécharger", tpj.lien_demarche, target: :blank - - - if @dossier.was_piece_justificative_uploaded_for_type_id?(tpj.id) - - pj = @dossier.retrieve_last_piece_justificative_by_type(tpj.id) - %p - Pièce-jointe déjà importée : - = link_to pj.original_filename, pj.content_url, target: :blank - - = file_field_tag "piece_justificative_#{tpj.id}", - accept: PieceJustificative.accept_format, - max_file_size: 6.megabytes, - required: (tpj.mandatory? && !@dossier.was_piece_justificative_uploaded_for_type_id?(tpj.id)) - - .send-wrapper - = hidden_field_tag 'submit_action', 'draft' - - - if @dossier.brouillon? - = f.button 'Enregistrer le brouillon', - formnovalidate: true, - class: 'button send', - data: { action: 'draft', disable_with: 'Envoi...' } - - - if @dossier.user == current_user - = f.button 'Soumettre le dossier', - class: 'button send primary', - data: { action: 'submit', disable_with: 'Envoi...' } - - - else - = f.button 'Modifier le dossier', - class: 'button send primary', - data: { action: 'submit', disable_with: 'Envoi...' } + = render partial: "shared/dossiers/edit", locals: { dossier: @dossier } diff --git a/app/views/shared/dossiers/_edit.html.haml b/app/views/shared/dossiers/_edit.html.haml new file mode 100644 index 000000000..d7a2f8b50 --- /dev/null +++ b/app/views/shared/dossiers/_edit.html.haml @@ -0,0 +1,63 @@ +.container + - if notice_url(dossier.procedure).present? + %p + Pour vous aider à remplir votre dossier, vous pouvez consulter + = link_to 'le guide de cette démarche', notice_url(dossier.procedure), { target: '_blank' } + + %p.thanks Les champs avec une asterisque (*) sont obligatoires. + + = form_for dossier, html: { class: 'form', multipart: true } do |f| + = f.fields_for :champs, dossier.champs do |champ_form| + - champ = champ_form.object + = render partial: "shared/dossiers/editable_champs/editable_champ", + locals: { champ: champ, form: champ_form } + + - tpjs = dossier.types_de_piece_justificative.order('order_place ASC') + - if tpjs.present? + .card.featured + .card-title + Pièces-jointes + + - tpjs.each do |tpj| + .pj-input + %label{ for: "piece_justificative_#{tpj.id}" } + = tpj.libelle + - if tpj.mandatory? + %span.mandatory * + + %p.piece-description= tpj.description + + - if tpj.lien_demarche.present? + %p.piece-description + Récupérer le formulaire vierge pour mon dossier : + = link_to "Télécharger", tpj.lien_demarche, target: :blank + + - if dossier.was_piece_justificative_uploaded_for_type_id?(tpj.id) + - pj = dossier.retrieve_last_piece_justificative_by_type(tpj.id) + %p + Pièce-jointe déjà importée : + = link_to pj.original_filename, pj.content_url, target: :blank + + = file_field_tag "piece_justificative_#{tpj.id}", + accept: PieceJustificative.accept_format, + max_file_size: 6.megabytes, + required: (tpj.mandatory? && !dossier.was_piece_justificative_uploaded_for_type_id?(tpj.id)) + + .send-wrapper + = hidden_field_tag 'submit_action', 'draft' + + - if dossier.brouillon? + = f.button 'Enregistrer le brouillon', + formnovalidate: true, + class: 'button send', + data: { action: 'draft', disable_with: 'Envoi...' } + + - if dossier.user == current_user + = f.button 'Soumettre le dossier', + class: 'button send primary', + data: { action: 'submit', disable_with: 'Envoi...' } + + - else + = f.button 'Modifier le dossier', + class: 'button send primary', + data: { action: 'submit', disable_with: 'Envoi...' }