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

EMBCESSMOD-5632: province validation fix #2386

Merged
merged 2 commits into from
Jul 16, 2024
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 @@ -29,6 +29,7 @@ import { BcAddressComponent } from '../../../../shared/forms/address-forms/bc-ad
import { MatDatepickerInput, MatDatepickerToggle, MatDatepicker } from '@angular/material/datepicker';
import { MatInput } from '@angular/material/input';
import { MatFormField, MatLabel, MatError, MatSuffix } from '@angular/material/form-field';
import { Community } from 'src/app/core/services/locations.service';

@Component({
selector: 'app-evacuation-details',
Expand Down Expand Up @@ -196,24 +197,18 @@ export class EvacuationDetailsComponent implements OnInit, OnDestroy {
*/
private createEvacDetailsForm(): void {
this.evacDetailsForm = this.formBuilder.group({
paperESSFile: [this.stepEssFileService.paperESSFile !== undefined ? this.stepEssFileService.paperESSFile : ''],
paperESSFile: [this.stepEssFileService.paperESSFile ?? ''],
evacuatedFromPrimary: [
this.stepEssFileService.evacuatedFromPrimary !== null ? this.stepEssFileService.evacuatedFromPrimary : '',
this.stepEssFileService.evacuatedFromPrimary ?? '',
this.customValidation
.conditionalValidation(
() => this.evacDetailsForm.get('primaryAddressIndicator').value === true,
Validators.required
)
.bind(this.customValidation)
],
facilityName: [
this.stepEssFileService.facilityName !== undefined ? this.stepEssFileService.facilityName : '',
[this.customValidation.whitespaceValidator()]
],
insurance: [
this.stepEssFileService.insurance !== undefined ? this.stepEssFileService.insurance : '',
Validators.required
],
facilityName: [this.stepEssFileService.facilityName ?? '', [this.customValidation.whitespaceValidator()]],
insurance: [this.stepEssFileService.insurance ?? '', Validators.required],
primaryAddressIndicator: [true],
evacAddress: this.createEvacAddressForm(),
paperIssuedBy: this.formBuilder.group({
Expand Down Expand Up @@ -318,7 +313,10 @@ export class EvacuationDetailsComponent implements OnInit, OnDestroy {
* Checks if the inserted primary address is in BC Province
*/
private checkAddress() {
if (this.stepEssFileService?.primaryAddress?.stateProvince?.code !== 'BC') {
if (
this.stepEssFileService?.primaryAddress?.stateProvince?.code !== 'BC' ||
!(this.stepEssFileService?.primaryAddress?.community as Community)?.code
) {
this.isBCAddress = false;

// Make sure province/country are set to BC/Can whenever address form is displayed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
/>
<mat-autocomplete #auto="matAutocomplete" [displayWith]="provinceDisplayFn">
@for (option of filteredOptions | async; track option) {
<mat-option [value]="option">
<mat-option [value]="option" [disabled]="option.name === 'British Columbia'">
{{ option.name }}
</mat-option>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export class MaskEvacuatedAddressPipe implements PipeTransform {
*/
transform(address: AddressModel): SafeHtml {
if (address !== null && address !== undefined) {
const communities = this.locationService.getCommunityList();

let line1 = address.addressLine1;
let line2 = '';

Expand Down