feat(procedure): send notifications after closing
This commit is contained in:
parent
c147d9b36c
commit
c95f0f1cad
13 changed files with 307 additions and 11 deletions
|
@ -0,0 +1,76 @@
|
|||
import { ApplicationController } from './application_controller';
|
||||
import { hide, show } from '@utils';
|
||||
|
||||
export class ClosingNotificationController extends ApplicationController {
|
||||
static targets = [
|
||||
'brouillonToggle',
|
||||
'emailContentBrouillon',
|
||||
'enCoursToggle',
|
||||
'emailContentEnCours',
|
||||
'submit'
|
||||
];
|
||||
|
||||
declare readonly brouillonToggleTarget: HTMLInputElement;
|
||||
declare readonly hasBrouillonToggleTarget: boolean;
|
||||
declare readonly enCoursToggleTarget: HTMLInputElement;
|
||||
declare readonly hasEnCoursToggleTarget: boolean;
|
||||
declare readonly emailContentBrouillonTarget: HTMLElement;
|
||||
declare readonly emailContentEnCoursTarget: HTMLElement;
|
||||
declare readonly submitTarget: HTMLButtonElement;
|
||||
|
||||
connect() {
|
||||
this.displayBrouillonInput();
|
||||
this.displayEnCoursInput();
|
||||
this.on('change', () => this.onChange());
|
||||
}
|
||||
|
||||
onChange() {
|
||||
this.displayBrouillonInput();
|
||||
this.displayEnCoursInput();
|
||||
}
|
||||
|
||||
displayBrouillonInput() {
|
||||
if (this.hasBrouillonToggleTarget) {
|
||||
const brouillonToggleElement = this
|
||||
.brouillonToggleTarget as HTMLInputElement;
|
||||
|
||||
const emailContentBrouillonElement = this
|
||||
.emailContentBrouillonTarget as HTMLElement;
|
||||
|
||||
if (emailContentBrouillonElement) {
|
||||
if (brouillonToggleElement.checked) {
|
||||
show(emailContentBrouillonElement);
|
||||
} else {
|
||||
hide(emailContentBrouillonElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
displayEnCoursInput() {
|
||||
if (this.hasEnCoursToggleTarget) {
|
||||
const enCoursToggleElement = this.enCoursToggleTarget as HTMLInputElement;
|
||||
|
||||
const emailContentEnCoursElement = this
|
||||
.emailContentEnCoursTarget as HTMLElement;
|
||||
|
||||
if (emailContentEnCoursElement) {
|
||||
if (enCoursToggleElement.checked) {
|
||||
show(this.emailContentEnCoursTarget);
|
||||
} else {
|
||||
hide(this.emailContentEnCoursTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enableSubmitOnClick() {
|
||||
if (
|
||||
this.element.querySelectorAll('input[type="checkbox"]:checked').length > 0
|
||||
) {
|
||||
this.submitTarget.disabled = false;
|
||||
} else {
|
||||
this.submitTarget.disabled = true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue