Skip to content

Commit 8684d06

Browse files
authored
Responsible Parties QA III (#2604)
* fix: addressed qa changes part III * fix: fix submitter fields to resolve save to draft bug
1 parent 5a2bfe5 commit 8684d06

File tree

5 files changed

+51
-18
lines changed

5 files changed

+51
-18
lines changed

alcs-frontend/src/app/features/compliance-and-enforcement/details/responsible-parties/responsible-parties.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,18 @@ export class ResponsiblePartiesDetailsComponent implements OnInit, OnDestroy {
261261
}
262262

263263
async saveResponsibleParties() {
264-
// Force immediate save of all form changes in the responsible parties component ( this bypasses the debounce and saves immediately )
264+
// Force immediate save of all form changes in the responsible parties component
265265
if (this.responsiblePartiesComponent) {
266-
await this.responsiblePartiesComponent.saveAllForms();
266+
const success = await this.responsiblePartiesComponent.saveAllForms();
267+
268+
if (!success) {
269+
// Validation failed - don't navigate, show error
270+
this.toastService.showErrorToast('Please fill in all required fields before saving');
271+
return;
272+
}
267273
}
268274

269-
// Navigate immediately
275+
// Navigate only if validation passed
270276
this.router.navigate(['..'], { relativeTo: this.route });
271277

272278
// Show success toast after navigation

alcs-frontend/src/app/features/compliance-and-enforcement/draft/draft.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export class DraftComponent implements OnInit, AfterViewInit, OnDestroy {
321321
if (submitterUuid) {
322322
await firstValueFrom(this.complianceAndEnforcementSubmitterService.update(submitterUuid, submitterUpdate));
323323
} else {
324-
this.submitter = await firstValueFrom(this.complianceAndEnforcementSubmitterService.create(submitterUpdate));
324+
this.submitter = await firstValueFrom(this.complianceAndEnforcementSubmitterService.create({ ...submitterUpdate, fileUuid: this.file.uuid }));
325325
}
326326

327327
if (this.property?.uuid) {

alcs-frontend/src/app/features/compliance-and-enforcement/responsible-parties/responsible-parties.component.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,20 @@ export class ResponsiblePartiesComponent implements OnInit, OnDestroy {
508508
this.showRequiredError = true;
509509
}
510510

511-
async saveAllForms(): Promise<void> {
511+
async saveAllForms(): Promise<boolean> {
512+
// Mark all forms as touched to show validation errors
513+
for (let i = 0; i < this.form.length; i++) {
514+
const partyForm = this.form.at(i);
515+
partyForm.markAllAsTouched();
516+
}
517+
518+
// Check if all forms are valid
519+
const allFormsValid = this.form.controls.every(form => form.valid);
520+
521+
if (!allFormsValid) {
522+
return false; // Validation failed
523+
}
524+
512525
// Force immediate save of all form changes, bypassing debounce
513526
const savePromises: Promise<void>[] = [];
514527

@@ -524,6 +537,7 @@ export class ResponsiblePartiesComponent implements OnInit, OnDestroy {
524537

525538
// Wait for all saves to complete
526539
await Promise.all(savePromises);
540+
return true; // Success
527541
}
528542

529543
ngOnDestroy(): void {

alcs-frontend/src/app/services/compliance-and-enforcement/responsible-parties/responsible-parties.service.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { HttpClient, HttpParams } from '@angular/common/http';
22
import { Injectable } from '@angular/core';
33
import { firstValueFrom, Observable } from 'rxjs';
44
import { environment } from '../../../../environments/environment';
5+
import { OwnerDto, SubmissionOwnersDto } from '../../../shared/document-upload-dialog/document-upload-dialog.dto';
56
import {
6-
ResponsiblePartyDto,
77
CreateResponsiblePartyDto,
8-
UpdateResponsiblePartyDto,
98
FOIPPACategory,
9+
ResponsiblePartyDto,
1010
ResponsiblePartyType,
11+
UpdateResponsiblePartyDto,
1112
} from './responsible-parties.dto';
12-
import { OwnerDto, SubmissionOwnersDto } from '../../../shared/document-upload-dialog/document-upload-dialog.dto';
1313

1414
@Injectable({
1515
providedIn: 'root',
@@ -24,16 +24,20 @@ export class ResponsiblePartiesService {
2424
}
2525

2626
async fetchSubmission(fileNumber: string): Promise<SubmissionOwnersDto> {
27-
const responsibleParties = await this.fetchByFileNumber(fileNumber, ResponsiblePartyType.PROPERTY_OWNER);
28-
const responsiblePartiesOwners: OwnerDto[] = responsibleParties.map((party) => ({
29-
...party,
30-
displayName: '',
31-
type: {
32-
label: '',
33-
code: party.foippaCategory === FOIPPACategory.ORGANIZATION ? 'ORGZ' : '',
34-
description: '',
35-
},
36-
}));
27+
const responsibleParties = await this.fetchByFileNumber(fileNumber);
28+
const responsiblePartiesOwners: OwnerDto[] = responsibleParties
29+
.filter((party) => party.foippaCategory === FOIPPACategory.ORGANIZATION)
30+
.map((party) => ({
31+
uuid: party.uuid,
32+
displayName: party.organizationName || '',
33+
organizationName: party.organizationName,
34+
corporateSummaryUuid: undefined,
35+
type: {
36+
label: '',
37+
code: party.foippaCategory === FOIPPACategory.ORGANIZATION ? 'ORGZ' : '',
38+
description: '',
39+
},
40+
}));
3741

3842
return {
3943
owners: responsiblePartiesOwners,

alcs-frontend/src/app/shared/document-upload-dialog/document-upload-dialog.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ export class DocumentUploadDialogComponent implements OnInit, OnDestroy {
261261

262262
async prepareCertificateOfTitleUpload(uuid?: string) {
263263
this.source.setValue(DOCUMENT_SOURCE.APPLICANT);
264+
265+
// If fixedParcel is provided, use it and don't require validation
266+
if (this.data.fixedParcel) {
267+
this.parcelId.setValue(this.data.fixedParcel.uuid);
268+
this.parcelId.clearValidators();
269+
this.parcelId.updateValueAndValidity();
270+
return;
271+
}
272+
264273
this.parcelId.setValidators([Validators.required]);
265274
this.parcelId.updateValueAndValidity();
266275

0 commit comments

Comments
 (0)