diff --git a/app/controllers/admin/attestation_templates_controller.rb b/app/controllers/admin/attestation_templates_controller.rb index 0a6ea60a3..bc3bf0f40 100644 --- a/app/controllers/admin/attestation_templates_controller.rb +++ b/app/controllers/admin/attestation_templates_controller.rb @@ -1,16 +1,6 @@ class Admin::AttestationTemplatesController < AdminController before_action :retrieve_procedure - def show - attestation_template = @procedure.attestation_template - @logo = attestation_template.logo - @title = attestation_template.title - @body = attestation_template.body - @signature = attestation_template.signature - @footer = attestation_template.footer - @created_at = DateTime.now - end - def edit @attestation_template = @procedure.attestation_template || AttestationTemplate.new(procedure: @procedure) end diff --git a/app/views/admin/attestation_templates/edit.html.haml b/app/views/admin/attestation_templates/edit.html.haml index 29bf812d4..f5d790808 100644 --- a/app/views/admin/attestation_templates/edit.html.haml +++ b/app/views/admin/attestation_templates/edit.html.haml @@ -63,10 +63,11 @@ %button.btn.btn-primary{ formaction: admin_procedure_attestation_template_preview_path, formtarget: '_blank' } Prévisualiser .pull-right - - if @attestation_template.activated + - if @attestation_template.activated && !@procedure.locked? %button.btn.btn-warning{ formaction: admin_procedure_attestation_template_disactivate_path } désactiver l'attestation - if @attestation_template.new_record? || !@attestation_template.activated %button.btn.btn-success Activer l'attestation - else - %button.btn.btn-success Enregistrer + - save_data = @procedure.locked? ? { toggle: :tooltip, confirm: "Attention: les modifications n'affecteront pas les attestations déjà délivrées." } : nil + %button.btn.btn-success{ data: save_data } Enregistrer diff --git a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml index 37e2fe106..22362a245 100644 --- a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml +++ b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml @@ -45,12 +45,8 @@ .procedure-list-element{ class: ('active' if active == 'Prévisualisation') } Prévisualisation - - if !@procedure.locked? - %a#onglet-attestation{ href: url_for(edit_admin_procedure_attestation_template_path(@procedure)) } - .procedure-list-element{ class: ('active' if active == 'Attestation') } Attestation - - elsif @procedure.attestation_template.present? - %a#onglet-attestation{ href: url_for(admin_procedure_attestation_template_path(@procedure, format: :pdf)), target: '_blank' } - .procedure-list-element Attestation + %a#onglet-attestation{ href: url_for(edit_admin_procedure_attestation_template_path(@procedure)) } + .procedure-list-element{ class: ('active' if active == 'Attestation') } Attestation .split-hr-left diff --git a/config/routes.rb b/config/routes.rb index c67ba0dc9..a64710865 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -144,7 +144,7 @@ Rails.application.routes.draw do resource :previsualisation, only: [:show] - resource :attestation_template, only: [:show, :edit, :update, :create] + resource :attestation_template, only: [:edit, :update, :create] post 'attestation_template/disactivate' => 'attestation_templates#disactivate' patch 'attestation_template/disactivate' => 'attestation_templates#disactivate' diff --git a/spec/controllers/admin/attestation_templates_controller_spec.rb b/spec/controllers/admin/attestation_templates_controller_spec.rb index 7e62dcf43..cd318832a 100644 --- a/spec/controllers/admin/attestation_templates_controller_spec.rb +++ b/spec/controllers/admin/attestation_templates_controller_spec.rb @@ -10,18 +10,6 @@ describe Admin::AttestationTemplatesController, type: :controller do Timecop.freeze(Time.now) end - describe 'GET #show' do - before { get :show, params: { procedure_id: procedure.id, format: :pdf } } - - it { expect(subject.status).to eq(200) } - it { expect(assigns[:title]).to eq(attestation_template.title) } - it { expect(assigns[:logo].read).to eq(attestation_template.logo.read) } - it { expect(assigns[:body]).to eq(attestation_template.body) } - it { expect(assigns[:signature].read).to eq(attestation_template.signature.read) } - it { expect(assigns[:footer]).to eq(attestation_template.footer) } - it { expect(assigns[:created_at]).to eq(DateTime.now) } - end - describe 'POST #preview' do let(:upload_params) { { title: 't', body: 'b', footer: 'f' } }