Skip to content

Commit

Permalink
Merge pull request #866 from bcgov/feature/ALCS-802
Browse files Browse the repository at this point in the history
Add Steps 2,3,4,7
  • Loading branch information
dhaselhan authored Aug 11, 2023
2 parents 371be39 + 0b130ed commit 1eff589
Show file tree
Hide file tree
Showing 23 changed files with 1,856 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ import { MatTableModule } from '@angular/material/table';
import { NgxMaskDirective, NgxMaskPipe } from 'ngx-mask';
import { SharedModule } from '../../../shared/shared.module';
import { EditSubmissionComponent } from './edit-submission.component';
import { LandUseComponent } from './land-use/land-use.component';
import { OtherAttachmentsComponent } from './other-attachments/other-attachments.component';
import { DeleteParcelDialogComponent } from './parcels/delete-parcel/delete-parcel-dialog.component';
import { ParcelDetailsComponent } from './parcels/parcel-details.component';
import { ParcelEntryConfirmationDialogComponent } from './parcels/parcel-entry/parcel-entry-confirmation-dialog/parcel-entry-confirmation-dialog.component';
import { ParcelEntryComponent } from './parcels/parcel-entry/parcel-entry.component';
import { PrimaryContactComponent } from './primary-contact/primary-contact.component';
import { SelectGovernmentComponent } from './select-government/select-government.component';

@NgModule({
declarations: [
Expand All @@ -21,6 +25,10 @@ import { ParcelEntryComponent } from './parcels/parcel-entry/parcel-entry.compon
ParcelEntryComponent,
ParcelEntryConfirmationDialogComponent,
DeleteParcelDialogComponent,
PrimaryContactComponent,
SelectGovernmentComponent,
LandUseComponent,
OtherAttachmentsComponent,
],
imports: [
CommonModule,
Expand All @@ -40,6 +48,10 @@ import { ParcelEntryComponent } from './parcels/parcel-entry/parcel-entry.compon
ParcelEntryComponent,
ParcelEntryConfirmationDialogComponent,
DeleteParcelDialogComponent,
PrimaryContactComponent,
SelectGovernmentComponent,
LandUseComponent,
OtherAttachmentsComponent,
],
})
export class EditSubmissionBaseModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ <h6 *ngIf="noiSubmission">Notice of Intent ID: {{ noiSubmission.fileNumber }} |
Download PDF
</button>
<div class="change-app-type-btn-wrapper">
<button mat-flat-button color="accent" (click)="onChangeSubmissionType()">
Change NOI Type
</button>
<button mat-flat-button color="accent" (click)="onChangeSubmissionType()">Change NOI Type</button>
<mat-icon
color="accent"
matTooltip="Changing application type will remove some inputs from your saved progress"
Expand All @@ -35,7 +33,7 @@ <h6 *ngIf="noiSubmission">Notice of Intent ID: {{ noiSubmission.fileNumber }} |
<ng-container *ngTemplateOutlet="header"></ng-container>
<div *ngIf="cdkStepper.selectedIndex === steps.Parcel">
<app-noi-parcel-details
[$noiSubmission]='$noiSubmission'
[$noiSubmission]="$noiSubmission"
[showErrors]="showValidationErrors"
(navigateToStep)="onBeforeSwitchStep($event)"
(componentInitialized)="onParcelDetailsInitialized()"
Expand All @@ -45,23 +43,57 @@ <h6 *ngIf="noiSubmission">Notice of Intent ID: {{ noiSubmission.fileNumber }} |
</cdk-step>
<cdk-step label="Primary Contact">
<ng-container *ngTemplateOutlet="header"></ng-container>
<div *ngIf="cdkStepper.selectedIndex === steps.PrimaryContact">Primary Contact</div>
<div *ngIf="cdkStepper.selectedIndex === steps.PrimaryContact">
<app-primary-contact
[showErrors]="showValidationErrors"
[$noiSubmission]="$noiSubmission"
[$noiDocuments]="$noiDocuments"
(navigateToStep)="onBeforeSwitchStep($event)"
(exit)="onExit()"
></app-primary-contact>
</div>
</cdk-step>
<cdk-step label="Government">
<ng-container *ngTemplateOutlet="header"></ng-container>
<div *ngIf="cdkStepper.selectedIndex === steps.Government">Select Government</div>
<div *ngIf="cdkStepper.selectedIndex === steps.Government">
<app-select-government
[showErrors]="showValidationErrors"
[$noiSubmission]="$noiSubmission"
(navigateToStep)="onBeforeSwitchStep($event)"
(exit)="onExit()"
></app-select-government>
</div>
</cdk-step>
<cdk-step label="Land Use">
<ng-container *ngTemplateOutlet="header"></ng-container>
<div *ngIf="cdkStepper.selectedIndex === steps.LandUse">Land Use</div>
<div *ngIf="cdkStepper.selectedIndex === steps.LandUse">
<app-land-use
[$noiSubmission]="$noiSubmission"
[showErrors]="showValidationErrors"
(navigateToStep)="onBeforeSwitchStep($event)"
(exit)="onExit()"
></app-land-use>
</div>
</cdk-step>
<cdk-step label="Proposal">
<ng-container *ngTemplateOutlet="header"></ng-container>
<div *ngIf="noiSubmission && cdkStepper.selectedIndex === steps.Proposal">Proposal</div>
</cdk-step>
<cdk-step label="Additional Information">
<ng-container *ngTemplateOutlet="header"></ng-container>
<div *ngIf="noiSubmission && cdkStepper.selectedIndex === steps.ExtraInfo">Additional Information</div>
</cdk-step>
<cdk-step label="Upload Attachments">
<ng-container *ngTemplateOutlet="header"></ng-container>
<div *ngIf="cdkStepper.selectedIndex === steps.Attachments">Other attachments</div>
<div *ngIf="cdkStepper.selectedIndex === steps.Attachments">
<app-other-attachments
[$noiSubmission]="$noiSubmission"
[$noiDocuments]="$noiDocuments"
[showErrors]="showValidationErrors"
(navigateToStep)="onBeforeSwitchStep($event)"
(exit)="onExit()"
></app-other-attachments>
</div>
</cdk-step>
<cdk-step label="Review & Submit">
<ng-container *ngTemplateOutlet="header"></ng-container>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute } from '@angular/router';
import { NoticeOfIntentDocumentService } from '../../../services/notice-of-intent-document/notice-of-intent-document.service';
import { NoticeOfIntentSubmissionService } from '../../../services/notice-of-intent-submission/notice-of-intent-submission.service';
import { ToastService } from '../../../services/toast/toast.service';

