feedbacks from Martin

This commit is contained in:
Lisa Durand 2023-01-05 15:10:07 +01:00
parent 3918757dc9
commit 4afb873afc
3 changed files with 42 additions and 46 deletions

View file

@ -273,7 +273,6 @@ ul.dropdown-items {
margin: -$default-padding; margin: -$default-padding;
padding: $default-padding; padding: $default-padding;
text-align: left; text-align: left;
font-size: 12px;
} }
.icon { .icon {

View file

@ -1,42 +1,41 @@
- if available_operations[:options].present? - if available_operations[:options].count == 1
- if available_operations[:options].count == 1 - opt = available_operations[:options].dig(0)
- opt = available_operations[:options].dig(0) = form_for(BatchOperation.new, url: instructeur_batch_operations_path(procedure_id: procedure.id), method: :post, html: { class: 'flex justify-end', id: "#{dom_id(BatchOperation.new)}" }, data: { "batch-operation-target" => "form"}) do |form|
= form_for(BatchOperation.new, url: instructeur_batch_operations_path(procedure_id: procedure.id), method: :post, html: { class: 'flex justify-end', id: "#{dom_id(BatchOperation.new)}" }, data: { "batch-operation-target" => "form"}) do |form| = form.button opt[:label], class: ['fr-btn fr-btn--icon-left', icons[opt[:operation].to_sym]], disabled: :disabled, name: "#{form.object_name}[operation]", data: { "batch-operation-target" => "submit", "submitter-operation" => opt[:operation] }
= form.button opt[:label], class: ['fr-btn fr-btn--icon-left', icons[opt[:operation].to_sym]], disabled: :disabled, name: "#{form.object_name}[operation]", data: { "batch-operation-target" => "submit", "submitter-operation" => opt[:operation] }
- else - else
.flex.justify-end .flex.justify-end
.dropdown{ data: { controller: 'menu-button', popover: 'true' } } .dropdown{ data: { controller: 'menu-button', popover: 'true' } }
-# Dropdown button title -# Dropdown button title
%button.fr-btn.dropdown-button{ id: 'batch_operation_dropdown', disabled: :disabled, data: { menu_button_target: 'button'} } %button.fr-btn.dropdown-button{ id: 'batch_operation_dropdown', disabled: :disabled, data: { menu_button_target: 'button'} }
Actions multiples Actions multiples
#state-menu.dropdown-content.fade-in-down{ data: { menu_button_target: 'menu' } } #state-menu.dropdown-content.fade-in-down{ data: { menu_button_target: 'menu' } }
= form_for(BatchOperation.new, url: instructeur_batch_operations_path(procedure_id: procedure.id), method: :post, html: { class: 'flex justify-end form', id: "#{dom_id(BatchOperation.new)}" }, data: { "batch-operation-target" => "form"}) do |form| = form_for(BatchOperation.new, url: instructeur_batch_operations_path(procedure_id: procedure.id), method: :post, html: { class: 'flex justify-end form', id: "#{dom_id(BatchOperation.new)}" }, data: { "batch-operation-target" => "form"}) do |form|
%ul.dropdown-items %ul.dropdown-items
- available_operations[:options].each do |opt| - available_operations[:options].each do |opt|
%li{ 'data-turbo': 'true' } %li{ 'data-turbo': 'true' }
- if opt[:operation] == 'accepter' - if opt[:operation] == 'accepter'
.wrapper .wrapper
%a.dropdown-items-link{ href: '#', onclick: "DS.showMotivation(event, 'accept');" } %a.dropdown-items-link{ href: '#', onclick: "DS.showMotivation(event, 'accept');" }
%span{ class: icons[opt[:operation].to_sym] }
.dropdown-description
%h4= opt[:label]
.motivation.hidden.accept
= form.text_area :motivation, class: 'motivation-text-area'
.optional-justificatif{ id: "justificatif_motivation_suggest_accept", onclick: "DS.showImportJustificatif('accept');" }
.button Ajouter un justificatif (optionnel)
.hidden{ id: "justificatif_motivation_import_accept" }
= form.file_field :justificatif_motivation, direct_upload: true
.text-right
%span{ onclick: 'DS.motivationCancel();', class: 'fr-btn fr-btn--secondary' } Annuler
= form.button "Valider la décision", class: ['fr-btn'], disabled: :disabled, name: "#{form.object_name}[operation]", data: { "batch-operation-target" => "submit", "submitter-operation" => opt[:operation]}
- else
= form.button opt[:label], class: 'dropdown-items-link', disabled: :disabled, name: "#{form.object_name}[operation]", data: { "batch-operation-target" => "submit", "submitter-operation" => opt[:operation]} do
%span{ class: icons[opt[:operation].to_sym] } %span{ class: icons[opt[:operation].to_sym] }
.dropdown-description .dropdown-description
%h4= opt[:label] %h4= opt[:label]
.motivation.hidden.accept
= form.text_area :motivation, class: 'motivation-text-area'
.optional-justificatif{ id: "justificatif_motivation_suggest_accept", onclick: "DS.showImportJustificatif('accept');" }
.button Ajouter un justificatif (optionnel)
.hidden{ id: "justificatif_motivation_import_accept" }
= form.file_field :justificatif_motivation, direct_upload: true
.text-right
%span{ onclick: 'DS.motivationCancel();', class: 'fr-btn fr-btn--secondary' } Annuler
= form.button "Valider la décision", class: ['fr-btn'], disabled: :disabled, name: "#{form.object_name}[operation]", data: { "batch-operation-target" => "submit", "submitter-operation" => opt[:operation]}
- else
= form.button opt[:label], class: 'dropdown-items-link', disabled: :disabled, name: "#{form.object_name}[operation]", data: { "batch-operation-target" => "submit", "submitter-operation" => opt[:operation]} do
%span{ class: icons[opt[:operation].to_sym] }
.dropdown-description
%h4= opt[:label]

View file

@ -78,16 +78,14 @@ class BatchOperation < ApplicationRecord
end end
def track_processed_dossier(success, dossier) def track_processed_dossier(success, dossier)
transaction do dossiers.delete(dossier)
dossiers.delete(dossier) touch(:run_at) if called_for_first_time?
touch(:run_at) if called_for_first_time? touch(:finished_at) if called_for_last_time?(dossier)
touch(:finished_at) if called_for_last_time?(dossier)
if success if success
dossier_operation(dossier).done! dossier_operation(dossier).done!
else else
dossier_operation(dossier).fail! dossier_operation(dossier).fail!
end
end end
end end