add bulk action 'follow'

This commit is contained in:
Lisa Durand 2023-01-04 11:51:22 +01:00
parent 177dec2bdb
commit 25a7fa5a34
10 changed files with 126 additions and 5 deletions

View file

@ -26,6 +26,15 @@ en:
text_success:
one: 1/1 is being accepted
other: "%{progress_count}/%{count} files have been accepted"
follow:
finish:
text_success:
one: 1/1 file has been followed
other: "%{success_count}/%{count} files have been followed"
in_progress:
text_success:
one: 1/1 is being followed
other: "%{progress_count}/%{count} files have been followed"
title:
finish: The bulk action is finished
in_progress: A bulk action is processing

View file

@ -26,6 +26,15 @@ fr:
text_success:
one: 1 dossier sera accepté
other: "%{progress_count}/%{count} dossiers ont été acceptés"
follow:
finish:
text_success:
one: 1 dossier a été suivi
other: "%{success_count}/%{count} dossiers ont été suivis"
in_progress:
text_success:
one: 1 dossier sera suivi
other: "%{progress_count}/%{count} dossiers ont été suivis"
title:
finish: L'action de masse est terminée
in_progress: Une action de masse est en cours

View file

@ -7,11 +7,21 @@ class Dossiers::BatchOperationComponent < ApplicationComponent
end
def render?
['traites', 'suivis'].include?(@statut)
['a-suivre', 'traites', 'suivis'].include?(@statut)
end
def available_operations
case @statut
when 'a-suivre' then
{
options:
[
{
label: t(".operations.follow"),
operation: BatchOperation.operations.fetch(:follow)
}
]
}
when 'traites' then
{
options:
@ -47,9 +57,10 @@ class Dossiers::BatchOperationComponent < ApplicationComponent
def icons
{
accepter: 'fr-icon-success-line',
archiver: 'fr-icon-folder-2-line',
passer_en_instruction: 'fr-icon-edit-line',
accepter: 'fr-icon-success-line'
follow: 'fr-icon-star-line',
passer_en_instruction: 'fr-icon-edit-line'
}
end
end

View file

@ -3,3 +3,4 @@ fr:
archiver: 'Archive selected files'
passer_en_instruction: 'Change selected files to instructing'
accepter: 'Accept seleted files'
follow: 'Follow seleted files'

View file

@ -3,3 +3,4 @@ fr:
archiver: 'Archiver les dossiers sélectionnés'
passer_en_instruction: 'Passer en instruction les dossiers sélectionnés'
accepter: 'Accepter les dossiers sélectionnés'
follow: 'Suivre les dossiers sélectionnés'

View file

@ -17,9 +17,10 @@
class BatchOperation < ApplicationRecord
enum operation: {
accepter: 'accepter',
archiver: 'archiver',
passer_en_instruction: 'passer_en_instruction',
accepter: 'accepter'
follow: 'follow',
passer_en_instruction: 'passer_en_instruction'
}
has_many :dossiers, dependent: :nullify
@ -58,6 +59,8 @@ class BatchOperation < ApplicationRecord
query.state_en_construction
when BatchOperation.operations.fetch(:accepter) then
query.state_en_instruction
when BatchOperation.operations.fetch(:follow) then
query.without_followers
end
end
@ -74,6 +77,8 @@ class BatchOperation < ApplicationRecord
dossier.passer_en_instruction(instructeur: instructeur)
when BatchOperation.operations.fetch(:accepter)
dossier.accepter(instructeur: instructeur, motivation: motivation, justificatif: justificatif_motivation)
when BatchOperation.operations.fetch(:follow)
instructeur.follow(dossier)
end
end