display link to delete PJ in instruction button

This commit is contained in:
Lisa Durand 2023-03-27 16:07:24 +02:00
parent 3137f508ed
commit dc46430c40
3 changed files with 22 additions and 2 deletions

View file

@ -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
};

View file

@ -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));

View file

@ -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