demarches-normaliennes/app/javascript/new_design/instruction-button.js
2023-03-29 10:26:42 +02:00

51 lines
1.5 KiB
JavaScript

import { show, hide } from '@utils';
export function showMotivation(event, state) {
event.preventDefault();
motivationCancel();
const stateElement = document.querySelector(`.motivation.${state}`);
show(stateElement.parentElement);
show(stateElement);
hide(document.querySelector('.dropdown-items'));
}
export function motivationCancel() {
document.querySelectorAll('.motivation').forEach(hide);
document
.querySelectorAll('.motivation')
.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) {
const justificatif = document.querySelector(
'#dossier_justificatif_motivation_' + name
);
if (justificatif.value != '') {
show(document.querySelector('#delete_motivation_import_' + name));
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));
}