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-4901: registrant portal inentified needs changes #2010

Merged
merged 4 commits into from
Apr 11, 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
8 changes: 3 additions & 5 deletions registrants/src/UI/embc-registrant/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
"no-shadow": "off",
"deprecation/deprecation": "error",
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/no-shadow": [
"error"
],
"@angular-eslint/component-selector": [
"error",
{
Expand All @@ -46,7 +43,8 @@
"prefix": "app",
"style": "camelCase"
}
]
],
"max-len": "off"
}
},
{
Expand Down Expand Up @@ -79,4 +77,4 @@
}
}
]
}
}
9 changes: 5 additions & 4 deletions registrants/src/UI/embc-registrant/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"singleQuote": true,
"trailingComma": "none",
"endOfLine": "auto"
}
"singleQuote": true,
"trailingComma": "none",
"endOfLine": "auto",
"printWidth": 180
}
4 changes: 2 additions & 2 deletions registrants/src/UI/embc-registrant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"gen-api": "ng-openapi-gen -i https://era-evacuees-dev.apps.silver.devops.gov.bc.ca/api/openapi/v1/openapi.json -o ./src/app/core/api --ignoreUnusedModels false",
"gen-api": "ng-openapi-gen -i https://dev-era-evacuees.apps.silver.devops.gov.bc.ca/api/openapi/v1/openapi.json -o ./src/app/core/api --ignoreUnusedModels false",
"gen-api-local": "ng-openapi-gen -i http://localhost:5020/api/openapi/v1/openapi.json -o ./src/app/core/api --ignoreUnusedModels false"
},
"private": true,
Expand Down Expand Up @@ -67,4 +67,4 @@
"ts-node": "~8.3.0",
"typescript": "~4.7.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Injectable } from '@angular/core';
providedIn: 'root',
})
export class ApiConfiguration {
rootUrl: string = 'https://era-evacuees-dev.apps.silver.devops.gov.bc.ca';
rootUrl: string = 'https://dev-era-evacuees.apps.silver.devops.gov.bc.ca';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export { InsuranceOption } from './models/insurance-option';
export { HouseholdMember } from './models/household-member';
export { Pet } from './models/pet';
export { NeedsAssessmentType } from './models/needs-assessment-type';
export { IdentifiedNeed } from './models/identified-need';
export { Support } from './models/support';
export { SupportStatus } from './models/support-status';
export { SupportCategory } from './models/support-category';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* tslint:disable */
/* eslint-disable */
export enum IdentifiedNeed {
ShelterReferral = 'ShelterReferral',
ShelterAllowance = 'ShelterAllowance',
Tranportation = 'Tranportation',
Food = 'Food',
Incidentals = 'Incidentals',
Clothing = 'Clothing'
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* tslint:disable */
/* eslint-disable */
import { HouseholdMember } from './household-member';
import { IdentifiedNeed } from './identified-need';
import { InsuranceOption } from './insurance-option';
import { NeedsAssessmentType } from './needs-assessment-type';
import { Pet } from './pet';
Expand All @@ -9,14 +10,10 @@ import { Pet } from './pet';
* Needs assessment form
*/
export interface NeedsAssessment {
canEvacueeProvideClothing?: null | boolean;
canEvacueeProvideFood?: null | boolean;
canEvacueeProvideIncidentals?: null | boolean;
canEvacueeProvideLodging?: null | boolean;
canEvacueeProvideTransportation?: null | boolean;
householdMembers?: Array<HouseholdMember>;
id?: null | string;
insurance: InsuranceOption;
needs?: Array<IdentifiedNeed>;
pets?: Array<Pet>;
type?: NeedsAssessmentType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum SupportSubCategory {
Lodging_Hotel = 'Lodging_Hotel',
Lodging_Billeting = 'Lodging_Billeting',
Lodging_Group = 'Lodging_Group',
Lodging_Allowance = 'Lodging_Allowance',
Food_Groceries = 'Food_Groceries',
Food_Restaurant = 'Food_Restaurant',
Transportation_Taxi = 'Transportation_Taxi',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
</div> -->

<div class="row justify-content-between">
<div class="col-md-10">
<div class="col-10">
<h1
class="mat-title"
*ngIf="data?.content?.title"
mat-dialog-title
[innerHTML]="data?.content?.title"
></h1>
</div>
<div class="col-md-2">
<div class="col-2">
<button
class="close-image close-button-style"
mat-icon-button
Expand Down
193 changes: 68 additions & 125 deletions registrants/src/UI/embc-registrant/src/app/core/model/needs.model.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import {
UntypedFormBuilder,
UntypedFormControl,
UntypedFormGroup,
Validators
} from '@angular/forms';
import { HouseholdMember } from '../api/models';
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
import { HouseholdMember, IdentifiedNeed } from '../api/models';
import { CustomValidationService } from '../services/customValidation.service';
import { RegAddress } from './address';

Expand All @@ -20,21 +15,14 @@ export class EvacuatedForm {
evacuatedFromAddress: UntypedFormGroup;
insurance = new UntypedFormControl();

constructor(
evacuated: Evacuated,
builder: UntypedFormBuilder,
customValidator: CustomValidationService
) {
constructor(evacuated: Evacuated, builder: UntypedFormBuilder, customValidator: CustomValidationService) {
this.evacuatedFromAddress = builder.group({
addressLine1: ['', [Validators.required]],
addressLine2: [''],
community: ['', [Validators.required]],
stateProvince: ['', [Validators.required]],
country: ['', [Validators.required]],
postalCode: [
'',
[customValidator.postalValidation().bind(customValidator)]
]
postalCode: ['', [customValidator.postalValidation().bind(customValidator)]]
});

this.insurance.setValue(evacuated.insurance);
Expand All @@ -53,62 +41,18 @@ export class HouseholdMembersForm {
householdMembers = new UntypedFormControl([]);
addHouseholdMemberIndicator = new UntypedFormControl(false);

constructor(
householdMembers: HouseholdMembers,
customValidator: CustomValidationService,
builder: UntypedFormBuilder
) {
constructor(householdMembers: HouseholdMembers, customValidator: CustomValidationService, builder: UntypedFormBuilder) {
this.householdMember = builder.group({
firstName: [
'',
[
customValidator
.conditionalValidation(
() => this.addHouseholdMemberIndicator.value,
Validators.required
)
.bind(customValidator)
]
],
lastName: [
'',
[
customValidator
.conditionalValidation(
() => this.addHouseholdMemberIndicator.value,
Validators.required
)
.bind(customValidator)
]
],
firstName: ['', [customValidator.conditionalValidation(() => this.addHouseholdMemberIndicator.value, Validators.required).bind(customValidator)]],
lastName: ['', [customValidator.conditionalValidation(() => this.addHouseholdMemberIndicator.value, Validators.required).bind(customValidator)]],
sameLastNameCheck: [''],
initials: [''],
gender: [
'',
[
customValidator
.conditionalValidation(
() => this.addHouseholdMemberIndicator.value,
Validators.required
)
.bind(customValidator)
]
],
gender: ['', [customValidator.conditionalValidation(() => this.addHouseholdMemberIndicator.value, Validators.required).bind(customValidator)]],
dateOfBirth: [
'',
[
customValidator
.conditionalValidation(
() => this.addHouseholdMemberIndicator.value,
Validators.required
)
.bind(customValidator),
customValidator
.conditionalValidation(
() => this.addHouseholdMemberIndicator.value,
customValidator.dateOfBirthValidator().bind(customValidator)
)
.bind(customValidator)
customValidator.conditionalValidation(() => this.addHouseholdMemberIndicator.value, Validators.required).bind(customValidator),
customValidator.conditionalValidation(() => this.addHouseholdMemberIndicator.value, customValidator.dateOfBirthValidator().bind(customValidator)).bind(customValidator)
]
],
isPrimaryRegistrant: ['']
Expand All @@ -128,78 +72,80 @@ export class PetForm {
pet: UntypedFormGroup;
addPetIndicator = new UntypedFormControl(false);

constructor(
pet: Pet,
customValidator: CustomValidationService,
builder: UntypedFormBuilder
) {
constructor(pet: Pet, customValidator: CustomValidationService, builder: UntypedFormBuilder) {
this.pet = builder.group({
quantity: [
'',
[
customValidator
.conditionalValidation(
() => this.addPetIndicator.value,
Validators.required
)
.bind(customValidator),
customValidator.conditionalValidation(() => this.addPetIndicator.value, Validators.required).bind(customValidator),
customValidator.quantityPetsValidator().bind(customValidator)
]
],
type: [
'',
[
customValidator
.conditionalValidation(
() => this.addPetIndicator.value,
Validators.required
)
.bind(customValidator)
]
]
type: ['', [customValidator.conditionalValidation(() => this.addPetIndicator.value, Validators.required).bind(customValidator)]]
});

}
}

export class IdentifyNeeds {
canEvacueeProvideClothing: boolean;
canEvacueeProvideFood: boolean;
canEvacueeProvideIncidentals: boolean;
canEvacueeProvideLodging: boolean;
canEvacueeProvideTransportation: boolean;
needs: IdentifiedNeed[] = [];
}

export class IdentifyNeedsForm {
canEvacueeProvideClothing = new UntypedFormControl();
canEvacueeProvideFood = new UntypedFormControl();
canEvacueeProvideIncidentals = new UntypedFormControl();
canEvacueeProvideLodging = new UntypedFormControl();
canEvacueeProvideTransportation = new UntypedFormControl();
requiresClothing = new UntypedFormControl();
requiresFood = new UntypedFormControl();
requiresIncidentals = new UntypedFormControl();
requiresShelterType = new UntypedFormControl();
requiresShelter = new UntypedFormControl();
requiresNothing = new UntypedFormControl();

constructor(identifyNeeds: IdentifyNeeds) {
this.canEvacueeProvideClothing.setValue(
identifyNeeds.canEvacueeProvideClothing
);
this.canEvacueeProvideClothing.setValidators([Validators.required]);

this.canEvacueeProvideFood.setValue(identifyNeeds.canEvacueeProvideFood);
this.canEvacueeProvideFood.setValidators([Validators.required]);

this.canEvacueeProvideIncidentals.setValue(
identifyNeeds.canEvacueeProvideIncidentals
);
this.canEvacueeProvideIncidentals.setValidators([Validators.required]);

this.canEvacueeProvideLodging.setValue(
identifyNeeds.canEvacueeProvideLodging
);
this.canEvacueeProvideLodging.setValidators([Validators.required]);

this.canEvacueeProvideTransportation.setValue(
identifyNeeds.canEvacueeProvideTransportation
);
this.canEvacueeProvideTransportation.setValidators([Validators.required]);
this.requiresClothing.setValue(identifyNeeds.needs.includes(IdentifiedNeed.Clothing));
this.requiresFood.setValue(identifyNeeds.needs.includes(IdentifiedNeed.Food));
this.requiresIncidentals.setValue(identifyNeeds.needs.includes(IdentifiedNeed.Incidentals));
if (identifyNeeds.needs.includes(IdentifiedNeed.ShelterReferral)) {
this.requiresShelterType.setValue('shelterReferral');
} else if (identifyNeeds.needs.includes(IdentifiedNeed.ShelterAllowance)) {
this.requiresShelterType.setValue('shelterAllowance');
}
this.requiresShelter.setValue(identifyNeeds.needs.includes(IdentifiedNeed.ShelterReferral) || identifyNeeds.needs.includes(IdentifiedNeed.ShelterAllowance));
this.requiresNothing.valueChanges.subscribe((checked) => {
if (checked) {
this.disableNeeds();
} else {
this.enableNeeds();
}
});
this.requiresShelter.valueChanges.subscribe((checked) => {
if (!checked) {
this.requiresShelterType.reset();
}
});
}

private disableNeeds() {
this.disableFormControl(this.requiresIncidentals);
this.disableFormControl(this.requiresClothing);
this.disableFormControl(this.requiresFood);
this.disableFormControl(this.requiresShelter);
this.disableFormControl(this.requiresShelterType);
}

private enableNeeds() {
this.enableFormControl(this.requiresIncidentals);
this.enableFormControl(this.requiresClothing);
this.enableFormControl(this.requiresFood);
this.enableFormControl(this.requiresShelter);
this.enableFormControl(this.requiresShelterType);
}

private disableFormControl(formControl: UntypedFormControl) {
formControl.disable();
formControl.reset();
}

private enableFormControl(formControl: UntypedFormControl) {
formControl.enable();
formControl.reset();
}
}

Expand All @@ -214,9 +160,6 @@ export class SecretForm {

constructor(secret: Secret) {
this.secretPhrase.setValue(secret.secretPhrase);
this.secretPhrase.setValidators([
Validators.required,
Validators.minLength(6)
]);
this.secretPhrase.setValidators([Validators.required, Validators.minLength(6)]);
}
}
Loading