add classer_sans_suite and refuser to batch operation

This commit is contained in:
Lisa Durand 2023-07-03 16:05:48 +02:00
parent f3922c7e39
commit 220b71bbf7
9 changed files with 81 additions and 32 deletions

View file

@ -15,7 +15,7 @@ class Dossiers::BatchOperationComponent < ApplicationComponent
when Dossier.states.fetch(:en_construction)
[BatchOperation.operations.fetch(:passer_en_instruction)]
when Dossier.states.fetch(:en_instruction)
[BatchOperation.operations.fetch(:accepter), BatchOperation.operations.fetch(:repasser_en_construction)]
[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)]
else
@ -57,11 +57,31 @@ class Dossiers::BatchOperationComponent < ApplicationComponent
operation: BatchOperation.operations.fetch(:passer_en_instruction)
},
{
instruction:
[
{
label: t(".operations.accepter"),
operation: BatchOperation.operations.fetch(:accepter)
operation_description: t(".operations.accepter_description"),
operation: BatchOperation.operations.fetch(:accepter),
operation_class_name: 'accept'
},
{
label: t(".operations.refuser"),
operation_description: t(".operations.refuser_description"),
operation: BatchOperation.operations.fetch(:refuser),
operation_class_name: 'refuse'
},
{
label: t(".operations.classer_sans_suite"),
operation_description: t(".operations.classer_sans_suite_description"),
operation: BatchOperation.operations.fetch(:classer_sans_suite),
operation_class_name: 'without-continuation'
}
]
},
{
label: t(".operations.unfollow"),
operation: BatchOperation.operations.fetch(:unfollow)

View file

@ -2,7 +2,14 @@ fr:
operations:
archiver: 'Archive selected files'
passer_en_instruction: 'Change selected files to instructing'
instruction: Instructing files
accepter: 'Accept 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
without_continuation: 'Close without continuation seleted files'
without_continuation_description: Users will be notified that their file has been closed without continuation
follow: 'Follow seleted files'
unfollow: 'Unfollow seleted files'
repasser_en_construction: 'Change selected files to in progress'
other: Other batch operations

View file

@ -2,7 +2,14 @@ fr:
operations:
archiver: 'Archiver les dossiers'
passer_en_instruction: 'Passer les dossiers en instruction'
instruction: Instruire les dossiers
accepter: 'Accepter 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é
classer_sans_suite: 'Classer sans suite les dossiers'
classer_sans_suite_description: Les usagers seront informés que leur dossier a été classé sans suite
follow: 'Suivre les dossiers'
unfollow: 'Ne plus suivre les dossiers'
repasser_en_construction: 'Repasser les dossiers en construction'
other: Autres actions multiples

View file

@ -12,7 +12,7 @@
.dropdown{ data: { controller: 'menu-button', popover: 'true' } }
-# Dropdown button title
%button.fr-btn.fr-btn--sm.fr-btn--secondary.fr-ml-1w.dropdown-button{ disabled: true, data: { menu_button_target: 'button', batch_operation_target: 'menu' } }
Autres actions multiples
= t('.operations.other')
#state-menu.dropdown-content.fade-in-down{ data: { menu_button_target: 'menu' } }
%ul.dropdown-items

View file

@ -0,0 +1,3 @@
en:
labels:
instruction: Instruct files

View file

@ -0,0 +1,3 @@
fr:
labels:
instruction: Instruire les dossiers

View file

@ -1,31 +1,17 @@
- if opt[:operation] == 'accepter'
.dropdown{ data: { controller: 'menu-button', popover: 'true', operation: opt[:operation] }, id: 'dropdown_batch' }
-# Dropdown button title
%button{ disabled: true, class: ['fr-btn fr-btn--sm fr-btn--icon-left fr-ml-1w', icons[opt[:operation].to_sym]], disabled: true, name: "#{form.object_name}[operation]" , data: { menu_button_target: 'button' } }
= opt[:label]
- if opt.keys.include?(:instruction)
= render Dropdown::MenuComponent.new(wrapper: :div, wrapper_options: { data: {controller: 'menu-button', popover: 'true', operation: opt[:operation]} }, menu_options: { id: "dropdown_batch" }, button_options: { class: "fr-btn fr-btn--sm fr-ml-1w"}, role: :region ) do |menu|
- menu.with_button_inner_html do
= t(".labels.instruction")
#state-menu.dropdown-content.fade-in-down{ data: { menu_button_target: 'menu' } }
%ul.dropdown-items
%li.inactive{ 'data-turbo': 'true' }
- if opt[:operation] == 'accepter'
.wrapper
.dropdown-items-link
%span{ class: icons[opt[:operation].to_sym] }
- opt[:instruction].each do |opt|
- menu.with_item do
= link_to('#', onclick: "DS.showMotivation(event, '#{opt[:operation_class_name]}');", role: 'menuitem') do
%span{ class: "icon #{opt[:operation_class_name]}" }
.dropdown-description
%h4= opt[:label]
= opt[:operation_description]
.motivation.accept
= form.text_area :motivation, class: 'fr-input'
#justificatif_motivation_suggest_accept.optional-justificatif
%button.fr-btn.fr-btn--sm.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-attachment-line.fr-ml-0{ type: 'button', onclick: "DS.showImportJustificatif('accept');" } Ajouter un justificatif (optionnel)
#justificatif_motivation_import_accept.hidden
= form.file_field :justificatif_motivation, direct_upload: true, id: "dossier_justificatif_motivation_accept", onchange: "DS.showDeleteJustificatif('accept');"
.hidden.js_delete_motivation{ id: "delete_motivation_import_accept" }
%button.fr-btn.fr-btn--sm.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-delete-line.fr-ml-0.fr-mt-1w{ type: 'button', onclick: "DS.deleteJustificatif('accept');" } Supprimer le justificatif
= button_tag "Annuler", type: :reset, class: 'fr-btn fr-btn--sm fr-btn--secondary', onclick: 'DS.motivationCancelBatch();'
= form.button "Valider la décision", class: ['fr-btn fr-btn--sm fr-mt-2w'], disabled: true, name: "#{form.object_name}[operation]", value: opt[:operation]
- menu.with_item(class: "hidden inactive form-inside fr-pt-1v") do
= render partial: 'instructeurs/dossiers/instruction_button_motivation_batch', locals: { instruction_operation: opt[:operation_class_name], form:, opt: }
- else
= form.button opt[:label], class: ['fr-btn fr-btn--sm fr-btn--icon-left fr-ml-1w', icons[opt[:operation].to_sym]], disabled: true, name: "#{form.object_name}[operation]", value: opt[:operation], data: { operation: opt[:operation] }

View file

@ -18,6 +18,8 @@
class BatchOperation < ApplicationRecord
enum operation: {
accepter: 'accepter',
refuser: 'refuser',
classer_sans_suite: 'classer_sans_suite',
archiver: 'archiver',
follow: 'follow',
passer_en_instruction: 'passer_en_instruction',
@ -61,6 +63,10 @@ class BatchOperation < ApplicationRecord
query.state_en_construction
when BatchOperation.operations.fetch(:accepter) then
query.state_en_instruction
when BatchOperation.operations.fetch(:refuser) then
query.state_en_instruction
when BatchOperation.operations.fetch(:classer_sans_suite) then
query.state_en_instruction
when BatchOperation.operations.fetch(:follow) then
query.without_followers.en_cours
when BatchOperation.operations.fetch(:repasser_en_construction) then
@ -83,6 +89,10 @@ 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(:refuser)
dossier.refuser(instructeur: instructeur, motivation: motivation, justificatif: justificatif_motivation)
when BatchOperation.operations.fetch(:classer_sans_suite)
dossier.classer_sans_suite(instructeur: instructeur, motivation: motivation, justificatif: justificatif_motivation)
when BatchOperation.operations.fetch(:follow)
instructeur.follow(dossier)
when BatchOperation.operations.fetch(:repasser_en_construction)

View file

@ -0,0 +1,13 @@
%div{ class: "motivation #{instruction_operation}" }
= form.text_area :motivation, class: 'fr-input'
.optional-justificatif{ id: "justificatif_motivation_suggest_#{instruction_operation}" }
%button.fr-btn.fr-btn--sm.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-attachment-line.fr-ml-0{ type: 'button', onclick: "DS.showImportJustificatif('#{instruction_operation}');" } Ajouter un justificatif (optionnel)
.hidden{ id: "justificatif_motivation_import_#{instruction_operation}" }
= form.file_field :justificatif_motivation, direct_upload: true, id: "dossier_justificatif_motivation_#{instruction_operation}", onchange: "DS.showDeleteJustificatif('#{instruction_operation}');"
.hidden.js_delete_motivation{ id: "delete_motivation_import_#{instruction_operation}" }
%button.fr-btn.fr-btn--sm.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-delete-line.fr-ml-0.fr-mt-1w{ type: 'button', onclick: "DS.deleteJustificatif('#{instruction_operation}');" } Supprimer le justificatif
= button_tag "Annuler", type: :reset, class: 'fr-btn fr-btn--sm fr-btn--secondary', onclick: 'DS.motivationCancelBatch();'
= form.button "Valider la décision", class: ['fr-btn fr-btn--sm fr-mt-2w'], disabled: true, name: "#{form.object_name}[operation]", value: opt[:operation], data: { operation: opt[:operation] }