Skip to content

Commit

Permalink
Merge pull request bcgov#2035 from HemanthKona/stories/EMBCESS-5135
Browse files Browse the repository at this point in the history
EMBCESSMOD-5109, EMBCESSMOD-5132, EMBCESSMOD-5133, EMBCESSMOD-5134, EMBCESSMOD-5135
  • Loading branch information
ytqsl authored Apr 15, 2024
2 parents 0a563e8 + c36c933 commit bfb7b77
Show file tree
Hide file tree
Showing 8 changed files with 795 additions and 1,011 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ export class IdentifyNeedsForm {
requiresClothing = new UntypedFormControl();
requiresFood = new UntypedFormControl();
requiresIncidentals = new UntypedFormControl();
requiresShelterType = new UntypedFormControl();
requiresShelterType = new UntypedFormControl(null, [this.customValidator.conditionalValidation(() => this.requiresShelter.value, Validators.required)]);
requiresShelter = new UntypedFormControl();
requiresNothing = new UntypedFormControl();

constructor(identifyNeeds: IdentifyNeeds) {
constructor(identifyNeeds: IdentifyNeeds, private customValidator: CustomValidationService) {
this.requiresClothing.setValue(identifyNeeds.needs.includes(IdentifiedNeed.Clothing));
this.requiresFood.setValue(identifyNeeds.needs.includes(IdentifiedNeed.Food));
this.requiresIncidentals.setValue(identifyNeeds.needs.includes(IdentifiedNeed.Incidentals));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AbstractControl, ValidatorFn, Validators } from '@angular/forms';
import { AbstractControl, FormGroup, ValidationErrors, ValidatorFn, Validators } from '@angular/forms';
import { Injectable } from '@angular/core';
import * as moment from 'moment';
import * as globalConst from '../services/globalConstants';
Expand Down Expand Up @@ -38,11 +38,7 @@ export class CustomValidationService {
* @param validator : validator to test again
* @param errorName : custom error name
*/
conditionalValidation(
predicate: () => boolean,
validator: ValidatorFn,
errorName?: string
): ValidatorFn {
conditionalValidation(predicate: () => boolean, validator: ValidatorFn, errorName?: string): ValidatorFn {
return (control: AbstractControl): { [key: string]: boolean } | null => {
if (control.parent) {
let validationError = null;
Expand Down Expand Up @@ -70,14 +66,7 @@ export class CustomValidationService {
if (control) {
const email = control.get('email').value;
const confirmEmail = control.get('confirmEmail').value;
if (
email !== undefined &&
confirmEmail !== undefined &&
email !== null &&
confirmEmail !== null &&
email !== '' &&
confirmEmail !== ''
) {
if (email !== undefined && confirmEmail !== undefined && email !== null && confirmEmail !== null && email !== '' && confirmEmail !== '') {
if (email.toLowerCase() !== confirmEmail.toLowerCase()) {
return { emailMatch: true };
}
Expand All @@ -94,16 +83,8 @@ export class CustomValidationService {
const confirmEmail = control.get('confirmEmail').value;
const phone = control.get('phone').value;

if (
control.get('showContacts').value === true &&
(phone === null || phone === undefined || phone === '')
) {
if (
(email !== undefined || email !== null || email === '') &&
(confirmEmail === null ||
confirmEmail === '' ||
confirmEmail === undefined)
) {
if (control.get('showContacts').value === true && (phone === null || phone === undefined || phone === '')) {
if ((email !== undefined || email !== null || email === '') && (confirmEmail === null || confirmEmail === '' || confirmEmail === undefined)) {
return { confirmEmailRequired: true };
}
}
Expand All @@ -118,10 +99,7 @@ export class CustomValidationService {
postalValidation(): ValidatorFn {
return (control: AbstractControl): { [key: string]: boolean } | null => {
if (control.parent) {
if (
control.parent.get('country').value !== undefined &&
control.parent.get('country').value !== null
) {
if (control.parent.get('country').value !== undefined && control.parent.get('country').value !== null) {
if (control.parent.get('country').value.code === 'CAN') {
return Validators.pattern(globalConst.postalPattern)(control);
} else if (control.parent.get('country').value.code === 'USA') {
Expand Down Expand Up @@ -151,8 +129,7 @@ export class CustomValidationService {
* Checks if the quantity inserted is between 1 and 999
*/
quantityPetsValidator(): ValidatorFn {
return (control: AbstractControl): { [key: string]: boolean } | null =>
Validators.pattern(globalConst.petsQuantityPattern)(control);
return (control: AbstractControl): { [key: string]: boolean } | null => Validators.pattern(globalConst.petsQuantityPattern)(control);
}

whitespaceValidator(): ValidatorFn {
Expand All @@ -165,7 +142,6 @@ export class CustomValidationService {
};
}


/**
* Checks an array of controls by name, to see if they all have different values (unless empty)
*
Expand Down Expand Up @@ -204,4 +180,17 @@ export class CustomValidationService {
return null;
};
}

public needsValidator(): ValidatorFn {
return (group: FormGroup): ValidationErrors | null => {
const anyNeedsIdentified =
group.controls['requiresShelter'].value || group.controls['requiresFood'].value || group.controls['requiresClothing'].value || group.controls['requiresIncidentals'].value;

const noNeedsIdentified = group.controls['requiresNothing'].value;
if (!anyNeedsIdentified && !noNeedsIdentified) {
return { invalid: true };
}
return null;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export class FormCreationService {

petsForm$: Observable<UntypedFormGroup> = this.petsForm.asObservable();

identifyNeedsForm: BehaviorSubject<UntypedFormGroup | undefined> = new BehaviorSubject(this.formBuilder.group(new IdentifyNeedsForm(new IdentifyNeeds())));
identifyNeedsForm: BehaviorSubject<UntypedFormGroup | undefined> = new BehaviorSubject(
this.formBuilder.group(new IdentifyNeedsForm(new IdentifyNeeds(), this.customValidator), { validators: [this.customValidator.needsValidator()] })
);

identifyNeedsForm$: Observable<UntypedFormGroup> = this.identifyNeedsForm.asObservable();

Expand Down Expand Up @@ -162,7 +164,7 @@ export class FormCreationService {
this.evacuatedForm.next(this.formBuilder.group(new EvacuatedForm(new Evacuated(), this.formBuilder, this.customValidator)));
this.householdMembersForm.next(this.formBuilder.group(new HouseholdMembersForm(new HouseholdMembers(), this.customValidator, this.formBuilder)));
this.petsForm.next(this.formBuilder.group(new PetForm(new Pet(), this.customValidator, this.formBuilder)));
this.identifyNeedsForm.next(this.formBuilder.group(new IdentifyNeedsForm(new IdentifyNeeds())));
this.identifyNeedsForm.next(this.formBuilder.group(new IdentifyNeedsForm(new IdentifyNeeds(), this.customValidator), { validators: [this.customValidator.needsValidator()] }));
this.secretForm.next(this.formBuilder.group(new SecretForm(new Secret())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const successfulBcscInvite: DialogContent = {

export const shelterAllowanceNeedDialog: DialogContent = {
title: 'Shelter',
text: 'A shelter allowance of $30 per night based on single occupancy ($10 for each additional adult and youth, and $5 for each child<br/>The shelter allowance can be provided to eligible evacuees via e-Transfer.'
text: 'A shelter allowance of $30 per night based on single occupancy ($10 for each additional adult and youth, and $5 for each child).<br/>The shelter allowance can be provided to eligible evacuees via e-Transfer.'
};

export const shelterReferralNeedDialog: DialogContent = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Observable } from 'rxjs';
import { NavigationExtras, Router } from '@angular/router';
import { FormCreationService } from '../../core/services/formCreation.service';
import {
CaptchaResponse,
CaptchaResponseType
} from 'src/app/core/components/captcha-v2/captcha-v2.component';
import { ConfigService } from 'src/app/core/services/config.service';
import { IdentifyNeedsForm } from 'src/app/core/model/needs.model';
import { CaptchaResponse, CaptchaResponseType } from 'src/app/core/components/captcha-v2/captcha-v2.component';
import { UntypedFormGroup } from '@angular/forms';
import { ShelterType } from 'src/app/core/services/globalConstants';

Expand All @@ -30,10 +25,7 @@ export class ReviewComponent implements OnInit {
hideCard = false;
navigationExtras: NavigationExtras;

constructor(
private router: Router,
public formCreationService: FormCreationService
) { }
constructor(private router: Router, public formCreationService: FormCreationService) {}

ngOnInit(): void {
this.navigationExtras = { state: { parentPageName: this.parentPageName } };
Expand Down Expand Up @@ -74,10 +66,15 @@ export class ReviewComponent implements OnInit {
needs.push('Incidentals');
}
if (form.controls.requiresShelterType?.value === ShelterType.referral) {
needs.push('Shelter referral');
needs.push('Shelter');
} else if (form.controls.requiresShelterType?.value === ShelterType.allowance) {
needs.push('Shelter allowance');
}

if (form.controls.requiresNothing?.value) {
needs.push('Household currently does not require assistance.');
}

return needs;
}
}
Original file line number Diff line number Diff line change
@@ -1,79 +1,41 @@
<br />
<div class="row" style="max-width: 100%">
<div class="col-md-12 breadCrumb">
<a class="goBackLink" (click)="goToCurrent()"
>{{ evacuationFileTab }} Events ({{
evacuationFileDataService.currentEvacuationFileCount$ | async
}}) &nbsp;</a
>
<span>
/ &nbsp; ESS File #{{
evacuationFileDataService?.isPaper
? evacuationFileDataService.externalReferenceId
: evacuationFileDataService?.essFileId
}}</span
>
<a class="goBackLink" (click)="goToCurrent()">{{ evacuationFileTab }} Events ({{ evacuationFileDataService.currentEvacuationFileCount$ | async }}) &nbsp;</a>
<span> / &nbsp; ESS File #{{ evacuationFileDataService?.isPaper ? evacuationFileDataService.externalReferenceId : evacuationFileDataService?.essFileId }}</span>
</div>
</div>
<mat-card class="detailsCard">
<div class="row evacFileHeader">
<div class="col-md-9 titleDetailHeader">
<button
class="backButton"
(click)="goToCurrent()"
(mouseover)="onMouseOver()"
(mouseout)="onMouseOut()"
>
<button class="backButton" (click)="goToCurrent()" (mouseover)="onMouseOver()" (mouseout)="onMouseOut()">
<img [src]="backArrowImgSrc" height="28" width="31" />
</button>
<span class="evacFileSpan"
>ESS File #{{
evacuationFileDataService?.isPaper
? evacuationFileDataService.externalReferenceId
: evacuationFileDataService?.essFileId
}}</span
>
<span class="evacFileSpan">ESS File #{{ evacuationFileDataService?.isPaper ? evacuationFileDataService.externalReferenceId : evacuationFileDataService?.essFileId }}</span>
</div>

<div class="col-md-3 statusDetailHeader">
<div class="statusDetailHeaderElements">
<span>Status: </span>
<span
[ngClass]="{
'support-active':
evacuationFileDataService.evacuationFileStatus === 'Active',
'support-pending':
evacuationFileDataService.evacuationFileStatus === 'Pending',
'support-expired':
evacuationFileDataService.evacuationFileStatus === 'Expired',
'support-completed':
evacuationFileDataService.evacuationFileStatus === 'Completed',
'support-archived':
evacuationFileDataService.evacuationFileStatus === 'Archived'
'support-active': evacuationFileDataService.evacuationFileStatus === 'Active',
'support-pending': evacuationFileDataService.evacuationFileStatus === 'Pending',
'support-expired': evacuationFileDataService.evacuationFileStatus === 'Expired',
'support-completed': evacuationFileDataService.evacuationFileStatus === 'Completed',
'support-archived': evacuationFileDataService.evacuationFileStatus === 'Archived'
}"
>{{ evacuationFileDataService.evacuationFileStatus }}</span
>
</div>
</div>
</div>
<div *ngIf="referralData?.size === 0; else referrals">
<app-review
[type]="type"
[showHeading]="false"
[currentFlow]="currentFlow"
[parentPageName]="parentPageName"
[allowEdit]="allowEdition()"
>
</app-review>
<app-review [type]="type" [showHeading]="false" [currentFlow]="currentFlow" [parentPageName]="parentPageName" [allowEdit]="allowEdition()"> </app-review>
<div class="supportReceived">
<p class="titleDetailHeader">Supports Received</p>
<p class="supportReceivedBoldSpan">
We do not have any records of supports issued within our system.
</p>
<p class="supportReceivedRegSpan">
Please proceed to an ESS volunteer or your nearest reception center
where you will be assisted.
</p>
<p class="supportReceivedBoldSpan">We do not have any records of supports issued within our system.</p>
<p class="supportReceivedRegSpan">Please proceed to an ESS volunteer or your nearest reception center where you will be assisted.</p>
</div>
</div>
<ng-template #referrals>
Expand All @@ -87,23 +49,15 @@
<div class="col-md-3">Evacuated From:</div>
<div class="col-md-3 evacuatedAddress">
<div>
<p
[innerHTML]="
evacuationFileDataService?.evacuatedAddress
| maskEvacuatedaddress
"
></p>
<p [innerHTML]="evacuationFileDataService?.evacuatedAddress | maskEvacuatedaddress"></p>
</div>
</div>
</div>
<div class="row info-detail">
<div class="col-md-3">ESS File Created:</div>
<div class="col-md-3">
<span
><b>{{
evacuationFileDataService?.evacuationFileDate
| date: 'dd-MMM-yyyy'
}}</b></span
><b>{{ evacuationFileDataService?.evacuationFileDate | date: 'dd-MMM-yyyy' }}</b></span
>
</div>
</div>
Expand All @@ -113,22 +67,14 @@
</div>
<hr />
<div class="row info-detail">
<div class="col-10">
Click on the dates that you received supports below to view full
support details.
</div>
<div class="col-10">Click on the dates that you received supports below to view full support details.</div>
<div class="col-2 row mainReferralsLink" (click)="expandDetails()">
<div class="col-md-6 allReferrals">
<a>{{ this.allExpandState ? 'close all' : 'expand all' }}</a>
</div>
<div class="col-md-6 row">
<div class="col-md-9" style="height: 6px">
<img
[ngClass]="allExpandState ? 'none' : 'rotate180'"
src="../../../../assets/images/expand_arrow.png"
height="15"
width="18"
/>
<img [ngClass]="allExpandState ? 'none' : 'rotate180'" src="../../../../assets/images/expand_arrow.png" height="15" width="18" />
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit bfb7b77

Please sign in to comment.