Skip to content

Commit

Permalink
Merge pull request #949 from bcgov/feature/ALCS-1035
Browse files Browse the repository at this point in the history
Add Notification Documents
  • Loading branch information
dhaselhan authored Sep 7, 2023
2 parents f65d4c9 + 31d23dc commit e277274
Show file tree
Hide file tree
Showing 29 changed files with 2,262 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,16 @@ <h6 *ngIf="notificationSubmission">
</cdk-step>
<cdk-step label="Optional Attachments">
<ng-container *ngTemplateOutlet="header"></ng-container>
<div *ngIf="cdkStepper.selectedIndex === steps.Attachments"></div>
<div *ngIf="cdkStepper.selectedIndex === steps.Attachments">
<app-other-attachments
[$notificationSubmission]="$notificationSubmission"
[$notificationDocuments]="$notificationDocuments"
[showErrors]="showValidationErrors"
(navigateToStep)="switchStep($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
Expand Up @@ -2,6 +2,7 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute } from '@angular/router';
import { NotificationDocumentService } from '../../../services/notification-document/notification-document.service';
import { NotificationSubmissionService } from '../../../services/notification-submission/notification-submission.service';
import { ToastService } from '../../../services/toast/toast.service';

Expand All @@ -19,6 +20,10 @@ describe('EditSubmissionComponent', () => {
provide: NotificationSubmissionService,
useValue: {},
},
{
provide: NotificationDocumentService,
useValue: {},
},
{
provide: ToastService,
useValue: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ 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 { NotificationDocumentDto } from '../../../services/notification-document/notification-document.dto';
import { NotificationDocumentService } from '../../../services/notification-document/notification-document.service';
import {
NOTIFICATION_STATUS,
NotificationSubmissionDetailedDto,
Expand All @@ -13,6 +15,7 @@ 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 { 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';
Expand All @@ -37,7 +40,7 @@ export class EditSubmissionComponent implements OnDestroy, AfterViewInit {

$destroy = new Subject<void>();
$notificationSubmission = new BehaviorSubject<NotificationSubmissionDetailedDto | undefined>(undefined);
$notificationDocuments = new BehaviorSubject<NoticeOfIntentDocumentDto[]>([]);
$notificationDocuments = new BehaviorSubject<NotificationDocumentDto[]>([]);
notificationSubmission: NotificationSubmissionDetailedDto | undefined;

steps = EditNotificationSteps;
Expand All @@ -48,9 +51,11 @@ export class EditSubmissionComponent implements OnDestroy, AfterViewInit {
@ViewChild(ParcelDetailsComponent) parcelDetailsComponent!: ParcelDetailsComponent;
@ViewChild(PrimaryContactComponent) primaryContactComponent!: PrimaryContactComponent;
@ViewChild(SelectGovernmentComponent) selectGovernmentComponent!: SelectGovernmentComponent;
@ViewChild(OtherAttachmentsComponent) otherAttachmentsComponent!: OtherAttachmentsComponent;

constructor(
private notificationSubmissionService: NotificationSubmissionService,
private notificationDocumentService: NotificationDocumentService,
private activatedRoute: ActivatedRoute,
private dialog: MatDialog,
private toastService: ToastService,
Expand Down Expand Up @@ -149,7 +154,12 @@ export class EditSubmissionComponent implements OnDestroy, AfterViewInit {
}
break;
case EditNotificationSteps.Proposal:
break;
case EditNotificationSteps.Attachments:
if (this.otherAttachmentsComponent) {
await this.otherAttachmentsComponent.onSave();
}
break;
case EditNotificationSteps.ReviewAndSubmit:
//DO NOTHING
break;
Expand All @@ -164,10 +174,6 @@ export class EditSubmissionComponent implements OnDestroy, AfterViewInit {
}
}

onChangeSubmissionType() {
//TODO
}

async onSubmit() {
//TODO
}
Expand All @@ -193,7 +199,7 @@ export class EditSubmissionComponent implements OnDestroy, AfterViewInit {
await this.router.navigateByUrl(`/home`);
}

const documents: NoticeOfIntentDocumentDto[] = []; //TODO await this.noticeOfIntentDocumentService.getByFileId(fileId);
const documents = await this.notificationDocumentService.getByFileId(fileId);
if (documents) {
this.$notificationDocuments.next(documents);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { NgxMaskPipe } from 'ngx-mask';
import { CanDeactivateGuard } from '../../../shared/guard/can-deactivate.guard';
import { SharedModule } from '../../../shared/shared.module';
import { EditSubmissionComponent } from './edit-submission.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';
Expand Down Expand Up @@ -42,6 +43,7 @@ const routes: Routes = [
TransfereeDialogComponent,
PrimaryContactComponent,
SelectGovernmentComponent,
OtherAttachmentsComponent,
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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 { NotificationDocumentDto } from '../../../services/notification-document/notification-document.dto';
import { NotificationDocumentService } from '../../../services/notification-document/notification-document.service';
import { DOCUMENT_TYPE } from '../../../shared/dto/document.dto';
import { FileHandle } from '../../../shared/file-drag-drop/drag-drop.directive';
import { StepComponent } from './step.partial';
Expand All @@ -13,7 +13,7 @@ import { StepComponent } from './step.partial';
styleUrls: [],
})
export abstract class FilesStepComponent extends StepComponent {
@Input() $noiDocuments!: BehaviorSubject<NoticeOfIntentDocumentDto[]>;
@Input() $notificationDocuments!: BehaviorSubject<NotificationDocumentDto[]>;

DOCUMENT_TYPE = DOCUMENT_TYPE;

Expand All @@ -22,7 +22,7 @@ export abstract class FilesStepComponent extends StepComponent {
protected abstract save(): Promise<void>;

protected constructor(
protected noticeOfIntentDocumentService: NoticeOfIntentDocumentService,
protected notificationDocumentService: NotificationDocumentService,
protected dialog: MatDialog
) {
super();
Expand All @@ -32,26 +32,26 @@ export abstract class FilesStepComponent extends StepComponent {
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);
await this.notificationDocumentService.attachExternalFile(this.fileId, mappedFiles, documentType);
const documents = await this.notificationDocumentService.getByFileId(this.fileId);
if (documents) {
this.$noiDocuments.next(documents);
this.$notificationDocuments.next(documents);
}
}
}

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

async openFile(uuid: string) {
const res = await this.noticeOfIntentDocumentService.openFile(uuid);
const res = await this.notificationDocumentService.openFile(uuid);
if (res) {
window.open(res.url, '_blank');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<div class="step-description">
<h2>Optional Attachments</h2>
<p>
Please upload any optional supporting documents. Where possible, provide KML/KMZ Google Earth files or GIS
shapefiles and geodatabases.
</p>
</div>
<section>
<h4>Upload Optional Attachments (Max. 100 MB per attachment)</h4>
<form [formGroup]="form">
<div class="scrollable">
<table mat-table [dataSource]="otherFiles">
<ng-container matColumnDef="type">
<th mat-header-cell *matHeaderCellDef>Type</th>
<td mat-cell *matCellDef="let element">
<mat-form-field appearance="outline">
<mat-select
[formControlName]="element.uuid + '-type'"
(valueChange)="onChangeType(element.uuid, $event)"
placeholder="Select a type"
>
<mat-option *ngFor="let type of selectableTypes" [value]="type.code">{{ type.label }}</mat-option>
</mat-select>
</mat-form-field>
<div
*ngIf="
form.controls[element.uuid + '-type']!.invalid &&
(form.controls[element.uuid + '-type']!.dirty || form.controls[element.uuid + '-type']!.touched)
"
class="field-error"
>
<mat-icon>warning</mat-icon>
<div *ngIf="form.controls[element.uuid + '-type']!.errors?.['required']">This field is required</div>
</div>
</td>
</ng-container>

<ng-container matColumnDef="description">
<th mat-header-cell *matHeaderCellDef>Description</th>
<td mat-cell *matCellDef="let element">
<mat-form-field appearance="outline">
<input
[formControlName]="element.uuid + '-description'"
(change)="onChangeDescription(element.uuid, $event)"
id="fileType"
type="text"
matInput
placeholder="Type description"
/>
</mat-form-field>
<div
*ngIf="
form.controls[element.uuid + '-description']!.invalid &&
(form.controls[element.uuid + '-description']!.dirty ||
form.controls[element.uuid + '-description']!.touched)
"
class="field-error"
>
<mat-icon>warning</mat-icon>
<div *ngIf="form.controls[element.uuid + '-description']!.errors?.['required']">
This field is required
</div>
</div>
</td>
</ng-container>

<ng-container matColumnDef="fileName">
<th mat-header-cell *matHeaderCellDef>File Name</th>
<td mat-cell *matCellDef="let element">
<a (click)="openFile(element.uuid)">{{ element.fileName }}</a>
</td>
</ng-container>

<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef>Action</th>
<td mat-cell class="actions" *matCellDef="let element">
<button (click)="onDeleteFile(element)" mat-stroked-button color="accent">Remove</button>
</td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>

<tr class="mat-row" *matNoDataRow>
<td class="no-data-text" colspan="6">No attachments</td>
</tr>
</table>
</div>
</form>
<div class="uploader">
<app-file-drag-drop (uploadFiles)="attachFile($event, null)"></app-file-drag-drop>
</div>
</section>
<div class="button-container">
<button (click)="onSaveExit()" mat-stroked-button color="accent">Save and Exit</button>
<div>
<button mat-stroked-button color="primary" (click)="onNavigateToStep(currentStep - 1)">
Previous<span class="mobile-hidden"> Step</span>
</button>
<button mat-flat-button color="primary" (click)="onNavigateToStep(currentStep + 1)">
Next<span class="mobile-hidden"> Step</span>
</button>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@use '../../../../../styles/functions' as *;
@use '../../../../../styles/colors';

section {
margin-top: rem(32);
}

.uploader {
margin-top: rem(24);
}

h4 {
margin-bottom: rem(8) !important;
}

.scrollable {
overflow-x: auto;
}

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

.mat-mdc-form-field {
width: 100%;
}

:host::ng-deep {
.mdc-text-field--invalid {
margin-top: rem(8);
}
}

.no-data-text {
text-align: center;
color: colors.$grey;
padding-top: rem(12);
}
Loading

0 comments on commit e277274

Please sign in to comment.