Skip to content

Commit

Permalink
Merge pull request #1040 from bcgov/feature/ALCS-1176
Browse files Browse the repository at this point in the history
Add Public Notification View
  • Loading branch information
dhaselhan authored Oct 10, 2023
2 parents c3cffaf + dc0c229 commit 0c98b46
Show file tree
Hide file tree
Showing 50 changed files with 1,779 additions and 119 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service';
import { CodeService } from '../../../../services/code/code.service';

import { SubmissionDetailsComponent } from './submission-details.component';
Expand All @@ -10,22 +9,16 @@ describe('SubmissionDetailsComponent', () => {
let component: SubmissionDetailsComponent;
let fixture: ComponentFixture<SubmissionDetailsComponent>;
let mockCodeService: DeepMocked<CodeService>;
let mockAppDocumentService: DeepMocked<ApplicationDocumentService>;

beforeEach(async () => {
mockCodeService = createMock();
mockAppDocumentService = createMock();

await TestBed.configureTestingModule({
providers: [
{
provide: CodeService,
useValue: mockCodeService,
},
{
provide: ApplicationDocumentService,
useValue: mockAppDocumentService,
},
],
declarations: [SubmissionDetailsComponent],
schemas: [NO_ERRORS_SCHEMA],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { Subject } from 'rxjs';
import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service';
import { PARCEL_TYPE } from '../../../../services/application-parcel/application-parcel.dto';
import { LocalGovernmentDto } from '../../../../services/code/code.dto';
import { CodeService } from '../../../../services/code/code.service';
import { PublicApplicationSubmissionDto } from '../../../../services/public/public-application.dto';
import { PublicDocumentDto, PublicOwnerDto, PublicParcelDto } from '../../../../services/public/public.dto';
import { PublicService } from '../../../../services/public/public.service';
import { OWNER_TYPE } from '../../../../shared/dto/owner.dto';

@Component({
Expand All @@ -27,7 +27,7 @@ export class SubmissionDetailsComponent implements OnInit, OnDestroy {

private localGovernments: LocalGovernmentDto[] = [];

constructor(private codeService: CodeService, private applicationDocumentService: ApplicationDocumentService) {}
constructor(private codeService: CodeService) {}

ngOnInit(): void {
this.loadGovernments();
Expand All @@ -44,11 +44,6 @@ export class SubmissionDetailsComponent implements OnInit, OnDestroy {
this.$destroy.complete();
}

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

private async loadGovernments() {
const codes = await this.codeService.loadCodes();
this.localGovernments = codes.localGovernments.sort((a, b) => (a.name > b.name ? 1 : -1));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DeepMocked } from '@golevelup/ts-jest';
import { PublicService } from '../../../../../services/public/public.service';
Expand All @@ -18,6 +19,7 @@ describe('AdditionalInformationComponent', () => {
useValue: mockPublicService,
},
],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();

fixture = TestBed.createComponent(AdditionalInformationComponent);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service';
import { CodeService } from '../../../../services/code/code.service';

import { SubmissionDetailsComponent } from './submission-details.component';
Expand All @@ -10,22 +9,16 @@ describe('SubmissionDetailsComponent', () => {
let component: SubmissionDetailsComponent;
let fixture: ComponentFixture<SubmissionDetailsComponent>;
let mockCodeService: DeepMocked<CodeService>;
let mockAppDocumentService: DeepMocked<ApplicationDocumentService>;

beforeEach(async () => {
mockCodeService = createMock();
mockAppDocumentService = createMock();

await TestBed.configureTestingModule({
providers: [
{
provide: CodeService,
useValue: mockCodeService,
},
{
provide: ApplicationDocumentService,
useValue: mockAppDocumentService,
},
],
declarations: [SubmissionDetailsComponent],
schemas: [NO_ERRORS_SCHEMA],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { Subject } from 'rxjs';
import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service';
import { PARCEL_TYPE } from '../../../../services/application-parcel/application-parcel.dto';
import { LocalGovernmentDto } from '../../../../services/code/code.dto';
import { CodeService } from '../../../../services/code/code.service';
Expand All @@ -27,7 +26,7 @@ export class SubmissionDetailsComponent implements OnInit, OnDestroy {

private localGovernments: LocalGovernmentDto[] = [];

constructor(private codeService: CodeService, private applicationDocumentService: ApplicationDocumentService) {}
constructor(private codeService: CodeService) {}

ngOnInit(): void {
this.loadGovernments();
Expand All @@ -44,11 +43,6 @@ export class SubmissionDetailsComponent implements OnInit, OnDestroy {
this.$destroy.complete();
}

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

private async loadGovernments() {
const codes = await this.codeService.loadCodes();
this.localGovernments = codes.localGovernments.sort((a, b) => (a.name > b.name ? 1 : -1));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div>
<div class="header">
<h3>ALC Review and Decision</h3>
</div>
<div>
<app-submission-documents [documents]="documents"></app-submission-documents>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use '../../../../../styles/functions' as *;
@use '../../../../../styles/colors';

.warning {
background-color: rgba(colors.$accent-color-light, 0.5);
padding: rem(16);
margin-bottom: rem(24);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { PublicAlcReviewComponent } from './alc-review.component';

describe('PublicAlcReviewComponent', () => {
let component: PublicAlcReviewComponent;
let fixture: ComponentFixture<PublicAlcReviewComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
providers: [],
declarations: [PublicAlcReviewComponent],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();

fixture = TestBed.createComponent(PublicAlcReviewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component, Input } from '@angular/core';
import { ApplicationPortalDecisionDto } from '../../../../services/application-decision/application-decision.dto';
import { PublicNoticeOfIntentSubmissionDto } from '../../../../services/public/public-notice-of-intent.dto';
import { PublicNotificationSubmissionDto } from '../../../../services/public/public-notification.dto';
import { PublicDocumentDto } from '../../../../services/public/public.dto';

@Component({
selector: 'app-public-alc-review',
templateUrl: './alc-review.component.html',
styleUrls: ['./alc-review.component.scss'],
})
export class PublicAlcReviewComponent {
@Input() documents!: PublicDocumentDto[];

constructor() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<h4>Application Documents</h4>
<div class="table-container">
<table mat-table [dataSource]="dataSource" matSort class="mat-elevation-z3 documents">
<ng-container matColumnDef="type">
<th mat-header-cell *matHeaderCellDef mat-sort-header sortActionDescription="Sort by type">Type</th>
<td mat-cell *matCellDef="let element">
{{ element.type?.label }}
</td>
</ng-container>

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

<ng-container matColumnDef="source">
<th mat-header-cell *matHeaderCellDef mat-sort-header sortActionDescription="Sort by source">Source</th>
<td mat-cell *matCellDef="let element">{{ element.source }}</td>
</ng-container>

<ng-container matColumnDef="uploadedAt">
<th mat-header-cell *matHeaderCellDef mat-sort-header sortActionDescription="Sort by date">Upload Date</th>
<td mat-cell *matCellDef="let element">{{ element.uploadedAt | date }}</td>
</ng-container>

<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef>Actions</th>
<td mat-cell *matCellDef="let element">
<button mat-icon-button (click)="downloadFile(element.uuid)">
<mat-icon>file_download</mat-icon>
</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="text-center" colspan="6">Documents will be visible here once provided by ALC</td>
</tr>
</table>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@use '../../../../../../styles/colors';
@use '../../../../../../styles/functions' as *;

.header {
display: flex;
justify-content: space-between;
}

.table-container {
margin: rem(4);
overflow-x: auto;
}

.documents {
margin-top: rem(12);
}

.mat-mdc-no-data-row {
height: rem(56);
color: colors.$grey-dark;
}

a {
word-break: break-all;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { PublicService } from '../../../../../services/public/public.service';

import { PublicSubmissionDocumentsComponent } from './submission-documents.component';

describe('PublicSubmissionDocumentsComponent', () => {
let component: PublicSubmissionDocumentsComponent;
let fixture: ComponentFixture<PublicSubmissionDocumentsComponent>;
let mockPublicService: DeepMocked<PublicService>;

beforeEach(async () => {
mockPublicService = createMock();

await TestBed.configureTestingModule({
declarations: [PublicSubmissionDocumentsComponent],
providers: [
{
provide: PublicService,
useValue: mockPublicService,
},
],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();

fixture = TestBed.createComponent(PublicSubmissionDocumentsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { Subject } from 'rxjs';
import { PublicNoticeOfIntentSubmissionDto } from '../../../../../services/public/public-notice-of-intent.dto';
import { PublicDocumentDto } from '../../../../../services/public/public.dto';
import { PublicService } from '../../../../../services/public/public.service';

@Component({
selector: 'app-submission-documents',
templateUrl: './submission-documents.component.html',
styleUrls: ['./submission-documents.component.scss'],
})
export class PublicSubmissionDocumentsComponent implements OnInit, OnDestroy {
private $destroy = new Subject<void>();

displayedColumns: string[] = ['type', 'fileName', 'source', 'uploadedAt', 'actions'];
@Input() documents!: PublicDocumentDto[];
@Input() submission!: PublicNoticeOfIntentSubmissionDto;

@ViewChild(MatSort) sort!: MatSort;
dataSource: MatTableDataSource<PublicDocumentDto> = new MatTableDataSource<PublicDocumentDto>();

constructor(private publicService: PublicService) {}

ngOnInit(): void {
this.dataSource = new MatTableDataSource(this.documents);
}

async openFile(uuid: string) {
const res = await this.publicService.getNoticeOfIntentOpenFileUrl(this.submission.fileNumber, uuid);
if (res) {
window.open(res.url, '_blank');
}
}

async downloadFile(uuid: string) {
const res = await this.publicService.getNoticeOfIntentOpenFileUrl(this.submission.fileNumber, uuid);
if (res) {
const downloadLink = document.createElement('a');
downloadLink.href = res.url;
downloadLink.download = res.url.split('/').pop()!;
if (window.webkitURL == null) {
downloadLink.onclick = (event: MouseEvent) => document.body.removeChild(<Node>event.target);
downloadLink.style.display = 'none';
document.body.appendChild(downloadLink);
}
downloadLink.click();
}
}

ngOnDestroy(): void {
this.$destroy.next();
this.$destroy.complete();
}
}
Loading

0 comments on commit 0c98b46

Please sign in to comment.