refactor(dossier): change state with turbo
This commit is contained in:
parent
90ef2aed56
commit
95bd13872b
6 changed files with 33 additions and 35 deletions
|
@ -124,7 +124,8 @@ module Instructeurs
|
||||||
flash.alert = aasm_error_message(e, target_state: :en_instruction)
|
flash.alert = aasm_error_message(e, target_state: :en_instruction)
|
||||||
end
|
end
|
||||||
|
|
||||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
@dossier = dossier
|
||||||
|
render :change_state
|
||||||
end
|
end
|
||||||
|
|
||||||
def repasser_en_construction
|
def repasser_en_construction
|
||||||
|
@ -135,7 +136,8 @@ module Instructeurs
|
||||||
flash.alert = aasm_error_message(e, target_state: :en_construction)
|
flash.alert = aasm_error_message(e, target_state: :en_construction)
|
||||||
end
|
end
|
||||||
|
|
||||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
@dossier = dossier
|
||||||
|
render :change_state
|
||||||
end
|
end
|
||||||
|
|
||||||
def repasser_en_instruction
|
def repasser_en_instruction
|
||||||
|
@ -146,7 +148,8 @@ module Instructeurs
|
||||||
flash.alert = aasm_error_message(e, target_state: :en_instruction)
|
flash.alert = aasm_error_message(e, target_state: :en_instruction)
|
||||||
end
|
end
|
||||||
|
|
||||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
@dossier = dossier
|
||||||
|
render :change_state
|
||||||
end
|
end
|
||||||
|
|
||||||
def terminer
|
def terminer
|
||||||
|
@ -174,7 +177,8 @@ module Instructeurs
|
||||||
flash.alert = aasm_error_message(e, target_state: target_state)
|
flash.alert = aasm_error_message(e, target_state: target_state)
|
||||||
end
|
end
|
||||||
|
|
||||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
@dossier = dossier
|
||||||
|
render :change_state
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_commentaire
|
def create_commentaire
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
%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{ 'data-turbo': 'true' }
|
||||||
= link_to passer_en_instruction_instructeur_dossier_path(dossier.procedure, dossier), method: :post, data: { remote: true, confirm: "Confirmez-vous le passage en instruction de ce dossier ?" } do
|
= link_to passer_en_instruction_instructeur_dossier_path(dossier.procedure, dossier), data: { turbo_method: :post, turbo_confirm: "Confirmez-vous le passage en instruction de ce dossier ?" } do
|
||||||
%span.icon.in-progress
|
%span.icon.in-progress
|
||||||
.dropdown-description
|
.dropdown-description
|
||||||
%h4 Passer en instruction
|
%h4 Passer en instruction
|
||||||
|
@ -31,8 +31,8 @@
|
||||||
-# ------------------------------------------------------
|
-# ------------------------------------------------------
|
||||||
%ul.dropdown-items
|
%ul.dropdown-items
|
||||||
|
|
||||||
%li
|
%li{ 'data-turbo': 'true' }
|
||||||
= link_to repasser_en_construction_instructeur_dossier_path(dossier.procedure, dossier), method: :post, data: { remote:true, confirm: "Confirmez-vous le passage en construction de ce dossier ?" } do
|
= link_to repasser_en_construction_instructeur_dossier_path(dossier.procedure, dossier), data: { turbo_method: :post, turbo_confirm: "Confirmez-vous le passage en construction de ce dossier ?" } do
|
||||||
%span.icon.edit
|
%span.icon.edit
|
||||||
.dropdown-description
|
.dropdown-description
|
||||||
%h4 Repasser en construction
|
%h4 Repasser en construction
|
||||||
|
@ -100,8 +100,8 @@
|
||||||
%p Cette attestation a été envoyée automatiquement au demandeur.
|
%p Cette attestation a été envoyée automatiquement au demandeur.
|
||||||
|
|
||||||
- if dossier.can_repasser_en_instruction?
|
- if dossier.can_repasser_en_instruction?
|
||||||
%li
|
%li{ 'data-turbo': 'true' }
|
||||||
= link_to repasser_en_instruction_instructeur_dossier_path(dossier.procedure, dossier), method: :post, data: { remote:true, confirm: "Voulez vous remettre le dossier #{dossier.id} en instruction ?" } do
|
= link_to repasser_en_instruction_instructeur_dossier_path(dossier.procedure, dossier), data: { turbo_method: :post, turbo_confirm: "Voulez vous remettre le dossier #{dossier.id} en instruction ?" } do
|
||||||
%span.icon.in-progress
|
%span.icon.in-progress
|
||||||
.dropdown-description
|
.dropdown-description
|
||||||
%h4 Repasser en instruction
|
%h4 Repasser en instruction
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
%span.icon{ class: popup_class }
|
%span.icon{ class: popup_class }
|
||||||
#{popup_title}
|
#{popup_title}
|
||||||
|
|
||||||
= form_tag(terminer_instructeur_dossier_path(dossier.procedure, dossier), remote: true, method: :post, class: 'form') do
|
= form_tag(terminer_instructeur_dossier_path(dossier.procedure, dossier), data: { turbo: true, turbo_confirm: confirm }, method: :post, multipart: true, class: 'form') do
|
||||||
- if title == 'Accepter'
|
- if title == 'Accepter'
|
||||||
= text_area :dossier, :motivation, class: 'motivation-text-area', placeholder: placeholder, required: false
|
= text_area :dossier, :motivation, class: 'motivation-text-area', placeholder: placeholder, required: false
|
||||||
- if dossier.procedure.attestation_template&.activated?
|
- if dossier.procedure.attestation_template&.activated?
|
||||||
|
@ -37,4 +37,4 @@
|
||||||
= file_field :dossier, :justificatif_motivation, direct_upload: true
|
= file_field :dossier, :justificatif_motivation, direct_upload: true
|
||||||
.text-right
|
.text-right
|
||||||
%span.button{ onclick: 'DS.motivationCancel();' } Annuler
|
%span.button{ onclick: 'DS.motivationCancel();' } Annuler
|
||||||
= button_tag 'Valider la décision', name: :process_action, value: process_action, class: 'button primary', title: title, data: { confirm: confirm }
|
= button_tag 'Valider la décision', name: :process_action, value: process_action, class: 'button primary', title: title
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
<%= render_flash %>
|
|
||||||
<%= render_to_element('.header-actions', partial: 'header_actions', locals: { dossier: dossier }) %>
|
|
||||||
|
|
||||||
<% attachment = dossier.justificatif_motivation.attachment %>
|
|
||||||
<% if attachment && attachment.virus_scanner.pending? %>
|
|
||||||
<%= fire_event('attachment:update', { url: attachment_url(attachment.id, { signed_id: attachment.blob.signed_id }) }.to_json ) %>
|
|
||||||
<% end %>
|
|
|
@ -0,0 +1 @@
|
||||||
|
= turbo_stream.update_all '.header-actions', partial: 'header_actions', locals: { dossier: @dossier }
|
|
@ -99,7 +99,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in(instructeur.user)
|
sign_in(instructeur.user)
|
||||||
post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js'
|
post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id }, format: :turbo_stream
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) }
|
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) }
|
||||||
|
@ -113,7 +113,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
it 'warns about the error' do
|
it 'warns about the error' do
|
||||||
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction))
|
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction))
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.body).to have_text('Le dossier est déjà en instruction.')
|
expect(response.body).to include('Le dossier est déjà en instruction.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
|
|
||||||
it 'warns about the error' do
|
it 'warns about the error' do
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.body).to have_text('Le dossier est en ce moment accepté : il n’est pas possible de le passer en instruction.')
|
expect(response.body).to include('Le dossier est en ce moment accepté : il n’est pas possible de le passer en instruction.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -138,7 +138,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
sign_in(instructeur.user)
|
sign_in(instructeur.user)
|
||||||
post :repasser_en_construction,
|
post :repasser_en_construction,
|
||||||
params: { procedure_id: procedure.id, dossier_id: dossier.id },
|
params: { procedure_id: procedure.id, dossier_id: dossier.id },
|
||||||
format: 'js'
|
format: :turbo_stream
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction)) }
|
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction)) }
|
||||||
|
@ -151,7 +151,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
it 'warns about the error' do
|
it 'warns about the error' do
|
||||||
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction))
|
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction))
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.body).to have_text('Le dossier est déjà en construction.')
|
expect(response.body).to include('Le dossier est déjà en construction.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -163,7 +163,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
subject do
|
subject do
|
||||||
post :repasser_en_instruction,
|
post :repasser_en_instruction,
|
||||||
params: { procedure_id: procedure.id, dossier_id: dossier.id },
|
params: { procedure_id: procedure.id, dossier_id: dossier.id },
|
||||||
format: 'js'
|
format: :turbo_stream
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -186,7 +186,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
it 'warns about the error' do
|
it 'warns about the error' do
|
||||||
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction))
|
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction))
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.body).to have_text('Le dossier est déjà en instruction.')
|
expect(response.body).to include('Le dossier est déjà en instruction.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'simple refusal' do
|
context 'simple refusal' do
|
||||||
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js' }
|
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id }, format: :turbo_stream }
|
||||||
|
|
||||||
it 'change state to refuse' do
|
it 'change state to refuse' do
|
||||||
subject
|
subject
|
||||||
|
@ -244,7 +244,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'refusal with a justificatif' do
|
context 'refusal with a justificatif' do
|
||||||
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: 'js' }
|
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: :turbo_stream }
|
||||||
|
|
||||||
it 'attachs a justificatif' do
|
it 'attachs a justificatif' do
|
||||||
subject
|
subject
|
||||||
|
@ -264,7 +264,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
sign_in(instructeur.user)
|
sign_in(instructeur.user)
|
||||||
end
|
end
|
||||||
context 'without attachment' do
|
context 'without attachment' do
|
||||||
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js' }
|
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id }, format: :turbo_stream }
|
||||||
|
|
||||||
it 'change state to sans_suite' do
|
it 'change state to sans_suite' do
|
||||||
subject
|
subject
|
||||||
|
@ -286,7 +286,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with attachment' do
|
context 'with attachment' do
|
||||||
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: 'js' }
|
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: :turbo_stream }
|
||||||
|
|
||||||
it 'change state to sans_suite' do
|
it 'change state to sans_suite' do
|
||||||
subject
|
subject
|
||||||
|
@ -312,7 +312,7 @@ describe Instructeurs::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 }, format: 'js' }
|
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id }, format: :turbo_stream }
|
||||||
|
|
||||||
it 'change state to accepte' do
|
it 'change state to accepte' do
|
||||||
subject
|
subject
|
||||||
|
@ -361,7 +361,7 @@ describe Instructeurs::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'
|
}, format: :turbo_stream
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -374,7 +374,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with an attachment' do
|
context 'with an attachment' do
|
||||||
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: 'js' }
|
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: :turbo_stream }
|
||||||
|
|
||||||
it 'change state to accepte' do
|
it 'change state to accepte' do
|
||||||
subject
|
subject
|
||||||
|
@ -393,7 +393,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
|
|
||||||
before { allow(dossier).to receive(:after_accepter) }
|
before { allow(dossier).to receive(:after_accepter) }
|
||||||
|
|
||||||
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: 'js' }
|
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: :turbo_stream }
|
||||||
|
|
||||||
it 'does not close it again' do
|
it 'does not close it again' do
|
||||||
subject
|
subject
|
||||||
|
@ -402,7 +402,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
expect(dossier.state).to eq(Dossier.states.fetch(:accepte))
|
expect(dossier.state).to eq(Dossier.states.fetch(:accepte))
|
||||||
|
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.body).to have_text('Le dossier est déjà accepté.')
|
expect(response.body).to include('Le dossier est déjà accepté.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue