Skip to content

Commit 786f247

Browse files
authored
Merge pull request #2236 from bcgov/feature/ALCS-2562-option-to-send-email-on-release-decision
Feature/alcs 2562 option to send email on release decision
2 parents d731682 + c3337c3 commit 786f247

File tree

14 files changed

+258
-88
lines changed

14 files changed

+258
-88
lines changed

alcs-frontend/src/app/features/application/decision/decision-v2/decision-input/decision-input-v2.component.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,11 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
388388
this.form.controls['criterionModification'].updateValueAndValidity();
389389
}
390390

391-
async onSubmit(isStayOnPage: boolean = false, isDraft: boolean = true, ccEmails: string[] = []) {
391+
async onSubmit(isStayOnPage: boolean = false, isDraft: boolean = true, ccEmails: string[] = [], sendEmail: boolean = true) {
392392
this.isLoading = true;
393393

394394
try {
395-
await this.saveDecision(isDraft, ccEmails);
395+
await this.saveDecision(isDraft, ccEmails, sendEmail);
396396
} finally {
397397
if (!isStayOnPage) {
398398
this.onCancel();
@@ -404,9 +404,8 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
404404
}
405405
}
406406

407-
async saveDecision(isDraft: boolean = true, ccEmails: string[] = []) {
408-
const data = this.mapDecisionDataForSave(isDraft, ccEmails);
409-
407+
async saveDecision(isDraft: boolean = true, ccEmails: string[] = [], sendEmail: boolean = true) {
408+
const data = this.mapDecisionDataForSave(isDraft, ccEmails, sendEmail);
410409
if (this.uuid) {
411410
await this.decisionService.update(this.uuid, data);
412411
} else {
@@ -418,7 +417,7 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
418417
}
419418
}
420419

421-
private mapDecisionDataForSave(isDraft: boolean, ccEmails: string[]) {
420+
private mapDecisionDataForSave(isDraft: boolean, ccEmails: string[], sendEmail: boolean = true) {
422421
const {
423422
date,
424423
outcome,
@@ -464,6 +463,7 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
464463
decisionComponents: this.components,
465464
conditions: this.conditionUpdates,
466465
ccEmails,
466+
sendEmail,
467467
};
468468
if (ceoCriterion && ceoCriterion === CeoCriterion.MODIFICATION) {
469469
data.isTimeExtension = criterionModification?.includes('isTimeExtension');
@@ -627,9 +627,9 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
627627
},
628628
})
629629
.afterClosed()
630-
.subscribe(async (result: { confirmed: boolean; ccEmails: string[] }) => {
630+
.subscribe(async (result: { confirmed: boolean; ccEmails: string[], sendEmail: boolean }) => {
631631
if (result.confirmed) {
632-
await this.onSubmit(false, false, result.ccEmails);
632+
await this.onSubmit(false, false, result.ccEmails, result.sendEmail);
633633
await this.applicationService.loadApplication(this.fileNumber);
634634
}
635635
});

alcs-frontend/src/app/features/application/decision/decision-v2/release-dialog/release-dialog.component.html

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,57 @@
22
<h2 class="card-title">Confirm Release Decision</h2>
33
</div>
44
<mat-dialog-content class="content">
5+
<div *ngIf="!wasReleased" class="row">
6+
<div class="toggle-label" id="sendEmailLabel">Send Email (with decision document)</div>
7+
<div class="toggle">
8+
<mat-slide-toggle
9+
[(ngModel)]="sendEmail"
10+
aria-labelledby="sendEmailLabel"
11+
></mat-slide-toggle
12+
>
13+
</div>
14+
</div>
15+
<div *ngIf="!sendEmail" class="warning-section">
16+
<div class="warning">
17+
<mat-icon>info</mat-icon> <b>Warning: </b>&nbsp; Email will not be sent
18+
</div>
19+
</div>
20+
<div *ngIf="sendEmail">
21+
<div>
22+
<span *ngIf="!wasReleased">Email will be sent to Primary Contact and Local/First Nation Government</span>
23+
<span *ngIf="wasReleased">No auto-emails will be sent</span>
24+
</div>
25+
<div *ngIf="!wasReleased" style="margin-top: 24px; margin-bottom: 24px;">
26+
<div style="margin-bottom: 4px">
27+
<mat-label>CC additional recipients on decision release email (optional):</mat-label>
28+
</div>
29+
<mat-form-field style="width: 100%" appearance="outline">
30+
<mat-chip-grid #chipGrid aria-label="Enter emails">
31+
<mat-chip-row
32+
*ngFor="let email of emails"
33+
(removed)="onRemoveEmail(email)"
34+
[editable]="true"
35+
(edited)="editEmail(email, $event)"
36+
[aria-description]="'press enter to edit ' + email"
37+
>
38+
{{ email }}
39+
<button matChipRemove [attr.aria-label]="'remove ' + email">
40+
<mat-icon>cancel</mat-icon>
41+
</button>
42+
</mat-chip-row>
43+
</mat-chip-grid>
44+
<input
45+
placeholder="Type and hit ‘space’ to add emails"
46+
[matChipInputFor]="chipGrid"
47+
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
48+
[matChipInputAddOnBlur]="true"
49+
(matChipInputTokenEnd)="addEmail($event)"
50+
[formControl]="email"
51+
/>
52+
</mat-form-field>
53+
<mat-error *ngIf="email.invalid"><mat-icon>warning</mat-icon>&nbsp;Please type a valid email address</mat-error>
54+
</div>
55+
</div>
556
<p>Upon releasing the decision:</p>
657
<div class="release-data">
758
<div><strong>Visibility:</strong> Applicant, Local/First Nation Government, and Public</div>
@@ -16,41 +67,6 @@ <h2 class="card-title">Confirm Release Decision</h2>
1667
[type]="cancelledStatus"
1768
></app-application-submission-status-type-pill>
1869
</div>
19-
<div>
20-
<strong>Email (with decision document) sent to: </strong>
21-
<span *ngIf="!wasReleased">Primary Contact and Local/First Nation Government</span>
22-
<span *ngIf="wasReleased">No auto-emails will be sent</span>
23-
</div>
24-
</div>
25-
<div *ngIf="!wasReleased" style="margin-top: 24px">
26-
<div style="margin-bottom: 4px">
27-
<mat-label>CC additional recipients on decision release email (optional):</mat-label>
28-
</div>
29-
<mat-form-field style="width: 100%" appearance="outline">
30-
<mat-chip-grid #chipGrid aria-label="Enter emails">
31-
<mat-chip-row
32-
*ngFor="let email of emails"
33-
(removed)="onRemoveEmail(email)"
34-
[editable]="true"
35-
(edited)="editEmail(email, $event)"
36-
[aria-description]="'press enter to edit ' + email"
37-
>
38-
{{ email }}
39-
<button matChipRemove [attr.aria-label]="'remove ' + email">
40-
<mat-icon>cancel</mat-icon>
41-
</button>
42-
</mat-chip-row>
43-
</mat-chip-grid>
44-
<input
45-
placeholder="Type and hit ‘space’ to add emails"
46-
[matChipInputFor]="chipGrid"
47-
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
48-
[matChipInputAddOnBlur]="true"
49-
(matChipInputTokenEnd)="addEmail($event)"
50-
[formControl]="email"
51-
/>
52-
</mat-form-field>
53-
<mat-error *ngIf="email.invalid"><mat-icon>warning</mat-icon>&nbsp;Please type a valid email address</mat-error>
5470
</div>
5571
</mat-dialog-content>
5672

alcs-frontend/src/app/features/application/decision/decision-v2/release-dialog/release-dialog.component.scss

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,66 @@
2020
.mat-mdc-form-field-infix {
2121
display: flex;
2222
}
23+
.toggle {
24+
mat-label {
25+
margin-right: 8px;
26+
}
27+
28+
& .mdc-form-field {
29+
display: flex;
30+
}
31+
32+
& .mdc-label {
33+
font-size: 16px;
34+
padding-left: 12px;
35+
}
36+
37+
& .mat-mdc-slide-toggle .mdc-form-field {
38+
color: colors.$grey;
39+
}
40+
41+
& .mat-mdc-slide-toggle-checked .mdc-form-field {
42+
color: colors.$black;
43+
44+
.mdc-label {
45+
font-weight: 700 !important;
46+
}
47+
}
48+
}
49+
}
50+
51+
.toggle-label {
52+
font-weight: 700;
53+
}
54+
55+
.toggle {
56+
display: flex;
57+
gap: 4px;
58+
color: colors.$black;
59+
font-weight: 700;
60+
margin-left: 14px;
61+
margin-top: 6px;
62+
}
63+
64+
.row {
65+
display: flex;
66+
margin: 24px 0;
67+
align-items: flex-start;
68+
}
69+
70+
.warning {
71+
padding: 16px;
72+
font-size: 14px;
73+
background-color: rgba(colors.$field-warning-bg-color, 0.5);
74+
border-radius: 8px;
75+
display: flex;
76+
align-items: center;
77+
color: colors.$dark-contrast-text;
78+
margin-top: 18px;
79+
margin-bottom: 18px;
80+
81+
mat-icon {
82+
color: colors.$dark-contrast-text;
83+
margin-right: 16px;
84+
}
2385
}

alcs-frontend/src/app/features/application/decision/decision-v2/release-dialog/release-dialog.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class ReleaseDialogComponent implements OnInit, OnDestroy {
2323
firstDecision = false;
2424
releasedStatus: ApplicationSubmissionStatusPill | undefined;
2525
cancelledStatus: ApplicationSubmissionStatusPill | undefined;
26+
sendEmail = true;
2627

2728
readonly separatorKeysCodes = [ENTER, COMMA, SPACE] as const;
2829
emails: string[] = [];
@@ -58,6 +59,7 @@ export class ReleaseDialogComponent implements OnInit, OnDestroy {
5859
this.matDialogRef.close({
5960
confirmed: true,
6061
ccEmails: this.emails,
62+
sendEmail: this.sendEmail,
6163
});
6264
}
6365

alcs-frontend/src/app/features/notice-of-intent/decision/decision-v2/decision-input/decision-input-v2.component.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,11 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
275275
}
276276
}
277277

278-
async onSubmit(isStayOnPage: boolean = false, isDraft: boolean = true, ccEmails: string[] = []) {
278+
async onSubmit(isStayOnPage: boolean = false, isDraft: boolean = true, ccEmails: string[] = [], sendEmail: boolean = true) {
279279
this.isLoading = true;
280280

281281
try {
282-
await this.saveDecision(isDraft, ccEmails);
282+
await this.saveDecision(isDraft, ccEmails, sendEmail);
283283
} finally {
284284
if (!isStayOnPage) {
285285
this.onCancel();
@@ -291,8 +291,8 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
291291
}
292292
}
293293

294-
async saveDecision(isDraft: boolean = true, ccEmails: string[]) {
295-
const data = this.mapDecisionDataForSave(isDraft, ccEmails);
294+
async saveDecision(isDraft: boolean = true, ccEmails: string[], sendEmail: boolean = true) {
295+
const data = this.mapDecisionDataForSave(isDraft, ccEmails, sendEmail);
296296

297297
if (this.uuid) {
298298
await this.decisionService.update(this.uuid, data);
@@ -305,7 +305,7 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
305305
}
306306
}
307307

308-
private mapDecisionDataForSave(isDraft: boolean, ccEmails: string[]) {
308+
private mapDecisionDataForSave(isDraft: boolean, ccEmails: string[], sendEmail: boolean = true) {
309309
const {
310310
date,
311311
outcome,
@@ -339,6 +339,7 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
339339
conditions: this.conditionUpdates,
340340
decisionMaker: decisionMaker ?? undefined,
341341
ccEmails,
342+
sendEmail,
342343
};
343344

344345
return data;
@@ -466,9 +467,9 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
466467
},
467468
})
468469
.afterClosed()
469-
.subscribe(async (res: { confirmed: boolean; ccEmails: string[] }) => {
470+
.subscribe(async (res: { confirmed: boolean; ccEmails: string[], sendEmail: boolean }) => {
470471
if (res.confirmed) {
471-
await this.onSubmit(false, false, res.ccEmails);
472+
await this.onSubmit(false, false, res.ccEmails, res.sendEmail);
472473
await this.noticeOfIntentDetailService.load(this.fileNumber);
473474
}
474475
});

alcs-frontend/src/app/features/notice-of-intent/decision/decision-v2/release-dialog/release-dialog.component.html

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,57 @@
22
<h2 class="card-title">Confirm Release Decision</h2>
33
</div>
44
<mat-dialog-content class="content">
5+
<div *ngIf="!wasReleased" class="row">
6+
<div class="toggle-label" id="sendEmailLabel">Send Email (with decision document)</div>
7+
<div class="toggle">
8+
<mat-slide-toggle
9+
[(ngModel)]="sendEmail"
10+
aria-labelledby="sendEmailLabel"
11+
></mat-slide-toggle
12+
>
13+
</div>
14+
</div>
15+
<div *ngIf="!sendEmail" class="warning-section">
16+
<div class="warning">
17+
<mat-icon>info</mat-icon> <b>Warning: </b>&nbsp; Email will not be sent
18+
</div>
19+
</div>
20+
<div *ngIf="sendEmail">
21+
<div>
22+
<span *ngIf="!wasReleased">Email will be sent to Primary Contact and Local/First Nation Government</span>
23+
<span *ngIf="wasReleased">No auto-emails will be sent</span>
24+
</div>
25+
<div *ngIf="!wasReleased" style="margin-top: 24px; margin-bottom: 24px;">
26+
<div style="margin-bottom: 4px">
27+
<mat-label>CC additional recipients on decision release email (optional):</mat-label>
28+
</div>
29+
<mat-form-field style="width: 100%" appearance="outline">
30+
<mat-chip-grid #chipGrid aria-label="Enter emails">
31+
<mat-chip-row
32+
*ngFor="let email of emails"
33+
(removed)="onRemoveEmail(email)"
34+
[editable]="true"
35+
(edited)="editEmail(email, $event)"
36+
[aria-description]="'press enter to edit ' + email"
37+
>
38+
{{ email }}
39+
<button matChipRemove [attr.aria-label]="'remove ' + email">
40+
<mat-icon>cancel</mat-icon>
41+
</button>
42+
</mat-chip-row>
43+
</mat-chip-grid>
44+
<input
45+
placeholder="Type and hit ‘space’ to add emails"
46+
[matChipInputFor]="chipGrid"
47+
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
48+
[matChipInputAddOnBlur]="true"
49+
(matChipInputTokenEnd)="addEmail($event)"
50+
[formControl]="email"
51+
/>
52+
</mat-form-field>
53+
<mat-error *ngIf="email.invalid"><mat-icon>warning</mat-icon>&nbsp;Please type a valid email address</mat-error>
54+
</div>
55+
</div>
556
<p>Upon releasing the decision:</p>
657
<div class="release-data">
758
<div><strong>Visibility:</strong> Applicant, Local/First Nation Government, and Public</div>
@@ -16,42 +67,6 @@ <h2 class="card-title">Confirm Release Decision</h2>
1667
[type]="cancelledStatus"
1768
></app-application-submission-status-type-pill>
1869
</div>
19-
<div>
20-
<strong>Email (with decision document) sent to: </strong>
21-
<span *ngIf="!wasReleased">Primary Contact and Local/First Nation Government</span>
22-
<span *ngIf="wasReleased">No auto-emails will be sent</span>
23-
</div>
24-
</div>
25-
<div *ngIf="!wasReleased" style="margin-top: 24px">
26-
<div style="margin-bottom: 4px">
27-
<mat-label>CC additional recipients on decision release email (optional):</mat-label>
28-
</div>
29-
<mat-form-field style="width: 100%" appearance="outline">
30-
<mat-chip-grid #chipGrid aria-label="Enter emails">
31-
<mat-chip-row
32-
*ngFor="let email of emails"
33-
class="chip"
34-
(removed)="onRemoveEmail(email)"
35-
[editable]="true"
36-
(edited)="editEmail(email, $event)"
37-
[aria-description]="'press enter to edit ' + email"
38-
>
39-
{{ email }}
40-
<button matChipRemove [attr.aria-label]="'remove ' + email">
41-
<mat-icon>cancel</mat-icon>
42-
</button>
43-
</mat-chip-row>
44-
</mat-chip-grid>
45-
<input
46-
placeholder="Type and hit ‘space’ to add emails"
47-
[matChipInputFor]="chipGrid"
48-
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
49-
[matChipInputAddOnBlur]="true"
50-
(matChipInputTokenEnd)="addEmail($event)"
51-
[formControl]="email"
52-
/>
53-
</mat-form-field>
54-
<mat-error *ngIf="email.invalid"><mat-icon>warning</mat-icon>&nbsp;Please type a valid email address</mat-error>
5570
</div>
5671
</mat-dialog-content>
5772

0 commit comments

Comments
 (0)