Skip to content

Commit

Permalink
Merge pull request #1950 from bcgov/feature/ALCS-1156-QA-1
Browse files Browse the repository at this point in the history
1156 QA fixes
  • Loading branch information
trslater authored Nov 5, 2024
2 parents 023cb6b + 2d88d5f commit 5434bdd
Show file tree
Hide file tree
Showing 12 changed files with 210 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ section {
width: 100%;
}

.mat-mdc-table .mdc-data-table__row {
height: rem(75);
}

.info-banner {
background-color: rgba(colors.$secondary-color-light, 0.5);
padding: rem(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@ export class PfrsProposalComponent extends FilesStepComponent implements OnInit,
}
this.structuresSource = new MatTableDataSource(this.proposedStructures);

this.updateStructureTypeFields();
if (this.showErrors) {
this.form.markAllAsTouched();
this.structuresForm.markAllAsTouched();
}
}
});
Expand Down Expand Up @@ -244,7 +246,7 @@ export class PfrsProposalComponent extends FilesStepComponent implements OnInit,
}

protected async save() {
if (this.fileId && (this.form.dirty || this.areComponentsDirty)) {
if (this.fileId && (this.form.dirty || this.structuresForm.dirty || this.areComponentsDirty)) {
const isNewStructure = this.isNewStructure.getRawValue();
const isFollowUp = this.isFollowUp.getRawValue();
const followUpIDs = this.followUpIDs.getRawValue();
Expand Down Expand Up @@ -410,6 +412,8 @@ export class PfrsProposalComponent extends FilesStepComponent implements OnInit,
return;
}

this.structuresSource = new MatTableDataSource(this.proposedStructures);

if (this.hasInput(structure.type)) {
this.confirmationDialogService
.openDialog({
Expand Down Expand Up @@ -474,14 +478,67 @@ export class PfrsProposalComponent extends FilesStepComponent implements OnInit,
if (structure.type !== null && this.structureTypeCounts[structure.type] > 0) {
this.structureTypeCounts[structure.type]--;
}

this.structureTypeCounts[newType]++;

structure.type = newType;

this.updateStructureTypeFields();
this.form.markAsDirty();
}

updateStructureTypeFields() {
// Remove

if (this.structureTypeCounts[STRUCTURE_TYPES.FARM_STRUCTURE] === 0) {
this.soilStructureFarmUseReason.removeValidators([Validators.required]);
this.soilStructureFarmUseReason.reset();
this.soilAgriParcelActivity.removeValidators([Validators.required]);
this.soilAgriParcelActivity.reset();
}

if (
this.structureTypeCounts[STRUCTURE_TYPES.PRINCIPAL_RESIDENCE] === 0 &&
this.structureTypeCounts[STRUCTURE_TYPES.ADDITIONAL_RESIDENCE] === 0 &&
this.structureTypeCounts[STRUCTURE_TYPES.ACCESSORY_STRUCTURE] === 0
) {
this.soilStructureResidentialUseReason.reset();
this.soilStructureResidentialUseReason.removeValidators([Validators.required]);
}

if (this.structureTypeCounts[STRUCTURE_TYPES.OTHER_STRUCTURE] === 0) {
this.soilStructureResidentialAccessoryUseReason.reset();
this.soilStructureResidentialAccessoryUseReason.removeValidators([Validators.required]);
}

if (this.structureTypeCounts[STRUCTURE_TYPES.ACCESSORY_STRUCTURE] === 0) {
this.soilStructureOtherUseReason.reset();
this.soilStructureOtherUseReason.removeValidators([Validators.required]);
}

// Add

if (this.structureTypeCounts[STRUCTURE_TYPES.FARM_STRUCTURE] > 0) {
this.soilStructureFarmUseReason.setValidators([Validators.required]);
this.soilAgriParcelActivity.setValidators([Validators.required]);
}

if (
this.structureTypeCounts[STRUCTURE_TYPES.PRINCIPAL_RESIDENCE] > 0 ||
this.structureTypeCounts[STRUCTURE_TYPES.ADDITIONAL_RESIDENCE] > 0 ||
this.structureTypeCounts[STRUCTURE_TYPES.ACCESSORY_STRUCTURE] > 0
) {
this.soilStructureResidentialUseReason.setValidators([Validators.required]);
}

if (this.structureTypeCounts[STRUCTURE_TYPES.ACCESSORY_STRUCTURE] > 0) {
this.soilStructureResidentialAccessoryUseReason.setValidators([Validators.required]);
}

if (this.structureTypeCounts[STRUCTURE_TYPES.OTHER_STRUCTURE] > 0) {
this.soilStructureOtherUseReason.setValidators([Validators.required]);
}
}

onStructureAdd() {
if (this.isMobile) {
const dialog = this.dialog.open(AddStructureDialogComponent, {
Expand Down Expand Up @@ -523,10 +580,16 @@ export class PfrsProposalComponent extends FilesStepComponent implements OnInit,
if (type) {
this.structureTypeCounts[type]++;
}

this.structuresForm.markAsDirty();
}

isWarning(index: number, item: ProposedStructure): boolean {
return item.type === STRUCTURE_TYPES.PRINCIPAL_RESIDENCE || item.type === STRUCTURE_TYPES.ADDITIONAL_RESIDENCE;
return (
item.type === STRUCTURE_TYPES.PRINCIPAL_RESIDENCE ||
item.type === STRUCTURE_TYPES.ADDITIONAL_RESIDENCE ||
item.type === STRUCTURE_TYPES.ACCESSORY_STRUCTURE
);
}

onStructureRemove(id: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ section {
width: 100%;
}

.mat-mdc-table .mdc-data-table__row {
height: rem(75);
}

.info-banner {
background-color: rgba(colors.$secondary-color-light, 0.5);
padding: rem(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ export class PofoProposalComponent extends FilesStepComponent implements OnInit,
}
this.structuresSource = new MatTableDataSource(this.proposedStructures);

this.updateStructureTypeFields();
if (this.showErrors) {
this.form.markAllAsTouched();
this.structuresForm.markAllAsTouched();
}
}
});
Expand Down Expand Up @@ -199,7 +201,7 @@ export class PofoProposalComponent extends FilesStepComponent implements OnInit,
}

protected async save() {
if (this.fileId && (this.form.dirty || this.areComponentsDirty)) {
if (this.fileId && (this.form.dirty || this.structuresForm.dirty || this.areComponentsDirty)) {
const isNewStructure = this.isNewStructure.getRawValue();
const isFollowUp = this.isFollowUp.getRawValue();
const soilFollowUpIDs = this.followUpIDs.getRawValue();
Expand Down Expand Up @@ -336,6 +338,8 @@ export class PofoProposalComponent extends FilesStepComponent implements OnInit,
return;
}

this.structuresSource = new MatTableDataSource(this.proposedStructures);

if (this.hasInput(structure.type)) {
this.confirmationDialogService
.openDialog({
Expand Down Expand Up @@ -400,14 +404,67 @@ export class PofoProposalComponent extends FilesStepComponent implements OnInit,
if (structure.type !== null && this.structureTypeCounts[structure.type] > 0) {
this.structureTypeCounts[structure.type]--;
}

this.structureTypeCounts[newType]++;

structure.type = newType;

this.updateStructureTypeFields();
this.form.markAsDirty();
}

updateStructureTypeFields() {
// Remove

if (this.structureTypeCounts[STRUCTURE_TYPES.FARM_STRUCTURE] === 0) {
this.soilStructureFarmUseReason.removeValidators([Validators.required]);
this.soilStructureFarmUseReason.reset();
this.soilAgriParcelActivity.removeValidators([Validators.required]);
this.soilAgriParcelActivity.reset();
}

if (
this.structureTypeCounts[STRUCTURE_TYPES.PRINCIPAL_RESIDENCE] === 0 &&
this.structureTypeCounts[STRUCTURE_TYPES.ADDITIONAL_RESIDENCE] === 0 &&
this.structureTypeCounts[STRUCTURE_TYPES.ACCESSORY_STRUCTURE] === 0
) {
this.soilStructureResidentialUseReason.reset();
this.soilStructureResidentialUseReason.removeValidators([Validators.required]);
}

if (this.structureTypeCounts[STRUCTURE_TYPES.OTHER_STRUCTURE] === 0) {
this.soilStructureResidentialAccessoryUseReason.reset();
this.soilStructureResidentialAccessoryUseReason.removeValidators([Validators.required]);
}

if (this.structureTypeCounts[STRUCTURE_TYPES.ACCESSORY_STRUCTURE] === 0) {
this.soilStructureOtherUseReason.reset();
this.soilStructureOtherUseReason.removeValidators([Validators.required]);
}

// Add

if (this.structureTypeCounts[STRUCTURE_TYPES.FARM_STRUCTURE] > 0) {
this.soilStructureFarmUseReason.setValidators([Validators.required]);
this.soilAgriParcelActivity.setValidators([Validators.required]);
}

if (
this.structureTypeCounts[STRUCTURE_TYPES.PRINCIPAL_RESIDENCE] > 0 ||
this.structureTypeCounts[STRUCTURE_TYPES.ADDITIONAL_RESIDENCE] > 0 ||
this.structureTypeCounts[STRUCTURE_TYPES.ACCESSORY_STRUCTURE] > 0
) {
this.soilStructureResidentialUseReason.setValidators([Validators.required]);
}

if (this.structureTypeCounts[STRUCTURE_TYPES.ACCESSORY_STRUCTURE] > 0) {
this.soilStructureResidentialAccessoryUseReason.setValidators([Validators.required]);
}

if (this.structureTypeCounts[STRUCTURE_TYPES.OTHER_STRUCTURE] > 0) {
this.soilStructureOtherUseReason.setValidators([Validators.required]);
}
}

onStructureAdd() {
if (this.isMobile) {
const dialog = this.dialog.open(AddStructureDialogComponent, {
Expand Down Expand Up @@ -449,10 +506,16 @@ export class PofoProposalComponent extends FilesStepComponent implements OnInit,
if (type) {
this.structureTypeCounts[type]++;
}

this.structuresForm.markAsDirty();
}

isWarning(index: number, item: ProposedStructure): boolean {
return item.type === STRUCTURE_TYPES.PRINCIPAL_RESIDENCE || item.type === STRUCTURE_TYPES.ADDITIONAL_RESIDENCE;
return (
item.type === STRUCTURE_TYPES.PRINCIPAL_RESIDENCE ||
item.type === STRUCTURE_TYPES.ADDITIONAL_RESIDENCE ||
item.type === STRUCTURE_TYPES.ACCESSORY_STRUCTURE
);
}

onStructureRemove(id: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ section {
width: 100%;
}

.mat-mdc-table .mdc-data-table__row {
height: rem(75);
}

.info-banner {
background-color: rgba(colors.$secondary-color-light, 0.5);
padding: rem(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ export class RosoProposalComponent extends FilesStepComponent implements OnInit,
}
this.structuresSource = new MatTableDataSource(this.proposedStructures);

this.updateStructureTypeFields();
if (this.showErrors) {
this.form.markAllAsTouched();
this.structuresForm.markAllAsTouched();
}
}
});
Expand Down Expand Up @@ -196,7 +198,7 @@ export class RosoProposalComponent extends FilesStepComponent implements OnInit,
}

protected async save() {
if (this.fileId && (this.form.dirty || this.areComponentsDirty)) {
if (this.fileId && (this.form.dirty || this.structuresForm.dirty || this.areComponentsDirty)) {
const isNewStructure = this.isNewStructure.getRawValue();
const isNOIFollowUp = this.isFollowUp.getRawValue();
const soilFollowUpIDs = this.followUpIds.getRawValue();
Expand Down Expand Up @@ -360,10 +362,16 @@ export class RosoProposalComponent extends FilesStepComponent implements OnInit,
if (type) {
this.structureTypeCounts[type]++;
}

this.structuresForm.markAsDirty();
}

isWarning(index: number, item: ProposedStructure): boolean {
return item.type === STRUCTURE_TYPES.PRINCIPAL_RESIDENCE || item.type === STRUCTURE_TYPES.ADDITIONAL_RESIDENCE;
return (
item.type === STRUCTURE_TYPES.PRINCIPAL_RESIDENCE ||
item.type === STRUCTURE_TYPES.ADDITIONAL_RESIDENCE ||
item.type === STRUCTURE_TYPES.ACCESSORY_STRUCTURE
);
}

onStructureRemove(id: string) {
Expand Down Expand Up @@ -445,6 +453,8 @@ export class RosoProposalComponent extends FilesStepComponent implements OnInit,
return;
}

this.structuresSource = new MatTableDataSource(this.proposedStructures);

if (this.hasInput(structure.type)) {
this.confirmationDialogService
.openDialog({
Expand Down Expand Up @@ -509,14 +519,67 @@ export class RosoProposalComponent extends FilesStepComponent implements OnInit,
if (structure.type !== null && this.structureTypeCounts[structure.type] > 0) {
this.structureTypeCounts[structure.type]--;
}

this.structureTypeCounts[newType]++;

structure.type = newType;

this.updateStructureTypeFields();
this.form.markAsDirty();
}

updateStructureTypeFields() {
// Remove

if (this.structureTypeCounts[STRUCTURE_TYPES.FARM_STRUCTURE] === 0) {
this.soilStructureFarmUseReason.removeValidators([Validators.required]);
this.soilStructureFarmUseReason.reset();
this.soilAgriParcelActivity.removeValidators([Validators.required]);
this.soilAgriParcelActivity.reset();
}

if (
this.structureTypeCounts[STRUCTURE_TYPES.PRINCIPAL_RESIDENCE] === 0 &&
this.structureTypeCounts[STRUCTURE_TYPES.ADDITIONAL_RESIDENCE] === 0 &&
this.structureTypeCounts[STRUCTURE_TYPES.ACCESSORY_STRUCTURE] === 0
) {
this.soilStructureResidentialUseReason.reset();
this.soilStructureResidentialUseReason.removeValidators([Validators.required]);
}

if (this.structureTypeCounts[STRUCTURE_TYPES.OTHER_STRUCTURE] === 0) {
this.soilStructureResidentialAccessoryUseReason.reset();
this.soilStructureResidentialAccessoryUseReason.removeValidators([Validators.required]);
}

if (this.structureTypeCounts[STRUCTURE_TYPES.ACCESSORY_STRUCTURE] === 0) {
this.soilStructureOtherUseReason.reset();
this.soilStructureOtherUseReason.removeValidators([Validators.required]);
}

// Add

if (this.structureTypeCounts[STRUCTURE_TYPES.FARM_STRUCTURE] > 0) {
this.soilStructureFarmUseReason.setValidators([Validators.required]);
this.soilAgriParcelActivity.setValidators([Validators.required]);
}

if (
this.structureTypeCounts[STRUCTURE_TYPES.PRINCIPAL_RESIDENCE] > 0 ||
this.structureTypeCounts[STRUCTURE_TYPES.ADDITIONAL_RESIDENCE] > 0 ||
this.structureTypeCounts[STRUCTURE_TYPES.ACCESSORY_STRUCTURE] > 0
) {
this.soilStructureResidentialUseReason.setValidators([Validators.required]);
}

if (this.structureTypeCounts[STRUCTURE_TYPES.ACCESSORY_STRUCTURE] > 0) {
this.soilStructureResidentialAccessoryUseReason.setValidators([Validators.required]);
}

if (this.structureTypeCounts[STRUCTURE_TYPES.OTHER_STRUCTURE] > 0) {
this.soilStructureOtherUseReason.setValidators([Validators.required]);
}
}

markDirty() {
this.areComponentsDirty = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,6 @@
</div>
</ng-container>

<ng-container *ngIf="applicationSubmission.soilIsNewStructure === true">
<div class="subheading2 grid-1">Detailed Building Plan(s)</div>
<div class="grid-double multiple-documents">
<a *ngFor="let file of buildingPlans" (click)="openFile(file)">
{{ file.fileName }}
</a>
<app-no-data *ngIf="buildingPlans.length === 0"></app-no-data>
</div>
</ng-container>

<ng-container *ngIf="applicationSubmission.soilIsNewStructure === false">
<div class="subheading2 grid-1">Is your proposal for aggregate extraction or placer mining?</div>
<div class="grid-double">
Expand Down
Loading

0 comments on commit 5434bdd

Please sign in to comment.