Merge pull request #2581 from tchak/do-not-reload-page-on-state-change
Do not reload page when instructeur change dossier state
This commit is contained in:
commit
cac5035ddb
8 changed files with 61 additions and 40 deletions
|
@ -77,14 +77,14 @@ module NewGestionnaire
|
||||||
current_gestionnaire.follow(dossier)
|
current_gestionnaire.follow(dossier)
|
||||||
flash.notice = 'Dossier passé en instruction.'
|
flash.notice = 'Dossier passé en instruction.'
|
||||||
|
|
||||||
redirect_to gestionnaire_dossier_path(procedure, dossier)
|
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||||
end
|
end
|
||||||
|
|
||||||
def repasser_en_construction
|
def repasser_en_construction
|
||||||
dossier.en_construction!
|
dossier.en_construction!
|
||||||
flash.notice = 'Dossier repassé en construction.'
|
flash.notice = 'Dossier repassé en construction.'
|
||||||
|
|
||||||
redirect_to gestionnaire_dossier_path(procedure, dossier)
|
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||||
end
|
end
|
||||||
|
|
||||||
def terminer
|
def terminer
|
||||||
|
@ -113,7 +113,7 @@ module NewGestionnaire
|
||||||
NotificationMailer.send_closed_notification(dossier).deliver_later
|
NotificationMailer.send_closed_notification(dossier).deliver_later
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to gestionnaire_dossier_path(procedure, dossier)
|
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_commentaire
|
def create_commentaire
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
|
|
||||||
export function showMotivation(state) {
|
export function showMotivation(event, state) {
|
||||||
|
event.preventDefault();
|
||||||
$(`.motivation.${state}`).show();
|
$(`.motivation.${state}`).show();
|
||||||
$('.dropdown-items').hide();
|
$('.dropdown-items').hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
= link_to "Uniquement cet onglet", "#", onclick: "window.print()", class: "menu-item menu-link"
|
= link_to "Uniquement cet onglet", "#", onclick: "window.print()", class: "menu-item menu-link"
|
||||||
|
|
||||||
= render partial: "new_gestionnaire/procedures/dossier_actions", locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: current_gestionnaire&.follow?(dossier) }
|
= render partial: "new_gestionnaire/procedures/dossier_actions", locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: current_gestionnaire&.follow?(dossier) }
|
||||||
|
%span.state-button
|
||||||
= render partial: "state_button", locals: { dossier: dossier }
|
= render partial: "state_button", locals: { dossier: dossier }
|
||||||
|
|
||||||
%ul.tabs
|
%ul.tabs
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
%h4 En construction
|
%h4 En construction
|
||||||
Vous permettez à l'usager de modifier ses réponses au formulaire
|
Vous permettez à l'usager de modifier ses réponses au formulaire
|
||||||
%li
|
%li
|
||||||
= link_to passer_en_instruction_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" } do
|
= link_to passer_en_instruction_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, data: { remote: true, confirm: "Confirmer vous le passage en instruction de ce dossier ?" } do
|
||||||
%span.icon.in-progress
|
%span.icon.in-progress
|
||||||
.description
|
.description
|
||||||
%h4 Passer en instruction
|
%h4 Passer en instruction
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
- if dossier.en_instruction?
|
- if dossier.en_instruction?
|
||||||
%li
|
%li
|
||||||
= link_to repasser_en_construction_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, data: { confirm: "Confirmer vous le passage en construction de ce dossier ?" } do
|
= link_to repasser_en_construction_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, data: { remote:true, confirm: "Confirmer vous le passage en construction de ce dossier ?" } do
|
||||||
%span.icon.edit
|
%span.icon.edit
|
||||||
.description
|
.description
|
||||||
%h4 Repasser en construction
|
%h4 Repasser en construction
|
||||||
|
@ -29,17 +29,20 @@
|
||||||
.description
|
.description
|
||||||
%h4 En instruction
|
%h4 En instruction
|
||||||
L'usager ne peut modifier son dossier pendant l'instruction
|
L'usager ne peut modifier son dossier pendant l'instruction
|
||||||
%li{ onclick: "DS.showMotivation('accept');" }
|
%li
|
||||||
|
%a{ href: '#', onclick: "DS.showMotivation(event, 'accept');" }
|
||||||
%span.icon.accept
|
%span.icon.accept
|
||||||
.description
|
.description
|
||||||
%h4 Accepter
|
%h4 Accepter
|
||||||
L'usager sera notifié que son dossier a été accepté
|
L'usager sera notifié que son dossier a été accepté
|
||||||
%li{ onclick: "DS.showMotivation('without-continuation');" }
|
%li
|
||||||
|
%a{ href: '#', onclick: "DS.showMotivation(event, 'without-continuation');" }
|
||||||
%span.icon.without-continuation
|
%span.icon.without-continuation
|
||||||
.description
|
.description
|
||||||
%h4 Classer sans suite
|
%h4 Classer sans suite
|
||||||
L'usager sera notifié que son dossier a été classé sans suite
|
L'usager sera notifié que son dossier a été classé sans suite
|
||||||
%li{ onclick: "DS.showMotivation('refuse');" }
|
%li
|
||||||
|
%a{ href: '#', onclick: "DS.showMotivation(event, 'refuse');" }
|
||||||
%span.icon.refuse
|
%span.icon.refuse
|
||||||
.description
|
.description
|
||||||
%h4 Refuser
|
%h4 Refuser
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
%span.icon{ class: popup_class }
|
%span.icon{ class: popup_class }
|
||||||
#{popup_title}
|
#{popup_title}
|
||||||
|
|
||||||
= form_tag(terminer_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, class: 'form') do
|
= form_tag(terminer_gestionnaire_dossier_path(dossier.procedure, dossier), remote: true, method: :post, class: 'form') do
|
||||||
- if title == 'Accepter'
|
- if title == 'Accepter'
|
||||||
= text_area :dossier, :motivation, class: 'motivation-text-area', placeholder: 'Rédigez votre motivation ici (facultative)', required: false
|
= text_area :dossier, :motivation, class: 'motivation-text-area', placeholder: 'Rédigez votre motivation ici (facultative)', required: false
|
||||||
%p.help
|
%p.help
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<%= render_flash %>
|
||||||
|
<%= render_to_element('.state-button', partial: "state_button", locals: { dossier: dossier }) %>
|
|
@ -107,12 +107,12 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
before do
|
before do
|
||||||
dossier.en_construction!
|
dossier.en_construction!
|
||||||
sign_in gestionnaire
|
sign_in gestionnaire
|
||||||
post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id }
|
post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js'
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(dossier.state).to eq(Dossier.states.fetch(:en_instruction)) }
|
it { expect(dossier.state).to eq(Dossier.states.fetch(:en_instruction)) }
|
||||||
it { is_expected.to redirect_to gestionnaire_dossier_path(procedure, dossier) }
|
it { expect(response.body).to include('.state-button') }
|
||||||
it { expect(gestionnaire.follow?(dossier)).to be true }
|
it { expect(gestionnaire.follow?(dossier)).to be true }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
sign_in gestionnaire
|
sign_in gestionnaire
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { post :repasser_en_construction, params: { procedure_id: procedure.id, dossier_id: dossier.id } }
|
subject { post :repasser_en_construction, params: { procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js' }
|
||||||
|
|
||||||
it 'change state to en_construction' do
|
it 'change state to en_construction' do
|
||||||
subject
|
subject
|
||||||
|
@ -131,7 +131,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
expect(dossier.state).to eq(Dossier.states.fetch(:en_construction))
|
expect(dossier.state).to eq(Dossier.states.fetch(:en_construction))
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to redirect_to gestionnaire_dossier_path(procedure, dossier) }
|
it { expect(subject.body).to include('.state-button') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#terminer' do
|
describe '#terminer' do
|
||||||
|
@ -141,7 +141,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
sign_in gestionnaire
|
sign_in gestionnaire
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id } }
|
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js' }
|
||||||
|
|
||||||
it 'change state to refuse' do
|
it 'change state to refuse' do
|
||||||
subject
|
subject
|
||||||
|
@ -158,7 +158,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to redirect_to redirect_to gestionnaire_dossier_path(procedure, dossier) }
|
it { expect(subject.body).to include('.state-button') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with classer_sans_suite" do
|
context "with classer_sans_suite" do
|
||||||
|
@ -167,7 +167,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
sign_in gestionnaire
|
sign_in gestionnaire
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id } }
|
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js' }
|
||||||
|
|
||||||
it 'change state to sans_suite' do
|
it 'change state to sans_suite' do
|
||||||
subject
|
subject
|
||||||
|
@ -184,7 +184,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to redirect_to redirect_to gestionnaire_dossier_path(procedure, dossier) }
|
it { expect(subject.body).to include('.state-button') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with accepter" do
|
context "with accepter" do
|
||||||
|
@ -199,7 +199,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
expect(NotificationMailer).to receive(:deliver_later)
|
expect(NotificationMailer).to receive(:deliver_later)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id } }
|
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js' }
|
||||||
|
|
||||||
it 'change state to accepte' do
|
it 'change state to accepte' do
|
||||||
subject
|
subject
|
||||||
|
@ -223,16 +223,14 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'The gestionnaire is sent back to the dossier page' do
|
it 'The gestionnaire is sent back to the dossier page' do
|
||||||
subject
|
expect(subject.body).to include('.state-button')
|
||||||
|
|
||||||
is_expected.to redirect_to redirect_to gestionnaire_dossier_path(procedure, dossier)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'and the dossier has already an attestation' do
|
context 'and the dossier has already an attestation' do
|
||||||
it 'should not crash' do
|
it 'should not crash' do
|
||||||
dossier.attestation = Attestation.new
|
dossier.attestation = Attestation.new
|
||||||
dossier.save
|
dossier.save
|
||||||
expect(subject).to redirect_to redirect_to gestionnaire_dossier_path(procedure, dossier)
|
expect(subject.body).to include('.state-button')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -248,7 +246,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
procedure_id: procedure.id,
|
procedure_id: procedure.id,
|
||||||
dossier_id: dossier.id,
|
dossier_id: dossier.id,
|
||||||
dossier: { motivation: "Yallah" }
|
dossier: { motivation: "Yallah" }
|
||||||
}
|
}, format: 'js'
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -9,7 +9,7 @@ feature 'The gestionnaire part' do
|
||||||
let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
|
let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
|
||||||
let!(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure) }
|
let!(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure) }
|
||||||
|
|
||||||
scenario 'A gestionnaire can accept a dossier' do
|
scenario 'A gestionnaire can accept a dossier', :js do
|
||||||
log_in(gestionnaire.email, password)
|
log_in(gestionnaire.email, password)
|
||||||
|
|
||||||
expect(page).to have_current_path(gestionnaire_procedures_path)
|
expect(page).to have_current_path(gestionnaire_procedures_path)
|
||||||
|
@ -20,14 +20,30 @@ feature 'The gestionnaire part' do
|
||||||
click_on dossier.user.email
|
click_on dossier.user.email
|
||||||
expect(page).to have_current_path(gestionnaire_dossier_path(procedure, dossier))
|
expect(page).to have_current_path(gestionnaire_dossier_path(procedure, dossier))
|
||||||
|
|
||||||
|
click_on 'En construction'
|
||||||
|
accept_confirm do
|
||||||
click_on 'Passer en instruction'
|
click_on 'Passer en instruction'
|
||||||
|
end
|
||||||
|
expect(page).to have_text('En instruction')
|
||||||
|
|
||||||
dossier.reload
|
dossier.reload
|
||||||
expect(dossier.state).to eq(Dossier.states.fetch(:en_instruction))
|
expect(dossier.state).to eq(Dossier.states.fetch(:en_instruction))
|
||||||
|
|
||||||
|
click_on 'En instruction'
|
||||||
|
|
||||||
|
within('.dropdown-items') do
|
||||||
|
click_on 'Accepter'
|
||||||
|
end
|
||||||
|
|
||||||
within('.accept.motivation') do
|
within('.accept.motivation') do
|
||||||
fill_in('dossier_motivation', with: 'a good reason')
|
fill_in('dossier_motivation', with: 'a good reason')
|
||||||
|
|
||||||
|
accept_confirm do
|
||||||
click_on 'Valider la décision'
|
click_on 'Valider la décision'
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to have_text('Dossier traité avec succès.')
|
||||||
|
|
||||||
dossier.reload
|
dossier.reload
|
||||||
expect(dossier.state).to eq(Dossier.states.fetch(:accepte))
|
expect(dossier.state).to eq(Dossier.states.fetch(:accepte))
|
||||||
|
|
Loading…
Reference in a new issue