Expand All @@ -18,6 +19,10 @@ describe('EditSubmissionComponent', () => {
provide: NoticeOfIntentSubmissionService,
useValue: {},
},
{
provide: NoticeOfIntentDocumentService,
useValue: {},
},
{
provide: ToastService,
useValue: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import { AfterViewInit, Component, OnDestroy, ViewChild } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { BehaviorSubject, combineLatest, Observable, of, Subject, takeUntil } from 'rxjs';
import { NoticeOfIntentDocumentDto } from '../../../services/notice-of-intent-document/notice-of-intent-document.dto';
import { NoticeOfIntentDocumentService } from '../../../services/notice-of-intent-document/notice-of-intent-document.service';
import { NoticeOfIntentSubmissionDetailedDto } from '../../../services/notice-of-intent-submission/notice-of-intent-submission.dto';
import { NoticeOfIntentSubmissionService } from '../../../services/notice-of-intent-submission/notice-of-intent-submission.service';
import { ToastService } from '../../../services/toast/toast.service';
import { CustomStepperComponent } from '../../../shared/custom-stepper/custom-stepper.component';
import { OverlaySpinnerService } from '../../../shared/overlay-spinner/overlay-spinner.service';
import { scrollToElement } from '../../../shared/utils/scroll-helper';
import { EditApplicationSteps } from '../../applications/edit-submission/edit-submission.component';
import { LandUseComponent } from './land-use/land-use.component';
import { OtherAttachmentsComponent } from './other-attachments/other-attachments.component';
import { ParcelDetailsComponent } from './parcels/parcel-details.component';
import { PrimaryContactComponent } from './primary-contact/primary-contact.component';
import { SelectGovernmentComponent } from './select-government/select-government.component';

export enum EditNoiSteps {
Parcel = 0,
Expand All @@ -33,6 +38,7 @@ export class EditSubmissionComponent implements OnDestroy, AfterViewInit {

$destroy = new Subject<void>();
$noiSubmission = new BehaviorSubject<NoticeOfIntentSubmissionDetailedDto | undefined>(undefined);
$noiDocuments = new BehaviorSubject<NoticeOfIntentDocumentDto[]>([]);
noiSubmission: NoticeOfIntentSubmissionDetailedDto | undefined;

steps = EditNoiSteps;
Expand All @@ -42,9 +48,14 @@ export class EditSubmissionComponent implements OnDestroy, AfterViewInit {
@ViewChild('cdkStepper') public customStepper!: CustomStepperComponent;

@ViewChild(ParcelDetailsComponent) parcelDetailsComponent!: ParcelDetailsComponent;
@ViewChild(PrimaryContactComponent) primaryContactComponent!: PrimaryContactComponent;
@ViewChild(SelectGovernmentComponent) selectGovernmentComponent!: SelectGovernmentComponent;
@ViewChild(LandUseComponent) landUseComponent!: LandUseComponent;
@ViewChild(OtherAttachmentsComponent) otherAttachmentsComponent!: OtherAttachmentsComponent;

constructor(
private noticeOfIntentSubmissionService: NoticeOfIntentSubmissionService,
private noticeOfIntentDocumentService: NoticeOfIntentDocumentService,
private activatedRoute: ActivatedRoute,
private dialog: MatDialog,
private toastService: ToastService,
Expand Down Expand Up @@ -117,9 +128,21 @@ export class EditSubmissionComponent implements OnDestroy, AfterViewInit {

async saveSubmission(step: number) {
switch (step) {
case EditApplicationSteps.AppParcel:
case EditNoiSteps.Parcel:
await this.parcelDetailsComponent.onSave();
break;
case EditNoiSteps.PrimaryContact:
await this.primaryContactComponent.onSave();
break;
case EditNoiSteps.Government:
await this.selectGovernmentComponent.onSave();
break;
case EditNoiSteps.LandUse:
await this.landUseComponent.onSave();
break;
case EditNoiSteps.Attachments:
await this.otherAttachmentsComponent.onSave();
break;
default:
this.toastService.showErrorToast('Error updating notice of intent.');
}
Expand All @@ -140,6 +163,12 @@ export class EditSubmissionComponent implements OnDestroy, AfterViewInit {
this.overlayService.showSpinner();
this.noiSubmission = await this.noticeOfIntentSubmissionService.getByFileId(fileId);
this.fileId = fileId;

const documents = await this.noticeOfIntentDocumentService.getByFileId(fileId);
if (documents) {
this.$noiDocuments.next(documents);
}

this.$noiSubmission.next(this.noiSubmission);
this.overlayService.hideSpinner();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { Component, Input } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { BehaviorSubject } from 'rxjs';
import { NoticeOfIntentDocumentDto } from '../../../services/notice-of-intent-document/notice-of-intent-document.dto';
import { NoticeOfIntentDocumentService } from '../../../services/notice-of-intent-document/notice-of-intent-document.service';
import { DOCUMENT_TYPE } from '../../../shared/dto/document.dto';
import { FileHandle } from '../../../shared/file-drag-drop/drag-drop.directive';
import { RemoveFileConfirmationDialogComponent } from '../../applications/alcs-edit-submission/remove-file-confirmation-dialog/remove-file-confirmation-dialog.component';
import { StepComponent } from './step.partial';

@Component({
selector: 'app-file-step',
template: '<p></p>',
styleUrls: [],
})
export abstract class FilesStepComponent extends StepComponent {
@Input() $noiDocuments!: BehaviorSubject<NoticeOfIntentDocumentDto[]>;

DOCUMENT_TYPE = DOCUMENT_TYPE;

protected fileId = '';

protected abstract save(): Promise<void>;

protected constructor(
protected noticeOfIntentDocumentService: NoticeOfIntentDocumentService,
protected dialog: MatDialog
) {
super();
}

async attachFile(file: FileHandle, documentType: DOCUMENT_TYPE | null) {
if (this.fileId) {
await this.save();
const mappedFiles = file.file;
await this.noticeOfIntentDocumentService.attachExternalFile(this.fileId, mappedFiles, documentType);
const documents = await this.noticeOfIntentDocumentService.getByFileId(this.fileId);
if (documents) {
this.$noiDocuments.next(documents);
}
}
}

async onDeleteFile($event: NoticeOfIntentDocumentDto) {
if (this.draftMode) {
this.dialog
.open(RemoveFileConfirmationDialogComponent)
.beforeClosed()
.subscribe(async (didConfirm) => {
if (didConfirm) {
this.deleteFile($event);
}
});
} else {
await this.deleteFile($event);
}
}

private async deleteFile($event: NoticeOfIntentDocumentDto) {
await this.noticeOfIntentDocumentService.deleteExternalFile($event.uuid);
if (this.fileId) {
const documents = await this.noticeOfIntentDocumentService.getByFileId(this.fileId);
if (documents) {
this.$noiDocuments.next(documents);
}
}
}

async openFile(uuid: string) {
const res = await this.noticeOfIntentDocumentService.openFile(uuid);
if (res) {
window.open(res.url, '_blank');
}
}
}
Loading

0 comments on commit 1eff589

Please sign in to comment.