Skip to content

Commit

Permalink
Finish Public App View
Browse files Browse the repository at this point in the history
* Add ALC Tab and L/FNG Tab
* Add DTOs for Parcel and Document to minimize exposed data
  • Loading branch information
Daniel Haselhan committed Oct 5, 2023
1 parent 905890e commit 13945d8
Show file tree
Hide file tree
Showing 34 changed files with 533 additions and 542 deletions.
Original file line number Diff line number Diff line change
@@ -1,45 +1,9 @@
<div *ngIf="application">
<div *ngIf="applicationSubmission">
<div class="header">
<h3>ALC Review and Decision</h3>
<div>
<button
[routerLink]="'/application/' + application.fileNumber + '/edit'"
*ngIf="application.canEdit"
mat-flat-button
color="primary"
>
Edit Application
</button>
<button *ngIf="application.canReview" (click)="onReview(application.fileNumber)" mat-flat-button color="primary">
Review Application
</button>
</div>
</div>
<div
*ngIf="
application.status.code === SUBMISSION_STATUS.IN_PROGRESS ||
application.status.code === SUBMISSION_STATUS.IN_REVIEW_BY_LG ||
application.status.code === SUBMISSION_STATUS.INCOMPLETE ||
application.status.code === SUBMISSION_STATUS.WRONG_GOV ||
application.status.code === SUBMISSION_STATUS.SUBMITTED_TO_LG
"
class="warning"
>
This section will update after the application is submitted to the ALC.
</div>
<div *ngIf="application.status.code === SUBMISSION_STATUS.REFUSED_TO_FORWARD_LG" class="warning">
Application not subject to Agricultural Land Commission review.
</div>
<div
*ngIf="
application.status.code === SUBMISSION_STATUS.SUBMITTED_TO_ALC ||
application.status.code === SUBMISSION_STATUS.SUBMITTED_TO_ALC_INCOMPLETE ||
application.status.code === SUBMISSION_STATUS.RECEIVED_BY_ALC ||
application.status.code === SUBMISSION_STATUS.IN_REVIEW_BY_ALC ||
application.status.code === SUBMISSION_STATUS.ALC_DECISION
"
>
<app-decisions [fileNumber]="application.fileNumber"></app-decisions>
<app-submission-documents [$applicationDocuments]="$applicationDocuments"></app-submission-documents>
<div>
<app-public-decisions [applicationDecisions]="applicationDecisions"></app-public-decisions>
<app-submission-documents [applicationDocuments]="applicationDocuments"></app-submission-documents>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { ApplicationSubmissionReviewService } from '../../../../services/application-submission-review/application-submission-review.service';

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

