From b8936744e9d1e048de080f5669b3ee0beeb9267c Mon Sep 17 00:00:00 2001 From: aastha Date: Fri, 13 Oct 2023 10:05:16 +0530 Subject: [PATCH] fix: Add back validation method --- .../add-edit-advance-request.page.ts | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/app/fyle/add-edit-advance-request/add-edit-advance-request.page.ts b/src/app/fyle/add-edit-advance-request/add-edit-advance-request.page.ts index 1f5931ef20..768c1aa318 100644 --- a/src/app/fyle/add-edit-advance-request/add-edit-advance-request.page.ts +++ b/src/app/fyle/add-edit-advance-request/add-edit-advance-request.page.ts @@ -187,32 +187,48 @@ export class AddEditAdvanceRequestPage implements OnInit { return this.saveDraftAdvanceRequest(advanceRequest); } } + showFormValidationErrors(): void { + this.fg.markAllAsTouched(); + const formContainer = this.formContainer.nativeElement as HTMLElement; + if (formContainer) { + const invalidElement = formContainer.querySelector('.ng-invalid'); + if (invalidElement) { + invalidElement.scrollIntoView({ + behavior: 'smooth', + }); + } + } + } - async showAdvanceSummaryPopover() { + async showAdvanceSummaryPopover(): Promise { if (this.fg.valid) { const advanceSummaryPopover = await this.popoverController.create({ - component: DraftAdvanceSummaryComponent, - cssClass: 'dialog-popover', + component: PopupAlertComponent, + componentProps: { + title: 'Review', + message: + 'This action will save a draft advance request and will not be submitted to your approvers directly. You need to explicitly submit a draft advance request.', + primaryCta: { + text: 'Finish', + action: 'continue', + }, + secondaryCta: { + text: 'Cancel', + action: 'cancel', + }, + }, + cssClass: 'pop-up-in-center', }); await advanceSummaryPopover.present(); - const { data } = await advanceSummaryPopover.onWillDismiss(); + const { data } = await advanceSummaryPopover.onWillDismiss<{ action: string }>(); - if (data && data.saveAdvanceRequest) { + if (data && data.action === 'continue') { this.save('Draft'); } } else { - this.fg.markAllAsTouched(); - const formContainer = this.formContainer.nativeElement as HTMLElement; - if (formContainer) { - const invalidElement = formContainer.querySelector('.ng-invalid'); - if (invalidElement) { - invalidElement.scrollIntoView({ - behavior: 'smooth', - }); - } - } + this.showFormValidationErrors(); } }