Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature ouidou/batch action on dossiers desarchiver #9766

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ en:
text_success:
one: "1 is being archived"
other: "%{success_count}/%{count} files have been archived"
desarchiver:
finish:
text_success:
one: "%{success_count}/1 file has been unarchived"
other: "%{success_count}/%{count} files have been unarchived"
in_progress:
text_success:
one: "1 is being unarchived"
other: "%{success_count}/%{count} files have been unarchived"
passer_en_instruction:
finish:
text_success:
Expand Down Expand Up @@ -35,6 +44,24 @@ en:
text_success:
one: "1 is being refused"
other: "%{success_count}/%{count} files have been refused"
supprimer:
finish:
text_success:
one: "%{success_count}/1 file has been deleted"
other: "%{success_count}/%{count} files have been deleted"
in_progress:
text_success:
one: "1 is being deleted"
other: "%{success_count}/%{count} files have been deleted"
restaurer:
finish:
text_success:
one: "%{success_count}/1 file has been restored"
other: "%{success_count}/%{count} files have been restored"
in_progress:
text_success:
one: "1 is being restored"
other: "%{success_count}/%{count} files have been restored"
classer_sans_suite:
finish:
text_success:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ fr:
text_success:
one: "1 dossier est en cours d'archivage"
other: "%{success_count}/%{count} dossiers ont été archivés"
desarchiver:
finish:
text_success:
one: "%{success_count}/1 dossier a été désarchivé"
other: "%{success_count}/%{count} dossiers ont été désarchivés"
in_progress:
text_success:
one: "1 dossier est en cours d'désarchivage"
other: "%{success_count}/%{count} dossiers ont été désarchivés"
passer_en_instruction:
finish:
text_success:
Expand Down Expand Up @@ -35,6 +44,24 @@ fr:
text_success:
one: "1 dossier est en cours de refus"
other: "%{success_count}/%{count} dossiers ont été refusés"
supprimer:
finish:
text_success:
one: "%{success_count}/1 dossier a été supprimé"
other: "%{success_count}/%{count} dossiers ont été supprimés"
in_progress:
text_success:
one: "1 dossier est en cours de suppression"
other: "%{success_count}/%{count} dossiers ont été supprimés"
restaurer:
finish:
text_success:
one: "%{success_count}/1 dossier a été restauré"
other: "%{success_count}/%{count} dossiers ont été restaurés"
in_progress:
text_success:
one: "1 dossier est en cours de restauration"
other: "%{success_count}/%{count} dossiers ont été restaurés"
classer_sans_suite:
finish:
text_success:
Expand Down
31 changes: 29 additions & 2 deletions app/components/dossiers/batch_operation_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(statut:, procedure:)
end

def render?
['a-suivre', 'traites', 'suivis'].include?(@statut)
['a-suivre', 'traites', 'suivis', 'archives', 'supprimes_recemment'].include?(@statut)
end

def operations_for_dossier(dossier)
Expand All @@ -17,7 +17,7 @@ def operations_for_dossier(dossier)
when Dossier.states.fetch(:en_instruction)
[BatchOperation.operations.fetch(:accepter), BatchOperation.operations.fetch(:refuser), BatchOperation.operations.fetch(:classer_sans_suite), BatchOperation.operations.fetch(:repasser_en_construction)]
when Dossier.states.fetch(:accepte), Dossier.states.fetch(:refuse), Dossier.states.fetch(:sans_suite)
[BatchOperation.operations.fetch(:archiver)]
[BatchOperation.operations.fetch(:archiver), BatchOperation.operations.fetch(:desarchiver), BatchOperation.operations.fetch(:supprimer), BatchOperation.operations.fetch(:restaurer)]
else
[]
end.append(BatchOperation.operations.fetch(:follow), BatchOperation.operations.fetch(:unfollow))
Expand All @@ -37,13 +37,37 @@ def available_operations
}
]
}
when 'archives' then
{
options:
[
{
label: t(".operations.desarchiver"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

en voyant la capture écran, je me dis qu'on peut rajouter à peu de frais l'action "supprimer" pour avoir toutes les actions multiples disponibles sur cet onglet ?

operation: BatchOperation.operations.fetch(:desarchiver)
}
]
}
when 'traites' then
{
options:
[
{
label: t(".operations.archiver"),
operation: BatchOperation.operations.fetch(:archiver)
},
{
label: t(".operations.supprimer"),
operation: BatchOperation.operations.fetch(:supprimer)
}
]
}
when 'supprimes_recemment' then
{
options:
[
{
label: t(".operations.restaurer"),
operation: BatchOperation.operations.fetch(:restaurer)
}
]
}
Expand Down Expand Up @@ -107,9 +131,12 @@ def icons
{
accepter: 'fr-icon-success-line',
archiver: 'fr-icon-folder-2-line',
desarchiver: 'fr-icon-upload-2-line',
follow: 'fr-icon-star-line',
passer_en_instruction: 'fr-icon-edit-line',
repasser_en_construction: 'fr-icon-draft-line',
supprimer: 'fr-icon-delete-line',
restaurer: 'fr-icon-refresh-line',
unfollow: 'fr-icon-star-fill'
}
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
fr:
operations:
archiver: 'Archive selected files'
desarchiver: 'Unarchive selected files'
passer_en_instruction: 'Change selected files to instructing'
instruction: Instructing files
accepter: 'Accept seleted files'
supprimer: Delete seleted files
restaurer: Restore seleted files
accepter_description: Users will be notified that their file has been accepted
refuser: 'Refuse seleted files'
refuser_description: Users will be notified that their file has been refused
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
fr:
operations:
archiver: 'Archiver les dossiers'
desarchiver: 'Désarchiver les dossiers'
passer_en_instruction: 'Passer les dossiers en instruction'
instruction: Instruire les dossiers
accepter: 'Accepter les dossiers'
supprimer: 'Supprimer les dossiers'
restaurer: 'Restaurer les dossiers'
accepter_description: Les usagers seront informés que leur dossier a été accepté
refuser: 'Refuser les dossiers'
refuser_description: Les usagers seront informés que leur dossier a été refusé
Expand Down
34 changes: 24 additions & 10 deletions app/models/batch_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ class BatchOperation < ApplicationRecord
refuser: 'refuser',
classer_sans_suite: 'classer_sans_suite',
archiver: 'archiver',
desarchiver: 'desarchiver',
follow: 'follow',
passer_en_instruction: 'passer_en_instruction',
repasser_en_construction: 'repasser_en_construction',
unfollow: 'unfollow'
restaurer: 'restaurer',
unfollow: 'unfollow',
supprimer: 'supprimer'
}

has_many :dossiers, dependent: :nullify
Expand Down Expand Up @@ -37,25 +40,30 @@ 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(:desarchiver) then
query.visible_by_administration.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.visible_by_administration.state_termine
when BatchOperation.operations.fetch(:restaurer) then
query.hidden_by_administration
end
end

Expand All @@ -68,6 +76,8 @@ def process_one(dossier)
case operation
when BatchOperation.operations.fetch(:archiver)
dossier.archiver!(instructeur)
when BatchOperation.operations.fetch(:desarchiver)
dossier.desarchiver!
when BatchOperation.operations.fetch(:passer_en_instruction)
dossier.passer_en_instruction(instructeur: instructeur)
when BatchOperation.operations.fetch(:accepter)
Expand All @@ -82,6 +92,10 @@ def process_one(dossier)
dossier.repasser_en_construction!(instructeur: instructeur)
when BatchOperation.operations.fetch(:unfollow)
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

Expand Down
Loading
Loading