add action 'repasser en construction' to page 'suivis'
This commit is contained in:
parent
65e125b4ec
commit
2f666b487e
10 changed files with 116 additions and 5 deletions
|
@ -35,6 +35,15 @@ en:
|
||||||
text_success:
|
text_success:
|
||||||
one: 1/1 is being followed
|
one: 1/1 is being followed
|
||||||
other: "%{progress_count}/%{count} files have been followed"
|
other: "%{progress_count}/%{count} files have been followed"
|
||||||
|
repasser_en_construction:
|
||||||
|
finish:
|
||||||
|
text_success:
|
||||||
|
one: 1/1 file has been changed to in progress
|
||||||
|
other: "%{success_count}/%{count} files have been changed to in progress"
|
||||||
|
in_progress:
|
||||||
|
text_success:
|
||||||
|
one: 1/1 is being changed to in progress
|
||||||
|
other: "%{progress_count}/%{count} files have been changed to in progress"
|
||||||
title:
|
title:
|
||||||
finish: The bulk action is finished
|
finish: The bulk action is finished
|
||||||
in_progress: A bulk action is processing
|
in_progress: A bulk action is processing
|
||||||
|
|
|
@ -35,6 +35,15 @@ fr:
|
||||||
text_success:
|
text_success:
|
||||||
one: 1 dossier sera suivi
|
one: 1 dossier sera suivi
|
||||||
other: "%{progress_count}/%{count} dossiers ont été suivis"
|
other: "%{progress_count}/%{count} dossiers ont été suivis"
|
||||||
|
repasser_en_construction:
|
||||||
|
finish:
|
||||||
|
text_success:
|
||||||
|
one: 1 dossier a été repassé en construction
|
||||||
|
other: "%{success_count}/%{count} dossiers ont été repassés en construction"
|
||||||
|
in_progress:
|
||||||
|
text_success:
|
||||||
|
one: 1 dossier sera repassé en construction
|
||||||
|
other: "%{progress_count}/%{count} dossiers ont été repassés en construction"
|
||||||
title:
|
title:
|
||||||
finish: L'action de masse est terminée
|
finish: L'action de masse est terminée
|
||||||
in_progress: Une action de masse est en cours
|
in_progress: Une action de masse est en cours
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Dossiers::BatchOperationComponent < ApplicationComponent
|
||||||
when Dossier.states.fetch(:en_construction)
|
when Dossier.states.fetch(:en_construction)
|
||||||
[BatchOperation.operations.fetch(:passer_en_instruction), BatchOperation.operations.fetch(:follow)]
|
[BatchOperation.operations.fetch(:passer_en_instruction), BatchOperation.operations.fetch(:follow)]
|
||||||
when Dossier.states.fetch(:en_instruction)
|
when Dossier.states.fetch(:en_instruction)
|
||||||
[BatchOperation.operations.fetch(:accepter)]
|
[BatchOperation.operations.fetch(:accepter), BatchOperation.operations.fetch(:repasser_en_construction)]
|
||||||
when Dossier.states.fetch(:accepte), Dossier.states.fetch(:refuse), Dossier.states.fetch(:sans_suite)
|
when Dossier.states.fetch(:accepte), Dossier.states.fetch(:refuse), Dossier.states.fetch(:sans_suite)
|
||||||
[BatchOperation.operations.fetch(:archiver)]
|
[BatchOperation.operations.fetch(:archiver)]
|
||||||
else
|
else
|
||||||
|
@ -60,6 +60,11 @@ class Dossiers::BatchOperationComponent < ApplicationComponent
|
||||||
{
|
{
|
||||||
label: t(".operations.accepter"),
|
label: t(".operations.accepter"),
|
||||||
operation: BatchOperation.operations.fetch(:accepter)
|
operation: BatchOperation.operations.fetch(:accepter)
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
label: t(".operations.repasser_en_construction"),
|
||||||
|
operation: BatchOperation.operations.fetch(:repasser_en_construction)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -75,7 +80,8 @@ class Dossiers::BatchOperationComponent < ApplicationComponent
|
||||||
accepter: 'fr-icon-success-line',
|
accepter: 'fr-icon-success-line',
|
||||||
archiver: 'fr-icon-folder-2-line',
|
archiver: 'fr-icon-folder-2-line',
|
||||||
follow: 'fr-icon-star-line',
|
follow: 'fr-icon-star-line',
|
||||||
passer_en_instruction: 'fr-icon-edit-line'
|
passer_en_instruction: 'fr-icon-edit-line',
|
||||||
|
repasser_en_construction: 'fr-icon-draft-line'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,3 +4,4 @@ fr:
|
||||||
passer_en_instruction: 'Change selected files to instructing'
|
passer_en_instruction: 'Change selected files to instructing'
|
||||||
accepter: 'Accept seleted files'
|
accepter: 'Accept seleted files'
|
||||||
follow: 'Follow seleted files'
|
follow: 'Follow seleted files'
|
||||||
|
repasser_en_construction: 'Change selected files to in progress'
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
fr:
|
fr:
|
||||||
operations:
|
operations:
|
||||||
archiver: 'Archiver les dossiers'
|
archiver: 'Archiver les dossiers'
|
||||||
passer_en_instruction: 'Passer en instruction les dossiers'
|
passer_en_instruction: 'Passer les dossiers en instruction'
|
||||||
accepter: 'Accepter les dossiers'
|
accepter: 'Accepter les dossiers'
|
||||||
follow: 'Suivre les dossiers'
|
follow: 'Suivre les dossiers'
|
||||||
|
repasser_en_construction: 'Repasser les dossiers en construction'
|
||||||
|
|
|
@ -20,7 +20,8 @@ class BatchOperation < ApplicationRecord
|
||||||
accepter: 'accepter',
|
accepter: 'accepter',
|
||||||
archiver: 'archiver',
|
archiver: 'archiver',
|
||||||
follow: 'follow',
|
follow: 'follow',
|
||||||
passer_en_instruction: 'passer_en_instruction'
|
passer_en_instruction: 'passer_en_instruction',
|
||||||
|
repasser_en_construction: 'repasser_en_construction'
|
||||||
}
|
}
|
||||||
|
|
||||||
has_many :dossiers, dependent: :nullify
|
has_many :dossiers, dependent: :nullify
|
||||||
|
@ -61,6 +62,8 @@ class BatchOperation < ApplicationRecord
|
||||||
query.state_en_instruction
|
query.state_en_instruction
|
||||||
when BatchOperation.operations.fetch(:follow) then
|
when BatchOperation.operations.fetch(:follow) then
|
||||||
query.without_followers.en_cours
|
query.without_followers.en_cours
|
||||||
|
when BatchOperation.operations.fetch(:repasser_en_construction) then
|
||||||
|
query.state_en_instruction
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -79,6 +82,8 @@ class BatchOperation < ApplicationRecord
|
||||||
dossier.accepter(instructeur: instructeur, motivation: motivation, justificatif: justificatif_motivation)
|
dossier.accepter(instructeur: instructeur, motivation: motivation, justificatif: justificatif_motivation)
|
||||||
when BatchOperation.operations.fetch(:follow)
|
when BatchOperation.operations.fetch(:follow)
|
||||||
instructeur.follow(dossier)
|
instructeur.follow(dossier)
|
||||||
|
when BatchOperation.operations.fetch(:repasser_en_construction)
|
||||||
|
dossier.repasser_en_construction!(instructeur: instructeur)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -218,4 +218,58 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'repasser en construction' do
|
||||||
|
let(:component) do
|
||||||
|
described_class.new(
|
||||||
|
batch: batch_operation,
|
||||||
|
procedure: procedure
|
||||||
|
)
|
||||||
|
end
|
||||||
|
let!(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||||
|
let!(:dossier_2) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||||
|
let!(:batch_operation) { create(:batch_operation, operation: :repasser_en_construction, dossiers: [dossier, dossier_2], instructeur: instructeur) }
|
||||||
|
|
||||||
|
context 'in_progress' do
|
||||||
|
before {
|
||||||
|
batch_operation.track_processed_dossier(true, dossier)
|
||||||
|
batch_operation.reload
|
||||||
|
}
|
||||||
|
|
||||||
|
it { is_expected.to have_selector('.fr-alert--info') }
|
||||||
|
it { is_expected.to have_text("Une action de masse est en cours") }
|
||||||
|
it { is_expected.to have_text("1/2 dossiers ont été repassés en construction") }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'finished and success' do
|
||||||
|
before {
|
||||||
|
batch_operation.track_processed_dossier(true, dossier)
|
||||||
|
batch_operation.track_processed_dossier(true, dossier_2)
|
||||||
|
batch_operation.reload
|
||||||
|
}
|
||||||
|
|
||||||
|
it { is_expected.to have_selector('.fr-alert--success') }
|
||||||
|
it { is_expected.to have_text("L'action de masse est terminée") }
|
||||||
|
it { is_expected.to have_text("2 dossiers ont été repassés en construction") }
|
||||||
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'finished and fail' do
|
||||||
|
before {
|
||||||
|
batch_operation.track_processed_dossier(false, dossier)
|
||||||
|
batch_operation.track_processed_dossier(true, dossier_2)
|
||||||
|
batch_operation.reload
|
||||||
|
}
|
||||||
|
|
||||||
|
it { is_expected.to have_selector('.fr-alert--warning') }
|
||||||
|
it { is_expected.to have_text("L'action de masse est terminée") }
|
||||||
|
it { is_expected.to have_text("1/2 dossiers ont été repassés en construction") }
|
||||||
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
||||||
|
|
||||||
|
it 'on next render "seen_at" is set to avoid rendering alert' do
|
||||||
|
render_inline(component).to_html
|
||||||
|
expect(batch_operation.seen_at).not_to eq(nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,8 +20,9 @@ RSpec.describe Dossiers::BatchOperationComponent, type: :component do
|
||||||
subject { render_inline(component).to_html }
|
subject { render_inline(component).to_html }
|
||||||
context 'statut suivis' do
|
context 'statut suivis' do
|
||||||
let(:statut) { 'suivis' }
|
let(:statut) { 'suivis' }
|
||||||
it { is_expected.to have_button('Passer en instruction les dossiers', disabled: true) }
|
it { is_expected.to have_button('Passer les dossiers en instruction', disabled: true) }
|
||||||
it { is_expected.to have_button('Accepter les dossiers', disabled: true) }
|
it { is_expected.to have_button('Accepter les dossiers', disabled: true) }
|
||||||
|
it { is_expected.to have_button('Repasser les dossiers en construction', disabled: true) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'statut a-suivre' do
|
context 'statut a-suivre' do
|
||||||
|
|
|
@ -50,5 +50,16 @@ FactoryBot.define do
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :repasser_en_construction do
|
||||||
|
operation { BatchOperation.operations.fetch(:repasser_en_construction) }
|
||||||
|
after(:build) do |batch_operation, evaluator|
|
||||||
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur], administrateurs: [create(:administrateur)])
|
||||||
|
batch_operation.dossiers = [
|
||||||
|
create(:dossier, :with_individual, :en_instruction, procedure: procedure),
|
||||||
|
create(:dossier, :with_individual, :en_instruction, procedure: procedure)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,6 +60,20 @@ describe BatchOperationProcessOneJob, type: :job do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when operation is "repasser en construction"' do
|
||||||
|
let(:batch_operation) do
|
||||||
|
create(:batch_operation, :repasser_en_construction,
|
||||||
|
options.merge(instructeur: create(:instructeur)))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'changed the dossier to en construction' do
|
||||||
|
expect { subject.perform_now }
|
||||||
|
.to change { dossier_job.reload.en_construction? }
|
||||||
|
.from(false)
|
||||||
|
.to(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when operation is "accepter"' do
|
context 'when operation is "accepter"' do
|
||||||
let(:batch_operation) do
|
let(:batch_operation) do
|
||||||
create(:batch_operation, :accepter,
|
create(:batch_operation, :accepter,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue