From d1c228174b33c2806423876c88bc86c0f6cf8da8 Mon Sep 17 00:00:00 2001 From: Tristan Slater <1631008+trslater@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:25:56 -0800 Subject: [PATCH] Apply last PFRS change to POFO/ROSO --- .../pofo-proposal/pofo-proposal.component.ts | 17 +++++++++-------- .../roso-proposal/roso-proposal.component.ts | 7 ++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/portal-frontend/src/app/features/applications/edit-submission/proposal/pofo-proposal/pofo-proposal.component.ts b/portal-frontend/src/app/features/applications/edit-submission/proposal/pofo-proposal/pofo-proposal.component.ts index b13720206c..a9635c9777 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/proposal/pofo-proposal/pofo-proposal.component.ts +++ b/portal-frontend/src/app/features/applications/edit-submission/proposal/pofo-proposal/pofo-proposal.component.ts @@ -347,7 +347,7 @@ export class PofoProposalComponent extends FilesStepComponent implements OnInit, this.structuresSource = new MatTableDataSource(this.proposedStructures); - if (this.hasInput(structure.type, newType)) { + if (this.structureChangeRequiresConfirmation(structure.type, newType)) { this.confirmationDialogService .openDialog({ title: 'Change Structure Type', @@ -382,7 +382,7 @@ export class PofoProposalComponent extends FilesStepComponent implements OnInit, this.form.markAsDirty(); } - private hasInput(oldType: STRUCTURE_TYPES | null, newType: STRUCTURE_TYPES | null) { + private structureChangeRequiresConfirmation(oldType: STRUCTURE_TYPES | null, newType: STRUCTURE_TYPES | null) { const residentialTypes = [ STRUCTURE_TYPES.PRINCIPAL_RESIDENCE, STRUCTURE_TYPES.ADDITIONAL_RESIDENCE, @@ -392,14 +392,15 @@ export class PofoProposalComponent extends FilesStepComponent implements OnInit, const changingToResidentialType = newType && residentialTypes.includes(newType); return !!( - (oldType && + oldType !== newType && + ((oldType && oldType === STRUCTURE_TYPES.FARM_STRUCTURE && (this.soilAgriParcelActivity.value || this.soilStructureFarmUseReason.value)) || - (changingFromResidentialType && !changingToResidentialType && this.soilStructureResidentialUseReason.value) || - (oldType && - oldType === STRUCTURE_TYPES.ACCESSORY_STRUCTURE && - this.soilStructureResidentialAccessoryUseReason.value) || - (oldType && oldType === STRUCTURE_TYPES.OTHER_STRUCTURE && this.soilStructureOtherUseReason.value) + (changingFromResidentialType && !changingToResidentialType && this.soilStructureResidentialUseReason.value) || + (oldType && + oldType === STRUCTURE_TYPES.ACCESSORY_STRUCTURE && + this.soilStructureResidentialAccessoryUseReason.value) || + (oldType && oldType === STRUCTURE_TYPES.OTHER_STRUCTURE && this.soilStructureOtherUseReason.value)) ); } diff --git a/portal-frontend/src/app/features/applications/edit-submission/proposal/roso-proposal/roso-proposal.component.ts b/portal-frontend/src/app/features/applications/edit-submission/proposal/roso-proposal/roso-proposal.component.ts index 40a77a683e..3bea4eb978 100644 --- a/portal-frontend/src/app/features/applications/edit-submission/proposal/roso-proposal/roso-proposal.component.ts +++ b/portal-frontend/src/app/features/applications/edit-submission/proposal/roso-proposal/roso-proposal.component.ts @@ -456,7 +456,7 @@ export class RosoProposalComponent extends FilesStepComponent implements OnInit, this.structuresSource = new MatTableDataSource(this.proposedStructures); - if (this.hasInput(structure.type, newType)) { + if (this.structureChangeRequiresConfirmation(structure.type, newType)) { this.confirmationDialogService .openDialog({ title: 'Change Structure Type', @@ -491,7 +491,7 @@ export class RosoProposalComponent extends FilesStepComponent implements OnInit, this.form.markAsDirty(); } - private hasInput(oldType: STRUCTURE_TYPES | null, newType: STRUCTURE_TYPES | null) { + private structureChangeRequiresConfirmation(oldType: STRUCTURE_TYPES | null, newType: STRUCTURE_TYPES | null) { const residentialTypes = [ STRUCTURE_TYPES.PRINCIPAL_RESIDENCE, STRUCTURE_TYPES.ADDITIONAL_RESIDENCE, @@ -501,7 +501,8 @@ export class RosoProposalComponent extends FilesStepComponent implements OnInit, const changingToResidentialType = newType && residentialTypes.includes(newType); return !!( - (oldType && + (oldType !== newType && + oldType && oldType === STRUCTURE_TYPES.FARM_STRUCTURE && (this.soilAgriParcelActivity.value || this.soilStructureFarmUseReason.value)) || (changingFromResidentialType && !changingToResidentialType && this.soilStructureResidentialUseReason.value) ||