describe('AlcsReviewComponent', () => {
let component: AlcReviewComponent;
let fixture: ComponentFixture<AlcReviewComponent>;
let mockAppReviewService: DeepMocked<ApplicationSubmissionReviewService>;
describe('PublicAlcReviewComponent', () => {
let component: PublicAlcReviewComponent;
let fixture: ComponentFixture<PublicAlcReviewComponent>;

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

await TestBed.configureTestingModule({
providers: [
{
provide: ApplicationSubmissionReviewService,
useValue: mockAppReviewService,
},
],
declarations: [AlcReviewComponent],
providers: [],
declarations: [PublicAlcReviewComponent],
}).compileComponents();

fixture = TestBed.createComponent(AlcReviewComponent);
fixture = TestBed.createComponent(PublicAlcReviewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,19 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { BehaviorSubject, Subject, takeUntil } from 'rxjs';
import { ApplicationDocumentDto } from '../../../../services/application-document/application-document.dto';
import { ApplicationSubmissionReviewService } from '../../../../services/application-submission-review/application-submission-review.service';
import {
SUBMISSION_STATUS,
ApplicationSubmissionDetailedDto,
} from '../../../../services/application-submission/application-submission.dto';
import { Component, Input } from '@angular/core';
import { ApplicationPortalDecisionDto } from '../../../../services/application-decision/application-decision.dto';
import { SUBMISSION_STATUS } from '../../../../services/application-submission/application-submission.dto';
import { PublicApplicationSubmissionDto, PublicDocumentDto } from '../../../../services/public/public.dto';

@Component({
selector: 'app-alc-review',
selector: 'app-public-alc-review',
templateUrl: './alc-review.component.html',
styleUrls: ['./alc-review.component.scss'],
})
export class AlcReviewComponent implements OnInit, OnDestroy {
private $destroy = new Subject<void>();
export class PublicAlcReviewComponent {
@Input() applicationSubmission!: PublicApplicationSubmissionDto;
@Input() applicationDocuments!: PublicDocumentDto[];
@Input() applicationDecisions!: ApplicationPortalDecisionDto[];

@Input() $application = new BehaviorSubject<ApplicationSubmissionDetailedDto | undefined>(undefined);
@Input() $applicationDocuments = new BehaviorSubject<ApplicationDocumentDto[]>([]);

application: ApplicationSubmissionDetailedDto | undefined;
SUBMISSION_STATUS = SUBMISSION_STATUS;

constructor(private applicationReviewService: ApplicationSubmissionReviewService, private router: Router) {}

ngOnInit(): void {
this.$application.pipe(takeUntil(this.$destroy)).subscribe((application) => {
this.application = application;
});
}

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

async onReview(fileId: string) {
if (this.application?.status.code === SUBMISSION_STATUS.SUBMITTED_TO_LG) {
const review = await this.applicationReviewService.startReview(fileId);
if (!review) {
return;
}
}
await this.router.navigateByUrl(`application/${fileId}/review`);
}
constructor() {}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div *ngFor="let decision of decisions; let index = index">
<h4>Decision #{{ decisions.length - index }}</h4>
<div *ngFor="let decision of applicationDecisions; let index = index">
<h4>Decision #{{ applicationDecisions.length - index }}</h4>
<div class="decision-table">
<div>
<div class="subheading2">Decision Date</div>
Expand All @@ -15,7 +15,6 @@ <h4>Decision #{{ decisions.length - index }}</h4>
<div class="subheading2">Decision Outcome</div>
{{ decision.outcome.label }} {{ decision.isSubjectToConditions ? '- Subject to Conditions' : '' }}
</div>

<div>
<div class="subheading2">Decision Document</div>
<div *ngFor="let document of decision.documents">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { createMock } from '@golevelup/ts-jest';
import { ApplicationDecisionService } from '../../../../../services/application-decision/application-decision.service';

import { DecisionsComponent } from './decisions.component';
import { PublicDecisionsComponent } from './decisions.component';

describe('DecisionsComponent', () => {
let component: DecisionsComponent;
let fixture: ComponentFixture<DecisionsComponent>;
describe('PublicDecisionsComponent', () => {
let component: PublicDecisionsComponent;
let fixture: ComponentFixture<PublicDecisionsComponent>;
let mockDecisionService: ApplicationDecisionService;

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

await TestBed.configureTestingModule({
declarations: [DecisionsComponent],
declarations: [PublicDecisionsComponent],
providers: [
{
provide: ApplicationDecisionService,
Expand All @@ -22,7 +22,7 @@ describe('DecisionsComponent', () => {
],
}).compileComponents();

fixture = TestBed.createComponent(DecisionsComponent);
fixture = TestBed.createComponent(PublicDecisionsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,19 @@ import { ApplicationPortalDecisionDto } from '../../../../../services/applicatio
import { ApplicationDecisionService } from '../../../../../services/application-decision/application-decision.service';

@Component({
selector: 'app-decisions[fileNumber]',
selector: 'app-public-decisions',
templateUrl: './decisions.component.html',
styleUrls: ['./decisions.component.scss'],
})
export class DecisionsComponent implements OnInit, OnChanges {
@Input() fileNumber = '';
decisions: ApplicationPortalDecisionDto[] = [];
export class PublicDecisionsComponent {
@Input() applicationDecisions: ApplicationPortalDecisionDto[] = [];

constructor(private decisionService: ApplicationDecisionService) {}

ngOnInit(): void {
this.loadDecisions();
}

ngOnChanges(changes: SimpleChanges): void {
this.loadDecisions();
}

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

private async loadDecisions() {
if (this.fileNumber) {
const decisions = await this.decisionService.getByFileId(this.fileNumber);
if (decisions) {
this.decisions = decisions;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
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 { PublicService } from '../../../../../services/public/public.service';

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

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

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

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

fixture = TestBed.createComponent(SubmissionDocumentsComponent);
fixture = TestBed.createComponent(PublicSubmissionDocumentsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { BehaviorSubject, Subject, takeUntil } from 'rxjs';
import { ApplicationDocumentDto } from '../../../../../services/application-document/application-document.dto';
import { ApplicationDocumentService } from '../../../../../services/application-document/application-document.service';
import { Subject } from 'rxjs';
import { PublicApplicationSubmissionDto, 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 SubmissionDocumentsComponent implements OnInit, OnDestroy {
export class PublicSubmissionDocumentsComponent implements OnInit, OnDestroy {
private $destroy = new Subject<void>();

displayedColumns: string[] = ['type', 'fileName', 'source', 'uploadedAt', 'actions'];
documents: ApplicationDocumentDto[] = [];
documents: PublicDocumentDto[] = [];

@Input() $applicationDocuments = new BehaviorSubject<ApplicationDocumentDto[]>([]);
@Input() applicationDocuments!: PublicDocumentDto[];
@Input() applicationSubmission!: PublicApplicationSubmissionDto;

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

constructor(private applicationDocumentService: ApplicationDocumentService) {}
constructor(private publicService: PublicService) {}

ngOnInit(): void {
this.$applicationDocuments.pipe(takeUntil(this.$destroy)).subscribe((documents) => {
this.dataSource = new MatTableDataSource(documents);
});
this.dataSource = new MatTableDataSource(this.applicationDocuments);
}

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

async downloadFile(uuid: string) {
const res = await this.applicationDocumentService.downloadFile(uuid);
const res = await this.publicService.getApplicationFileUrl(this.applicationSubmission.fileNumber, uuid);
if (res) {
const downloadLink = document.createElement('a');
downloadLink.href = res.url;
Expand Down
Loading

0 comments on commit 13945d8

Please sign in to comment.