Skip to content

Commit

Permalink
Merge pull request bcgov#2108 from bcgov/release/R3.1.0
Browse files Browse the repository at this point in the history
R3.1.0->master
  • Loading branch information
ytqsl authored May 2, 2024
2 parents bc296cf + 758df05 commit 7641b86
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export class HouseholdMembersForm {
customValidator.conditionalValidation(() => this.addHouseholdMemberIndicator.value, customValidator.dateOfBirthValidator().bind(customValidator)).bind(customValidator)
]
],
isPrimaryRegistrant: ['']
isPrimaryRegistrant: [''],
id: [''],
isMinor: ['']
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class RestrictionForm {
}
}

export class PersonDetails {
export class PersonDetailsModel {
firstName: string;
lastName: string;
preferredName?: string;
Expand All @@ -31,17 +31,8 @@ export class PersonDetails {
dateOfBirth: string;
sameLastNameCheck?: boolean;
isPrimaryRegistrant?: boolean;

constructor(
firstName?: string,
lastName?: string,
preferredName?: string,
initials?: string,
gender?: string,
dateOfBirth?: string,
sameLastNameCheck?: boolean,
isPrimaryRegistrant?: boolean
) {}
id?: string;
isMinor: boolean;
}

export class PersonDetailsForm {
Expand All @@ -53,7 +44,7 @@ export class PersonDetailsForm {
dateOfBirth = new UntypedFormControl();

constructor(
personDetail: PersonDetails,
personDetail: PersonDetailsModel,
customValidator: CustomValidationService
) {
if (personDetail.firstName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Observable, BehaviorSubject } from 'rxjs';
import { UntypedFormGroup, UntypedFormBuilder } from '@angular/forms';
import {
PersonDetailsForm,
PersonDetails,
PersonDetailsModel,
ContactDetailsForm,
ContactDetails,
AddressForm,
Expand All @@ -23,7 +23,7 @@ export class FormCreationService {
restrictionForm$: Observable<UntypedFormGroup> = this.restrictionForm.asObservable();

personalDetailsForm: BehaviorSubject<UntypedFormGroup | undefined> = new BehaviorSubject(
this.formBuilder.group(new PersonDetailsForm(new PersonDetails(), this.customValidator))
this.formBuilder.group(new PersonDetailsForm(new PersonDetailsModel(), this.customValidator))
);

personalDetailsForm$: Observable<UntypedFormGroup> = this.personalDetailsForm.asObservable();
Expand Down Expand Up @@ -155,7 +155,7 @@ export class FormCreationService {
clearProfileData(): void {
this.restrictionForm.next(this.formBuilder.group(new RestrictionForm(new Restriction())));
this.addressForm.next(this.formBuilder.group(new AddressForm(new Address(), this.formBuilder, this.customValidator)));
this.personalDetailsForm.next(this.formBuilder.group(new PersonDetailsForm(new PersonDetails(), this.customValidator)));
this.personalDetailsForm.next(this.formBuilder.group(new PersonDetailsForm(new PersonDetailsModel(), this.customValidator)));
this.contactDetailsForm.next(this.formBuilder.group(new ContactDetailsForm(new ContactDetails(), this.customValidator)));
this.securityQuestionsForm.next(this.formBuilder.group(new SecurityQuestionsForm(new SecurityQuestions(), this.formBuilder, this.customValidator)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { first } from 'rxjs/operators';
import { HouseholdMember, IdentifiedNeed, InsuranceOption, NeedsAssessment, Pet } from 'src/app/core/api/models';
import { RegAddress } from 'src/app/core/model/address';
import { PersonDetails } from 'src/app/core/model/profile.model';
import { PersonDetailsModel } from 'src/app/core/model/profile.model';
import { FormCreationService } from 'src/app/core/services/formCreation.service';
import { EvacuationFileDataService } from '../../sharedModules/components/evacuation-file/evacuation-file-data.service';
import { ProfileDataService } from '../profile/profile-data.service';
Expand All @@ -17,12 +17,12 @@ export class NeedsAssessmentMappingService {
private profileDataService: ProfileDataService,
private needsAssessmentService: NeedsAssessmentService,
private evacuationFileDataService: EvacuationFileDataService
) {}
) { }

setNeedsAssessment(evacuatedAddress: RegAddress, needsAssessment: NeedsAssessment): void {
this.setNeedsAssessmentId(needsAssessment.id);
this.setInsurance(evacuatedAddress, needsAssessment.insurance);
this.setFamilyMedicationDiet(needsAssessment.householdMembers);
this.setHouseholdMembers(needsAssessment.householdMembers);
this.setPets(needsAssessment.pets);
this.setIdentifiedNeeds(needsAssessment.needs);
}
Expand All @@ -47,7 +47,7 @@ export class NeedsAssessmentMappingService {
});
}

setFamilyMedicationDiet(householdMembers: Array<HouseholdMember>): void {
setHouseholdMembers(householdMembers: Array<HouseholdMember>): void {
this.needsAssessmentService.householdMembers = householdMembers;

this.formCreationService
Expand All @@ -63,7 +63,9 @@ export class NeedsAssessmentMappingService {
initials: '',
lastName: '',
sameLastNameCheck: '',
isPrimaryRegistrant: ''
isPrimaryRegistrant: '',
id: '',
isMinor: '',
},
addHouseholdMemberIndicator: null
});
Expand Down Expand Up @@ -107,18 +109,20 @@ export class NeedsAssessmentMappingService {
});
}

public convertVerifiedHouseholdMembers(householdMembers: Array<HouseholdMember>): Array<PersonDetails> {
const householdMembersFormArray: Array<PersonDetails> = [];
public convertVerifiedHouseholdMembers(householdMembers: Array<HouseholdMember>): Array<PersonDetailsModel> {
const householdMembersFormArray: Array<PersonDetailsModel> = [];

for (const member of householdMembers) {
const memberDetails: PersonDetails = {
const memberDetails: PersonDetailsModel = {
firstName: member.details.firstName,
lastName: member.details.lastName,
initials: member.details.initials,
gender: member.details.gender,
dateOfBirth: member.details.dateOfBirth,
isPrimaryRegistrant: member.isPrimaryRegistrant,
sameLastNameCheck: this.isSameLastName(member.details.lastName)
sameLastNameCheck: this.isSameLastName(member.details.lastName),
id: member.id,
isMinor: member.isMinor,
};

householdMembersFormArray.push(memberDetails);
Expand All @@ -127,17 +131,18 @@ export class NeedsAssessmentMappingService {
return householdMembersFormArray;
}

public convertNonVerifiedHouseholdMembers(householdMembers: Array<HouseholdMember>): Array<PersonDetails> {
const householdMembersFormArray: Array<PersonDetails> = [];
public convertNonVerifiedHouseholdMembers(householdMembers: Array<HouseholdMember>): Array<PersonDetailsModel> {
const householdMembersFormArray: Array<PersonDetailsModel> = [];

for (const member of householdMembers) {
const memberDetails: PersonDetails = {
const memberDetails: PersonDetailsModel = {
firstName: member.details.firstName,
lastName: member.details.lastName,
initials: member.details.initials,
gender: member.details.gender,
dateOfBirth: member.details.dateOfBirth,
sameLastNameCheck: this.isSameLastName(member.details.lastName)
sameLastNameCheck: this.isSameLastName(member.details.lastName),
isMinor: member.isMinor,
};

householdMembersFormArray.push(memberDetails);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Injectable } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { InsuranceOption, NeedsAssessment, PersonDetails, Pet, RegistrationResult, NeedsAssessmentType, HouseholdMember, IdentifiedNeed } from 'src/app/core/api/models';
import { InsuranceOption, NeedsAssessment, Pet, RegistrationResult, NeedsAssessmentType, HouseholdMember, IdentifiedNeed } from 'src/app/core/api/models';
import { ProfileDataService } from '../profile/profile-data.service';
import { ShelterType } from 'src/app/core/services/globalConstants';
import { PersonDetailsModel } from 'src/app/core/model/profile.model';

@Injectable({ providedIn: 'root' })
export class NeedsAssessmentService {
Expand Down Expand Up @@ -90,11 +91,13 @@ export class NeedsAssessmentService {
this.mainHouseholdMembers = value;
}

public setHouseHoldMembers(members: PersonDetails[]): void {
public setHouseHoldMembers(personalDetails: PersonDetailsModel[]): void {
const householdMembersArray: Array<HouseholdMember> = [];
for (const member of members) {
for (const member of personalDetails) {
const houseHoldMember: HouseholdMember = {
id: null,
id: member.id,
isPrimaryRegistrant: member.isPrimaryRegistrant ?? false,
isMinor: member.isMinor ?? false,
details: member
};

Expand All @@ -114,7 +117,7 @@ export class NeedsAssessmentService {
return {
id: this.id,
needs: this.addNeedsToNeedsAssessment(),
householdMembers: this.addPrimaryApplicantToHousehold(),
householdMembers: this.addPrimaryApplicantToHousehold(this.householdMembers),
insurance: this.insurance,
pets: this.pets,
type: NeedsAssessmentType.Preliminary
Expand Down Expand Up @@ -153,17 +156,15 @@ export class NeedsAssessmentService {
this.householdMembers = undefined;
}

addPrimaryApplicantToHousehold(): HouseholdMember[] {
addPrimaryApplicantToHousehold(members: HouseholdMember[]): HouseholdMember[] {
const primaryMember: HouseholdMember = {
details: this.profileDataService.createProfileDTO().personalDetails,
isPrimaryRegistrant: true
};
if (this.householdMembers.length === 0) {
return [...this.householdMembers, primaryMember];
} else if (!this.householdMembers.find((member) => member.isPrimaryRegistrant === true)) {
return [...this.householdMembers, primaryMember];
if (!members.find((member) => member.isPrimaryRegistrant === true)) {
return [...members, primaryMember];
} else {
return this.householdMembers;
return [...members];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export class ReviewComponent implements OnInit {

isNoNeedSelected(form: UntypedFormGroup) {
const needsFormValue = form.value as any;
console.log("IsNoNeedSelected:", form.controls, needsFormValue);
return [
needsFormValue.requiresClothing,
needsFormValue.requiresFood,
Expand Down

0 comments on commit 7641b86

Please sign in to comment.