fix(instructeur): motivations from different states should not conflict
This commit is contained in:
parent
eeab49573a
commit
529461f3b6
5 changed files with 53 additions and 55 deletions
51
app/javascript/new_design/instruction-button.ts
Normal file
51
app/javascript/new_design/instruction-button.ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
import { isInputElement } from '@coldwired/utils';
|
||||
import { show, hide, disable, enable } from '@coldwired/actions';
|
||||
|
||||
export function showMotivation(event: Event, state: string) {
|
||||
event.preventDefault();
|
||||
motivationCancel();
|
||||
const stateElement = document.querySelector(`.motivation.${state}`);
|
||||
|
||||
if (stateElement) {
|
||||
show(stateElement.parentElement);
|
||||
show(stateElement);
|
||||
stateElement.querySelectorAll('input, textarea').forEach(enable);
|
||||
}
|
||||
}
|
||||
|
||||
export function motivationCancel() {
|
||||
document.querySelectorAll('.motivation').forEach((stateElement) => {
|
||||
hide(stateElement);
|
||||
hide(stateElement.parentElement);
|
||||
stateElement.querySelectorAll('input, textarea').forEach(disable);
|
||||
});
|
||||
|
||||
hide('.js_delete_motivation');
|
||||
}
|
||||
|
||||
export function showDeleteJustificatif(name: string) {
|
||||
const justificatif = document.querySelector(
|
||||
`#dossier_justificatif_motivation_${name}`
|
||||
);
|
||||
|
||||
if (isInputElement(justificatif)) {
|
||||
if (justificatif.value != '') {
|
||||
show(`#delete_motivation_import_${name}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function deleteJustificatif(name: string) {
|
||||
const justificatif = document.querySelector(
|
||||
`#dossier_justificatif_motivation_${name}`
|
||||
);
|
||||
if (isInputElement(justificatif)) {
|
||||
justificatif.value = '';
|
||||
hide(`#delete_motivation_import_${name}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function showImportJustificatif(name: string) {
|
||||
show(`#justificatif_motivation_import_${name}`);
|
||||
hide(`#justificatif_motivation_suggest_${name}`);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue