From 68682fe78dab3980b27abcc343c98f4d9f898314 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 29 Nov 2017 11:47:18 +0100 Subject: [PATCH] [fix #873] add motivation in case of refused or without continuation dossier --- .../javascripts/new_design/state_button.js | 8 ++-- .../stylesheets/new_design/motivation.scss | 1 + .../dossiers/_state_button.html.haml | 40 +++++++------------ .../_state_button_motivation.html.haml | 13 ++++++ .../new_gestionnaire/gestionnaire_spec.rb | 6 ++- 5 files changed, 36 insertions(+), 32 deletions(-) create mode 100644 app/views/new_gestionnaire/dossiers/_state_button_motivation.html.haml diff --git a/app/assets/javascripts/new_design/state_button.js b/app/assets/javascripts/new_design/state_button.js index 71e32310e..0e9e3af4f 100644 --- a/app/assets/javascripts/new_design/state_button.js +++ b/app/assets/javascripts/new_design/state_button.js @@ -1,9 +1,9 @@ -TPS.acceptDossier = function () { - $(".motivation").show(); +TPS.showMotivation = function (state) { + $(".motivation." + state).show(); $(".dropdown-items").hide(); -} +}; TPS.motivationCancel = function () { $(".motivation").hide(); $(".dropdown-items").show(); -} +}; diff --git a/app/assets/stylesheets/new_design/motivation.scss b/app/assets/stylesheets/new_design/motivation.scss index a28cee19d..cf5d684de 100644 --- a/app/assets/stylesheets/new_design/motivation.scss +++ b/app/assets/stylesheets/new_design/motivation.scss @@ -10,6 +10,7 @@ h3 { font-size: 22px; margin-bottom: $default-spacer * 2; + line-height: 1.5; .icon { vertical-align: sub; diff --git a/app/views/new_gestionnaire/dossiers/_state_button.html.haml b/app/views/new_gestionnaire/dossiers/_state_button.html.haml index ca0d6f739..c1115697e 100644 --- a/app/views/new_gestionnaire/dossiers/_state_button.html.haml +++ b/app/views/new_gestionnaire/dossiers/_state_button.html.haml @@ -28,36 +28,24 @@ .description %h4 En instruction L'usager ne peut modifier son dossier pendant l'instruction - %li{ onclick: "TPS.acceptDossier();" } + %li{ onclick: "TPS.showMotivation('accept');" } .icon.accept .description %h4 Accepter L'usager sera notifié que son dossier a été accepté - %li - = link_to backoffice_dossier_process_dossier_path(dossier, process_action: "without_continuation", new_ui: true), method: :post, data: { confirm: "Confirmer vous le classement sans suite de ce dossier ?" } do - .icon.without-continuation - .description - %h4 Classer sans suite - L'usager ne recevra aucune notification - %li - = link_to backoffice_dossier_process_dossier_path(dossier, process_action: "refuse", new_ui: true), method: :post, data: { confirm: "Confirmer vous le refus de ce dossier ?" } do - .icon.close - .description - %h4 Refuser - L'usager sera notifié que son dossier a été refusé - .motivation - %h3 - .icon.accept - Accepter le dossier - = "nº #{dossier.id}" - - = form_tag(backoffice_dossier_process_dossier_url(dossier.id, new_ui: true), method: :post, class: "form") do - = text_area :dossier, :motivation, class: "motivation-text-area", placeholder: "Rédigez votre motivation ici (facultative)" - %p.help - L'acceptation du dossier envoie automatiquement une attestation à l'usager. - .text-right - %span.button{ onclick: "TPS.motivationCancel();" } Annuler - = button_tag "Valider la décision", name: :process_action, value: "close", class: 'button primary', title: 'Accepter', data: { confirm: "Accepter ce dossier ?" } + %li{ onclick: "TPS.showMotivation('without-continuation');" } + .icon.without-continuation + .description + %h4 Classer sans suite + L'usager ne recevra aucune notification + %li{ onclick: "TPS.showMotivation('close');" } + .icon.close + .description + %h4 Refuser + L'usager sera notifié que son dossier a été refusé + = render partial: 'new_gestionnaire/dossiers/state_button_motivation', locals: { dossier: dossier, popup_title: 'Accepter le dossier', popup_class: 'accept', process_action: 'close', title: 'Accepter', confirm: 'Accepter ce dossier ?' } + = render partial: 'new_gestionnaire/dossiers/state_button_motivation', locals: { dossier: dossier, popup_title: 'Classer le dossier sans suite', popup_class: 'without-continuation', process_action: 'without_continuation', title: 'Classer sans suite', confirm: 'Confirmer vous le classement sans suite de ce dossier ?' } + = render partial: 'new_gestionnaire/dossiers/state_button_motivation', locals: { dossier: dossier, popup_title: 'Refuser le dossier', popup_class: 'close', process_action: 'refuse', title: 'Refuser', confirm: 'Confirmer vous le refus de ce dossier ?' } - else - if dossier.motivation.present? || dossier.attestation.present? diff --git a/app/views/new_gestionnaire/dossiers/_state_button_motivation.html.haml b/app/views/new_gestionnaire/dossiers/_state_button_motivation.html.haml new file mode 100644 index 000000000..2dfadaaf0 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/_state_button_motivation.html.haml @@ -0,0 +1,13 @@ +.motivation{ class: popup_class } + %h3 + .icon{ class: popup_class } + #{popup_title} nº #{dossier.id} + + = form_tag(backoffice_dossier_process_dossier_url(dossier.id, new_ui: true), method: :post, class: 'form') do + = text_area :dossier, :motivation, class: 'motivation-text-area', placeholder: 'Rédigez votre motivation ici (facultative)' + - if title == 'Accepter' + %p.help + L'acceptation du dossier envoie automatiquement une attestation à l'usager. + .text-right + %span.button{ onclick: 'TPS.motivationCancel();' } Annuler + = button_tag 'Valider la décision', name: :process_action, value: process_action, class: 'button primary', title: title, data: { confirm: confirm } diff --git a/spec/features/new_gestionnaire/gestionnaire_spec.rb b/spec/features/new_gestionnaire/gestionnaire_spec.rb index 5dbee74e4..85fe6bda5 100644 --- a/spec/features/new_gestionnaire/gestionnaire_spec.rb +++ b/spec/features/new_gestionnaire/gestionnaire_spec.rb @@ -23,8 +23,10 @@ feature 'The gestionnaire part' do dossier.reload expect(dossier.state).to eq('received') - fill_in('dossier_motivation', with: 'a good reason') - click_on 'Valider la décision' + within('.accept.motivation') do + fill_in('dossier_motivation', with: 'a good reason') + click_on 'Valider la décision' + end dossier.reload expect(dossier.state).to eq('closed')