From 3137f508ed719cd29118193a6eda51a6387e665f Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Mon, 27 Mar 2023 14:44:45 +0200 Subject: [PATCH 1/6] make cancel button to reset form for instruction button --- .../dossiers/_instruction_button_motivation.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml b/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml index d241281a5..f7e0dcbcf 100644 --- a/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml +++ b/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml @@ -32,5 +32,5 @@ .hidden{ id: "justificatif_motivation_import_#{popup_class}" } = file_field :dossier, :justificatif_motivation, direct_upload: true .text-right.fr-mt-2w - %span.fr-btn.fr-btn--secondary{ onclick: 'DS.motivationCancel();' } Annuler + = button_tag "Annuler", type: :reset, class: 'fr-btn fr-btn--secondary', onclick: 'DS.motivationCancel();' = button_tag 'Valider la décision', name: :process_action, value: process_action, class: 'fr-btn fr-mr-0', title: title From dc46430c40898768aa11eb76907ac6a1d665605d Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Mon, 27 Mar 2023 16:07:24 +0200 Subject: [PATCH 2/6] display link to delete PJ in instruction button --- app/javascript/entrypoints/application.js | 6 +++++- app/javascript/new_design/instruction-button.js | 13 +++++++++++++ .../_instruction_button_motivation.html.haml | 5 ++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/javascript/entrypoints/application.js b/app/javascript/entrypoints/application.js index 804d3d215..292932ee6 100644 --- a/app/javascript/entrypoints/application.js +++ b/app/javascript/entrypoints/application.js @@ -18,7 +18,9 @@ import { toggleCondidentielExplanation } from '../new_design/avis'; import { showMotivation, motivationCancel, - showImportJustificatif + showImportJustificatif, + showDeleteJustificatif, + deleteJustificatif } from '../new_design/instruction-button'; import { showFusion, showNewAccount } from '../new_design/fc-fusion'; @@ -31,6 +33,8 @@ const DS = { showMotivation, motivationCancel, showImportJustificatif, + showDeleteJustificatif, + deleteJustificatif, showFusion, showNewAccount }; diff --git a/app/javascript/new_design/instruction-button.js b/app/javascript/new_design/instruction-button.js index f2af6c57e..da7dac3d0 100644 --- a/app/javascript/new_design/instruction-button.js +++ b/app/javascript/new_design/instruction-button.js @@ -19,6 +19,19 @@ export function motivationCancel() { show(document.querySelector('.dropdown-items')); } +export function showDeleteJustificatif(name) { + const justificatif = document.querySelector('#dossier_justificatif_motivation_' + name) + if (justificatif.value != '') { + show(document.querySelector('#delete_motivation_import_' + name)); + } +} + +export function deleteJustificatif(name) { + const justificatif = document.querySelector('#dossier_justificatif_motivation_' + name) + justificatif.value = '' + hide(document.querySelector('#delete_motivation_import_' + name)); +} + export function showImportJustificatif(name) { show(document.querySelector('#justificatif_motivation_import_' + name)); hide(document.querySelector('#justificatif_motivation_suggest_' + name)); diff --git a/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml b/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml index f7e0dcbcf..d112b17e9 100644 --- a/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml +++ b/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml @@ -30,7 +30,10 @@ .optional-justificatif{ id: "justificatif_motivation_suggest_#{popup_class}", onclick: "DS.showImportJustificatif('#{popup_class}');" } .fr-btn.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-attachment-line.fr-ml-0 Ajouter un justificatif (optionnel) .hidden{ id: "justificatif_motivation_import_#{popup_class}" } - = file_field :dossier, :justificatif_motivation, direct_upload: true + = file_field :dossier, :justificatif_motivation, direct_upload: true, id: "dossier_justificatif_motivation_#{popup_class}",onchange: "DS.showDeleteJustificatif('#{popup_class}');" + + .hidden{ id: "delete_motivation_import_#{popup_class}" } + .fr-btn.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-delete-line.fr-ml-0{ onclick: "DS.deleteJustificatif('#{popup_class}');"} Supprimer le justificatif .text-right.fr-mt-2w = button_tag "Annuler", type: :reset, class: 'fr-btn fr-btn--secondary', onclick: 'DS.motivationCancel();' = button_tag 'Valider la décision', name: :process_action, value: process_action, class: 'fr-btn fr-mr-0', title: title From 92bc95014a276ea1e747423bff315b00aaf3f3f9 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Mon, 27 Mar 2023 17:21:35 +0200 Subject: [PATCH 3/6] add cancel button and delete pj button in batch context --- ...batch_operation_inline_buttons_component.html.haml | 11 +++++++---- app/javascript/entrypoints/application.js | 2 ++ app/javascript/new_design/instruction-button.js | 7 +++++++ .../dossiers/_instruction_button_motivation.html.haml | 7 +++---- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/components/dossiers/batch_operation_inline_buttons_component/batch_operation_inline_buttons_component.html.haml b/app/components/dossiers/batch_operation_inline_buttons_component/batch_operation_inline_buttons_component.html.haml index be2e84e15..4e652ab26 100644 --- a/app/components/dossiers/batch_operation_inline_buttons_component/batch_operation_inline_buttons_component.html.haml +++ b/app/components/dossiers/batch_operation_inline_buttons_component/batch_operation_inline_buttons_component.html.haml @@ -1,5 +1,5 @@ - if opt[:operation] == 'accepter' - .dropdown{ data: { controller: 'menu-button', popover: 'true', operation: opt[:operation] } } + .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] @@ -17,12 +17,15 @@ .motivation.accept = form.text_area :motivation, class: 'fr-input' #justificatif_motivation_suggest_accept.optional-justificatif - %button.button{ type: 'button', onclick: "DS.showImportJustificatif('accept');" } Ajouter un justificatif (optionnel) + %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 + = form.file_field :justificatif_motivation, direct_upload: true, id: "dossier_justificatif_motivation_accept", onchange: "DS.showDeleteJustificatif('accept');" + .hidden{ 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.js_delete_motivation{ type: 'button', onclick: "DS.deleteJustificatif('accept');"} Supprimer le justificatif - = form.button "Valider la décision", class: ['fr-btn fr-mt-2w'], disabled: true, name: "#{form.object_name}[operation]", value: opt[:operation] + = 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] - 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] } diff --git a/app/javascript/entrypoints/application.js b/app/javascript/entrypoints/application.js index 292932ee6..9c85ec7ff 100644 --- a/app/javascript/entrypoints/application.js +++ b/app/javascript/entrypoints/application.js @@ -20,6 +20,7 @@ import { motivationCancel, showImportJustificatif, showDeleteJustificatif, + motivationCancelBatch, deleteJustificatif } from '../new_design/instruction-button'; import { showFusion, showNewAccount } from '../new_design/fc-fusion'; @@ -34,6 +35,7 @@ const DS = { motivationCancel, showImportJustificatif, showDeleteJustificatif, + motivationCancelBatch, deleteJustificatif, showFusion, showNewAccount diff --git a/app/javascript/new_design/instruction-button.js b/app/javascript/new_design/instruction-button.js index da7dac3d0..3cf63cf9b 100644 --- a/app/javascript/new_design/instruction-button.js +++ b/app/javascript/new_design/instruction-button.js @@ -17,6 +17,13 @@ export function motivationCancel() { .forEach((el) => hide(el.parentElement)); show(document.querySelector('.dropdown-items')); + + document.querySelectorAll('.js_delete_motivation').forEach(hide); +} + +export function motivationCancelBatch() { + document.querySelector('#dropdown_batch' ).classList.remove("open");; + hide(document.querySelector('.js_delete_motivation')); } export function showDeleteJustificatif(name) { diff --git a/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml b/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml index d112b17e9..99ff67b07 100644 --- a/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml +++ b/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml @@ -28,12 +28,11 @@ - else = text_area :dossier, :motivation, class: 'fr-input', placeholder: placeholder, required: true .optional-justificatif{ id: "justificatif_motivation_suggest_#{popup_class}", onclick: "DS.showImportJustificatif('#{popup_class}');" } - .fr-btn.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-attachment-line.fr-ml-0 Ajouter un justificatif (optionnel) + %button.fr-btn.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) .hidden{ id: "justificatif_motivation_import_#{popup_class}" } = file_field :dossier, :justificatif_motivation, direct_upload: true, id: "dossier_justificatif_motivation_#{popup_class}",onchange: "DS.showDeleteJustificatif('#{popup_class}');" - .hidden{ id: "delete_motivation_import_#{popup_class}" } - .fr-btn.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-delete-line.fr-ml-0{ onclick: "DS.deleteJustificatif('#{popup_class}');"} Supprimer le justificatif - .text-right.fr-mt-2w + %button.fr-btn.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-delete-line.fr-ml-0.fr-mt-1w.js_delete_motivation{ type: 'button', onclick: "DS.deleteJustificatif('#{popup_class}');"} Supprimer le justificatif + .fr-mt-2w = button_tag "Annuler", type: :reset, class: 'fr-btn fr-btn--secondary', onclick: 'DS.motivationCancel();' = button_tag 'Valider la décision', name: :process_action, value: process_action, class: 'fr-btn fr-mr-0', title: title From df701f2a8fb0235fdeb354012371c357e4eea0c5 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Mon, 27 Mar 2023 17:26:53 +0200 Subject: [PATCH 4/6] fix linter --- ...atch_operation_inline_buttons_component.html.haml | 2 +- app/javascript/new_design/instruction-button.js | 12 ++++++++---- .../_instruction_button_motivation.html.haml | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/components/dossiers/batch_operation_inline_buttons_component/batch_operation_inline_buttons_component.html.haml b/app/components/dossiers/batch_operation_inline_buttons_component/batch_operation_inline_buttons_component.html.haml index 4e652ab26..044c23d69 100644 --- a/app/components/dossiers/batch_operation_inline_buttons_component/batch_operation_inline_buttons_component.html.haml +++ b/app/components/dossiers/batch_operation_inline_buttons_component/batch_operation_inline_buttons_component.html.haml @@ -22,7 +22,7 @@ = form.file_field :justificatif_motivation, direct_upload: true, id: "dossier_justificatif_motivation_accept", onchange: "DS.showDeleteJustificatif('accept');" .hidden{ 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.js_delete_motivation{ type: 'button', onclick: "DS.deleteJustificatif('accept');"} Supprimer le justificatif + %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.js_delete_motivation{ 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] diff --git a/app/javascript/new_design/instruction-button.js b/app/javascript/new_design/instruction-button.js index 3cf63cf9b..70ee806b7 100644 --- a/app/javascript/new_design/instruction-button.js +++ b/app/javascript/new_design/instruction-button.js @@ -22,20 +22,24 @@ export function motivationCancel() { } export function motivationCancelBatch() { - document.querySelector('#dropdown_batch' ).classList.remove("open");; + document.querySelector('#dropdown_batch').classList.remove('open'); hide(document.querySelector('.js_delete_motivation')); } export function showDeleteJustificatif(name) { - const justificatif = document.querySelector('#dossier_justificatif_motivation_' + name) + const justificatif = document.querySelector( + '#dossier_justificatif_motivation_' + name + ); if (justificatif.value != '') { show(document.querySelector('#delete_motivation_import_' + name)); } } export function deleteJustificatif(name) { - const justificatif = document.querySelector('#dossier_justificatif_motivation_' + name) - justificatif.value = '' + const justificatif = document.querySelector( + '#dossier_justificatif_motivation_' + name + ); + justificatif.value = ''; hide(document.querySelector('#delete_motivation_import_' + name)); } diff --git a/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml b/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml index 99ff67b07..9126974e8 100644 --- a/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml +++ b/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml @@ -32,7 +32,7 @@ .hidden{ id: "justificatif_motivation_import_#{popup_class}" } = file_field :dossier, :justificatif_motivation, direct_upload: true, id: "dossier_justificatif_motivation_#{popup_class}",onchange: "DS.showDeleteJustificatif('#{popup_class}');" .hidden{ id: "delete_motivation_import_#{popup_class}" } - %button.fr-btn.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-delete-line.fr-ml-0.fr-mt-1w.js_delete_motivation{ type: 'button', onclick: "DS.deleteJustificatif('#{popup_class}');"} Supprimer le justificatif + %button.fr-btn.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-delete-line.fr-ml-0.fr-mt-1w.js_delete_motivation{ type: 'button', onclick: "DS.deleteJustificatif('#{popup_class}');" } Supprimer le justificatif .fr-mt-2w = button_tag "Annuler", type: :reset, class: 'fr-btn fr-btn--secondary', onclick: 'DS.motivationCancel();' = button_tag 'Valider la décision', name: :process_action, value: process_action, class: 'fr-btn fr-mr-0', title: title From 044d03b5247bd5f0e3afe5c01c1ac94a3b58945b Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Mon, 27 Mar 2023 17:45:06 +0200 Subject: [PATCH 5/6] fix button display --- .../batch_operation_inline_buttons_component.html.haml | 4 ++-- app/javascript/new_design/instruction-button.js | 2 ++ .../dossiers/_instruction_button_motivation.html.haml | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/components/dossiers/batch_operation_inline_buttons_component/batch_operation_inline_buttons_component.html.haml b/app/components/dossiers/batch_operation_inline_buttons_component/batch_operation_inline_buttons_component.html.haml index 044c23d69..b40976b61 100644 --- a/app/components/dossiers/batch_operation_inline_buttons_component/batch_operation_inline_buttons_component.html.haml +++ b/app/components/dossiers/batch_operation_inline_buttons_component/batch_operation_inline_buttons_component.html.haml @@ -21,8 +21,8 @@ #justificatif_motivation_import_accept.hidden = form.file_field :justificatif_motivation, direct_upload: true, id: "dossier_justificatif_motivation_accept", onchange: "DS.showDeleteJustificatif('accept');" - .hidden{ 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.js_delete_motivation{ type: 'button', onclick: "DS.deleteJustificatif('accept');" } Supprimer le justificatif + .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] diff --git a/app/javascript/new_design/instruction-button.js b/app/javascript/new_design/instruction-button.js index 70ee806b7..987bcd77b 100644 --- a/app/javascript/new_design/instruction-button.js +++ b/app/javascript/new_design/instruction-button.js @@ -30,8 +30,10 @@ export function showDeleteJustificatif(name) { const justificatif = document.querySelector( '#dossier_justificatif_motivation_' + name ); + if (justificatif.value != '') { show(document.querySelector('#delete_motivation_import_' + name)); + document.querySelector('#delete_motivation_import_' + name); } } diff --git a/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml b/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml index 9126974e8..4d089c6e4 100644 --- a/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml +++ b/app/views/instructeurs/dossiers/_instruction_button_motivation.html.haml @@ -31,8 +31,8 @@ %button.fr-btn.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) .hidden{ id: "justificatif_motivation_import_#{popup_class}" } = file_field :dossier, :justificatif_motivation, direct_upload: true, id: "dossier_justificatif_motivation_#{popup_class}",onchange: "DS.showDeleteJustificatif('#{popup_class}');" - .hidden{ id: "delete_motivation_import_#{popup_class}" } - %button.fr-btn.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-delete-line.fr-ml-0.fr-mt-1w.js_delete_motivation{ type: 'button', onclick: "DS.deleteJustificatif('#{popup_class}');" } Supprimer le justificatif + .hidden.js_delete_motivation{ id: "delete_motivation_import_#{popup_class}" } + %button.fr-btn.fr-btn--tertiary-no-outline.fr-btn--icon-left.fr-icon-delete-line.fr-ml-0.fr-mt-1w{ type: 'button', onclick: "DS.deleteJustificatif('#{popup_class}');" } Supprimer le justificatif .fr-mt-2w = button_tag "Annuler", type: :reset, class: 'fr-btn fr-btn--secondary', onclick: 'DS.motivationCancel();' = button_tag 'Valider la décision', name: :process_action, value: process_action, class: 'fr-btn fr-mr-0', title: title From 518d075dc902f4c97a9d725f309ef270bde8e88f Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Wed, 29 Mar 2023 10:26:03 +0200 Subject: [PATCH 6/6] small changes for better readability --- app/javascript/entrypoints/application.js | 4 ++-- app/javascript/new_design/instruction-button.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/javascript/entrypoints/application.js b/app/javascript/entrypoints/application.js index 9c85ec7ff..3801b6038 100644 --- a/app/javascript/entrypoints/application.js +++ b/app/javascript/entrypoints/application.js @@ -18,9 +18,9 @@ import { toggleCondidentielExplanation } from '../new_design/avis'; import { showMotivation, motivationCancel, + motivationCancelBatchDropdown, showImportJustificatif, showDeleteJustificatif, - motivationCancelBatch, deleteJustificatif } from '../new_design/instruction-button'; import { showFusion, showNewAccount } from '../new_design/fc-fusion'; @@ -33,9 +33,9 @@ const DS = { toggleCondidentielExplanation, showMotivation, motivationCancel, + motivationCancelBatchDropdown, showImportJustificatif, showDeleteJustificatif, - motivationCancelBatch, deleteJustificatif, showFusion, showNewAccount diff --git a/app/javascript/new_design/instruction-button.js b/app/javascript/new_design/instruction-button.js index 987bcd77b..21499c72c 100644 --- a/app/javascript/new_design/instruction-button.js +++ b/app/javascript/new_design/instruction-button.js @@ -21,7 +21,7 @@ export function motivationCancel() { document.querySelectorAll('.js_delete_motivation').forEach(hide); } -export function motivationCancelBatch() { +export function motivationCancelBatchDropdown() { document.querySelector('#dropdown_batch').classList.remove('open'); hide(document.querySelector('.js_delete_motivation')); }