Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/alcs 2562 option to send email on release decision #2236

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,11 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
this.form.controls['criterionModification'].updateValueAndValidity();
}

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

try {
await this.saveDecision(isDraft, ccEmails);
await this.saveDecision(isDraft, ccEmails, sendEmail);
} finally {
if (!isStayOnPage) {
this.onCancel();
Expand All @@ -389,9 +389,8 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
}
}

async saveDecision(isDraft: boolean = true, ccEmails: string[] = []) {
const data = this.mapDecisionDataForSave(isDraft, ccEmails);

async saveDecision(isDraft: boolean = true, ccEmails: string[] = [], sendEmail: boolean = true) {
const data = this.mapDecisionDataForSave(isDraft, ccEmails, sendEmail);
if (this.uuid) {
await this.decisionService.update(this.uuid, data);
} else {
Expand All @@ -403,7 +402,7 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
}
}

private mapDecisionDataForSave(isDraft: boolean, ccEmails: string[]) {
private mapDecisionDataForSave(isDraft: boolean, ccEmails: string[], sendEmail: boolean = true) {
const {
date,
outcome,
Expand Down Expand Up @@ -449,6 +448,7 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
decisionComponents: this.components,
conditions: this.conditionUpdates,
ccEmails,
sendEmail,
};
if (ceoCriterion && ceoCriterion === CeoCriterion.MODIFICATION) {
data.isTimeExtension = criterionModification?.includes('isTimeExtension');
Expand Down Expand Up @@ -592,9 +592,9 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
},
})
.afterClosed()
.subscribe(async (result: { confirmed: boolean; ccEmails: string[] }) => {
.subscribe(async (result: { confirmed: boolean; ccEmails: string[], sendEmail: boolean }) => {
if (result.confirmed) {
await this.onSubmit(false, false, result.ccEmails);
await this.onSubmit(false, false, result.ccEmails, result.sendEmail);
await this.applicationService.loadApplication(this.fileNumber);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,57 @@
<h2 class="card-title">Confirm Release Decision</h2>
</div>
<mat-dialog-content class="content">
<div *ngIf="!wasReleased" class="row">
<div class="toggle-label" id="sendEmailLabel">Send Email (with decision document)</div>
<div class="toggle">
<mat-slide-toggle
[(ngModel)]="sendEmail"
aria-labelledby="sendEmailLabel"
></mat-slide-toggle
>
</div>
</div>
<div *ngIf="!sendEmail" class="warning-section">
<div class="warning">
<mat-icon>info</mat-icon> <b>Warning: </b>&nbsp; Email will not be sent
</div>
</div>
<div *ngIf="sendEmail">
<div>
<span *ngIf="!wasReleased">Email will be sent to Primary Contact and Local/First Nation Government</span>
<span *ngIf="wasReleased">No auto-emails will be sent</span>
</div>
<div *ngIf="!wasReleased" style="margin-top: 24px; margin-bottom: 24px;">
<div style="margin-bottom: 4px">
<mat-label>CC additional recipients on decision release email (optional):</mat-label>
</div>
<mat-form-field style="width: 100%" appearance="outline">
<mat-chip-grid #chipGrid aria-label="Enter emails">
<mat-chip-row
*ngFor="let email of emails"
(removed)="onRemoveEmail(email)"
[editable]="true"
(edited)="editEmail(email, $event)"
[aria-description]="'press enter to edit ' + email"
>
{{ email }}
<button matChipRemove [attr.aria-label]="'remove ' + email">
<mat-icon>cancel</mat-icon>
</button>
</mat-chip-row>
</mat-chip-grid>
<input
placeholder="Type and hit ‘space’ to add emails"
[matChipInputFor]="chipGrid"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
[matChipInputAddOnBlur]="true"
(matChipInputTokenEnd)="addEmail($event)"
[formControl]="email"
/>
</mat-form-field>
<mat-error *ngIf="email.invalid"><mat-icon>warning</mat-icon>&nbsp;Please type a valid email address</mat-error>
</div>
</div>
<p>Upon releasing the decision:</p>
<div class="release-data">
<div><strong>Visibility:</strong> Applicant, Local/First Nation Government, and Public</div>
Expand All @@ -16,41 +67,6 @@ <h2 class="card-title">Confirm Release Decision</h2>
[type]="cancelledStatus"
></app-application-submission-status-type-pill>
</div>
<div>
<strong>Email (with decision document) sent to: </strong>
<span *ngIf="!wasReleased">Primary Contact and Local/First Nation Government</span>
<span *ngIf="wasReleased">No auto-emails will be sent</span>
</div>
</div>
<div *ngIf="!wasReleased" style="margin-top: 24px">
<div style="margin-bottom: 4px">
<mat-label>CC additional recipients on decision release email (optional):</mat-label>
</div>
<mat-form-field style="width: 100%" appearance="outline">
<mat-chip-grid #chipGrid aria-label="Enter emails">
<mat-chip-row
*ngFor="let email of emails"
(removed)="onRemoveEmail(email)"
[editable]="true"
(edited)="editEmail(email, $event)"
[aria-description]="'press enter to edit ' + email"
>
{{ email }}
<button matChipRemove [attr.aria-label]="'remove ' + email">
<mat-icon>cancel</mat-icon>
</button>
</mat-chip-row>
</mat-chip-grid>
<input
placeholder="Type and hit ‘space’ to add emails"
[matChipInputFor]="chipGrid"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
[matChipInputAddOnBlur]="true"
(matChipInputTokenEnd)="addEmail($event)"
[formControl]="email"
/>
</mat-form-field>
<mat-error *ngIf="email.invalid"><mat-icon>warning</mat-icon>&nbsp;Please type a valid email address</mat-error>
</div>
</mat-dialog-content>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,66 @@
.mat-mdc-form-field-infix {
display: flex;
}
.toggle {
mat-label {
margin-right: 8px;
}

& .mdc-form-field {
display: flex;
}

& .mdc-label {
font-size: 16px;
padding-left: 12px;
}

& .mat-mdc-slide-toggle .mdc-form-field {
color: colors.$grey;
}

& .mat-mdc-slide-toggle-checked .mdc-form-field {
color: colors.$black;

.mdc-label {
font-weight: 700 !important;
}
}
}
}

.toggle-label {
font-weight: 700;
}

.toggle {
display: flex;
gap: 4px;
color: colors.$black;
font-weight: 700;
margin-left: 14px;
margin-top: 6px;
}

.row {
display: flex;
margin: 24px 0;
align-items: flex-start;
}

.warning {
padding: 16px;
font-size: 14px;
background-color: rgba(colors.$field-warning-bg-color, 0.5);
border-radius: 8px;
display: flex;
align-items: center;
color: colors.$dark-contrast-text;
margin-top: 18px;
margin-bottom: 18px;

mat-icon {
color: colors.$dark-contrast-text;
margin-right: 16px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class ReleaseDialogComponent implements OnInit, OnDestroy {
firstDecision = false;
releasedStatus: ApplicationSubmissionStatusPill | undefined;
cancelledStatus: ApplicationSubmissionStatusPill | undefined;
sendEmail = true;

readonly separatorKeysCodes = [ENTER, COMMA, SPACE] as const;
emails: string[] = [];
Expand Down Expand Up @@ -58,6 +59,7 @@ export class ReleaseDialogComponent implements OnInit, OnDestroy {
this.matDialogRef.close({
confirmed: true,
ccEmails: this.emails,
sendEmail: this.sendEmail,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
}
}

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

try {
await this.saveDecision(isDraft, ccEmails);
await this.saveDecision(isDraft, ccEmails, sendEmail);
} finally {
if (!isStayOnPage) {
this.onCancel();
Expand All @@ -286,8 +286,8 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
}
}

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

if (this.uuid) {
await this.decisionService.update(this.uuid, data);
Expand All @@ -300,7 +300,7 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
}
}

private mapDecisionDataForSave(isDraft: boolean, ccEmails: string[]) {
private mapDecisionDataForSave(isDraft: boolean, ccEmails: string[], sendEmail: boolean = true) {
const {
date,
outcome,
Expand Down Expand Up @@ -334,6 +334,7 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
conditions: this.conditionUpdates,
decisionMaker: decisionMaker ?? undefined,
ccEmails,
sendEmail,
};

return data;
Expand Down Expand Up @@ -441,9 +442,9 @@ export class DecisionInputV2Component implements OnInit, OnDestroy {
},
})
.afterClosed()
.subscribe(async (res: { confirmed: boolean; ccEmails: string[] }) => {
.subscribe(async (res: { confirmed: boolean; ccEmails: string[], sendEmail: boolean }) => {
if (res.confirmed) {
await this.onSubmit(false, false, res.ccEmails);
await this.onSubmit(false, false, res.ccEmails, res.sendEmail);
await this.noticeOfIntentDetailService.load(this.fileNumber);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,57 @@
<h2 class="card-title">Confirm Release Decision</h2>
</div>
<mat-dialog-content class="content">
<div *ngIf="!wasReleased" class="row">
<div class="toggle-label" id="sendEmailLabel">Send Email (with decision document)</div>
<div class="toggle">
<mat-slide-toggle
[(ngModel)]="sendEmail"
aria-labelledby="sendEmailLabel"
></mat-slide-toggle
>
</div>
</div>
<div *ngIf="!sendEmail" class="warning-section">
<div class="warning">
<mat-icon>info</mat-icon> <b>Warning: </b>&nbsp; Email will not be sent
</div>
</div>
<div *ngIf="sendEmail">
<div>
<span *ngIf="!wasReleased">Email will be sent to Primary Contact and Local/First Nation Government</span>
<span *ngIf="wasReleased">No auto-emails will be sent</span>
</div>
<div *ngIf="!wasReleased" style="margin-top: 24px; margin-bottom: 24px;">
<div style="margin-bottom: 4px">
<mat-label>CC additional recipients on decision release email (optional):</mat-label>
</div>
<mat-form-field style="width: 100%" appearance="outline">
<mat-chip-grid #chipGrid aria-label="Enter emails">
<mat-chip-row
*ngFor="let email of emails"
(removed)="onRemoveEmail(email)"
[editable]="true"
(edited)="editEmail(email, $event)"
[aria-description]="'press enter to edit ' + email"
>
{{ email }}
<button matChipRemove [attr.aria-label]="'remove ' + email">
<mat-icon>cancel</mat-icon>
</button>
</mat-chip-row>
</mat-chip-grid>
<input
placeholder="Type and hit ‘space’ to add emails"
[matChipInputFor]="chipGrid"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
[matChipInputAddOnBlur]="true"
(matChipInputTokenEnd)="addEmail($event)"
[formControl]="email"
/>
</mat-form-field>
<mat-error *ngIf="email.invalid"><mat-icon>warning</mat-icon>&nbsp;Please type a valid email address</mat-error>
</div>
</div>
<p>Upon releasing the decision:</p>
<div class="release-data">
<div><strong>Visibility:</strong> Applicant, Local/First Nation Government, and Public</div>
Expand All @@ -16,42 +67,6 @@ <h2 class="card-title">Confirm Release Decision</h2>
[type]="cancelledStatus"
></app-application-submission-status-type-pill>
</div>
<div>
<strong>Email (with decision document) sent to: </strong>
<span *ngIf="!wasReleased">Primary Contact and Local/First Nation Government</span>
<span *ngIf="wasReleased">No auto-emails will be sent</span>
</div>
</div>
<div *ngIf="!wasReleased" style="margin-top: 24px">
<div style="margin-bottom: 4px">
<mat-label>CC additional recipients on decision release email (optional):</mat-label>
</div>
<mat-form-field style="width: 100%" appearance="outline">
<mat-chip-grid #chipGrid aria-label="Enter emails">
<mat-chip-row
*ngFor="let email of emails"
class="chip"
(removed)="onRemoveEmail(email)"
[editable]="true"
(edited)="editEmail(email, $event)"
[aria-description]="'press enter to edit ' + email"
>
{{ email }}
<button matChipRemove [attr.aria-label]="'remove ' + email">
<mat-icon>cancel</mat-icon>
</button>
</mat-chip-row>
</mat-chip-grid>
<input
placeholder="Type and hit ‘space’ to add emails"
[matChipInputFor]="chipGrid"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
[matChipInputAddOnBlur]="true"
(matChipInputTokenEnd)="addEmail($event)"
[formControl]="email"
/>
</mat-form-field>
<mat-error *ngIf="email.invalid"><mat-icon>warning</mat-icon>&nbsp;Please type a valid email address</mat-error>
</div>
</mat-dialog-content>

Expand Down
Loading