feat: batch action for restaurer
This commit is contained in:
parent
5ec95d781c
commit
c0c2e35881
9 changed files with 126 additions and 12 deletions
|
@ -7,6 +7,7 @@ class BatchOperation < ApplicationRecord
|
|||
follow: 'follow',
|
||||
passer_en_instruction: 'passer_en_instruction',
|
||||
repasser_en_construction: 'repasser_en_construction',
|
||||
restaurer: 'restaurer',
|
||||
unfollow: 'unfollow',
|
||||
supprimer: 'supprimer'
|
||||
}
|
||||
|
@ -38,27 +39,28 @@ class BatchOperation < ApplicationRecord
|
|||
def dossiers_safe_scope(dossier_ids = self.dossier_ids)
|
||||
query = instructeur
|
||||
.dossiers
|
||||
.visible_by_administration
|
||||
.where(id: dossier_ids)
|
||||
case operation
|
||||
when BatchOperation.operations.fetch(:archiver) then
|
||||
query.not_archived.state_termine
|
||||
query.visible_by_administration.not_archived.state_termine
|
||||
when BatchOperation.operations.fetch(:passer_en_instruction) then
|
||||
query.state_en_construction
|
||||
query.visible_by_administration.state_en_construction
|
||||
when BatchOperation.operations.fetch(:accepter) then
|
||||
query.state_en_instruction
|
||||
query.visible_by_administration.state_en_instruction
|
||||
when BatchOperation.operations.fetch(:refuser) then
|
||||
query.state_en_instruction
|
||||
query.visible_by_administration.state_en_instruction
|
||||
when BatchOperation.operations.fetch(:classer_sans_suite) then
|
||||
query.state_en_instruction
|
||||
query.visible_by_administration.state_en_instruction
|
||||
when BatchOperation.operations.fetch(:follow) then
|
||||
query.without_followers.en_cours
|
||||
query.visible_by_administration.without_followers.en_cours
|
||||
when BatchOperation.operations.fetch(:repasser_en_construction) then
|
||||
query.state_en_instruction
|
||||
query.visible_by_administration.state_en_instruction
|
||||
when BatchOperation.operations.fetch(:unfollow) then
|
||||
query.with_followers.en_cours
|
||||
query.visible_by_administration.with_followers.en_cours
|
||||
when BatchOperation.operations.fetch(:supprimer) then
|
||||
query.state_termine
|
||||
query.visible_by_administration.state_termine
|
||||
when BatchOperation.operations.fetch(:restaurer) then
|
||||
query.hidden_by_administration
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -87,6 +89,8 @@ class BatchOperation < ApplicationRecord
|
|||
instructeur.unfollow(dossier)
|
||||
when BatchOperation.operations.fetch(:supprimer)
|
||||
dossier.hide_and_keep_track!(instructeur, :instructeur_request)
|
||||
when BatchOperation.operations.fetch(:restaurer)
|
||||
dossier.restore(instructeur)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue