add a bit of logic to display batch buttons : if more than 3 we group them in a dropdown

This commit is contained in:
Lisa Durand 2023-01-10 10:19:52 +01:00
parent eeb9fdcb46
commit d856969790
3 changed files with 52 additions and 41 deletions

View file

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

View file

@ -1,41 +1,24 @@
.batch-operation.fr-ml-auto .batch-operation.fr-ml-auto.flex
- if available_operations[:options].count == 1 - if available_operations[:options].count.between?(1,3)
- opt = available_operations[:options].dig(0) = form_for(BatchOperation.new, url: instructeur_batch_operations_path(procedure_id: procedure.id), method: :post, html: { class: 'form', id: "#{dom_id(BatchOperation.new)}" }) do |form|
= form_for(BatchOperation.new, url: instructeur_batch_operations_path(procedure_id: procedure.id), method: :post, html: { class: 'fr-ml-auto', id: "#{dom_id(BatchOperation.new)}" }) do |form| - available_operations[:options].each do |opt|
= form.button opt[:label], class: ['fr-btn fr-btn--icon-left', icons[opt[:operation].to_sym]], disabled: true, name: "#{form.object_name}[operation]", value: opt[:operation] = render partial: "instructeurs/dossiers/batch_operation_inline_buttons", locals: { opt: opt, icons: icons, form: form }
- else - else
.dropdown{ data: { controller: 'menu-button', popover: 'true' } } = form_for(BatchOperation.new, url: instructeur_batch_operations_path(procedure_id: procedure.id), method: :post, html: { class: 'form flex', id: "#{dom_id(BatchOperation.new)}" }) do |form|
-# Dropdown button title - available_operations[:options][0,2].each do |opt|
%button.fr-btn.dropdown-button{ disabled: true, data: { menu_button_target: 'button'} } = render partial: "instructeurs/dossiers/batch_operation_inline_buttons", locals: { opt: opt, icons: icons, form: form }
Actions multiples
#state-menu.dropdown-content.fade-in-down{ data: { menu_button_target: 'menu' } } .dropdown{ data: { controller: 'menu-button', popover: 'true' } }
= form_for(BatchOperation.new, url: instructeur_batch_operations_path(procedure_id: procedure.id), method: :post, html: { class: 'form', id: "#{dom_id(BatchOperation.new)}" }) do |form| -# Dropdown button title
%button.fr-btn.fr-btn--sm.fr-ml-1w.dropdown-button{ disabled: true, data: { menu_button_target: 'button'} }
Autres actions multiples
#state-menu.dropdown-content.fade-in-down{ data: { menu_button_target: 'menu' } }
%ul.dropdown-items %ul.dropdown-items
- available_operations[:options].each do |opt| - available_operations[:options][2, available_operations[:options].count].each do |opt|
%li{ 'data-turbo': 'true' } %li{ 'data-turbo': 'true' }
- if opt[:operation] == 'accepter' = form.button opt[:label], class: 'dropdown-items-link ', disabled: true, name: "#{form.object_name}[operation]", value: opt[:operation] do
.wrapper %span{ class: icons[opt[:operation].to_sym] }
.dropdown-description
%a.dropdown-items-link{ href: '#', onclick: "DS.showMotivation(event, 'accept');" } %h4= opt[:label]
%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: true, name: "#{form.object_name}[operation]", value: opt[:operation]
- else
= form.button opt[:label], class: 'dropdown-items-link', disabled: true, name: "#{form.object_name}[operation]", value: opt[:operation] do
%span{ class: icons[opt[:operation].to_sym] }
.dropdown-description
%h4= opt[:label]

View file

@ -0,0 +1,28 @@
- if opt[:operation] == 'accepter'
.dropdown{ data: { controller: 'menu-button', popover: 'true' } }
-# 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]
#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] }
.dropdown-description
%h4= opt[:label]
.motivation.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
= form.button "Valider la décision", class: ['fr-btn fr-mt-2w'], disabled: true, name: "#{form.object_name}[operation]", value: opt[:operation]
- 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]