Skip to content

Commit

Permalink
Add Proposal map to NFU Submissions
Browse files Browse the repository at this point in the history
* Add to Step 6 and Step 8
* Add to ALCS
  • Loading branch information
Daniel Haselhan committed Aug 15, 2023
1 parent dd5610b commit 1d914f3
Show file tree
Hide file tree
Showing 16 changed files with 140 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ <h3>Proposal</h3>
<app-nfu-details
*ngIf="submission && applicationType === 'NFUP'"
[applicationSubmission]="submission"
[files]="files"
></app-nfu-details>
<app-tur-details
*ngIf="submission && applicationType === 'TURP'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@

<div class="subheading2 grid-1">Proposal Map / Site Plan</div>
<div class="grid-double">
<a *ngFor="let file of proposalMap" (click)="openFile(file)">
{{ file.fileName }}
</a>
<div *ngFor="let file of proposalMap">
<a (click)="openFile(file)">
{{ file.fileName }}
</a>
</div>
</div>

<div class="subheading2 grid-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class NaruDetailsComponent {

proposalMap: ApplicationDocumentDto[] = [];

constructor(private router: Router, private applicationDocumentService: ApplicationDocumentService) {}
constructor(private applicationDocumentService: ApplicationDocumentService) {}

async openFile(file: ApplicationDocumentDto) {
await this.applicationDocumentService.download(file.uuid, file.fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
<div class="grid-double">
{{ applicationSubmission.nfuAgricultureSupport }}
</div>
<div class="subheading2 grid-1">Proposal Map / Site Plan</div>
<div class="grid-double">
<div *ngFor="let file of proposalMap">
<a (click)="openFile(file)">
{{ file.fileName }}
</a>
</div>
</div>
<div class="subheading2 grid-1">
Do you need to import any fill to construct or conduct the proposed Non-farm use? Fill is any material brought onto
the property, including gravel for construction.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ApplicationDocumentService } from '../../../../../services/application/application-document/application-document.service';

import { NfuDetailsComponent } from './nfu-details.component';

Expand All @@ -8,9 +9,14 @@ describe('NfuDetailsComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ NfuDetailsComponent ]
})
.compileComponents();
providers: [
{
provide: ApplicationDocumentService,
useValue: {},
},
],
declarations: [NfuDetailsComponent],
}).compileComponents();

fixture = TestBed.createComponent(NfuDetailsComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Component, Input } from '@angular/core';
import { ApplicationDocumentDto } from '../../../../../services/application/application-document/application-document.dto';
import { ApplicationDocumentService } from '../../../../../services/application/application-document/application-document.service';
import { ApplicationSubmissionDto } from '../../../../../services/application/application.dto';
import { DOCUMENT_TYPE } from '../../../../../shared/document/document.dto';

@Component({
selector: 'app-nfu-details[applicationSubmission]',
Expand All @@ -9,5 +12,17 @@ import { ApplicationSubmissionDto } from '../../../../../services/application/ap
export class NfuDetailsComponent {
@Input() applicationSubmission!: ApplicationSubmissionDto;

constructor() {}
@Input() set files(documents: ApplicationDocumentDto[] | undefined) {
if (documents) {
this.proposalMap = documents.filter((document) => document.type?.code === DOCUMENT_TYPE.PROPOSAL_MAP);
}
}

proposalMap: ApplicationDocumentDto[] = [];

constructor(private applicationDocumentService: ApplicationDocumentService) {}

async openFile(file: ApplicationDocumentDto) {
await this.applicationDocumentService.download(file.uuid, file.fileName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ <h3>3. Primary Contact</h3>
</div>
<div class="subheading2 grid-1">
<span
*ngIf="
primaryContact?.type?.code !== OWNER_TYPE.CROWN &&
primaryContact?.type?.code !== OWNER_TYPE.GOVERNMENT
"
*ngIf="primaryContact?.type?.code !== OWNER_TYPE.CROWN && primaryContact?.type?.code !== OWNER_TYPE.GOVERNMENT"
>Organization (optional)</span
>
<span *ngIf="primaryContact?.type?.code === OWNER_TYPE.CROWN">Ministry/Department Responsible</span>
Expand Down Expand Up @@ -242,6 +239,7 @@ <h3>6. Proposal</h3>
[showEdit]="showEdit"
[draftMode]="draftMode"
[applicationSubmission]="applicationSubmission"
[applicationDocuments]="appDocuments"
[updatedFields]="updatedFields"
></app-nfu-details>
<app-tur-details
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service';
import { ApplicationParcelService } from '../../../../services/application-parcel/application-parcel.service';

import { NaruDetailsComponent } from './naru-details.component';

describe('PofoDetailsComponent', () => {
let component: NaruDetailsComponent;
let fixture: ComponentFixture<NaruDetailsComponent>;
let mockAppDocumentService: DeepMocked<ApplicationDocumentService>;
let mockAppParcelService: DeepMocked<ApplicationParcelService>;

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

await TestBed.configureTestingModule({
Expand All @@ -22,10 +19,6 @@ describe('PofoDetailsComponent', () => {
provide: ApplicationDocumentService,
useValue: mockAppDocumentService,
},
{
provide: ApplicationParcelService,
useValue: mockAppParcelService,
},
],
}).compileComponents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
{{ applicationSubmission.nfuAgricultureSupport }}
<app-no-data [showRequired]="showErrors" *ngIf="!applicationSubmission.nfuAgricultureSupport"></app-no-data>
</div>
<div class="subheading2 grid-1">Proposal Map / Site Plan</div>
<div class="grid-double">
<a *ngFor="let map of proposalMap" (click)="openFile(map.uuid)">
{{ map.fileName }}
</a>
<app-no-data [showRequired]="showErrors" *ngIf="proposalMap.length === 0"></app-no-data>
</div>
<div class="subheading2 grid-1">
Do you need to import any fill to construct or conduct the proposed Non-farm use? Fill is any material brought onto
the property, including gravel for construction.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service';

import { NfuDetailsComponent } from './nfu-details.component';

describe('NfuDetailsComponent', () => {
let component: NfuDetailsComponent;
let fixture: ComponentFixture<NfuDetailsComponent>;
let mockAppDocumentService: DeepMocked<ApplicationDocumentService>;

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

await TestBed.configureTestingModule({
declarations: [ NfuDetailsComponent ]
})
.compileComponents();
declarations: [NfuDetailsComponent],
providers: [
{
provide: ApplicationDocumentService,
useValue: mockAppDocumentService,
},
],
}).compileComponents();

fixture = TestBed.createComponent(NfuDetailsComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Component, Input } from '@angular/core';
import { Router } from '@angular/router';
import { ApplicationDocumentDto } from '../../../../services/application-document/application-document.dto';
import { ApplicationDocumentService } from '../../../../services/application-document/application-document.service';
import { ApplicationSubmissionDetailedDto } from '../../../../services/application-submission/application-submission.dto';
import { DOCUMENT_TYPE } from '../../../../shared/dto/document.dto';

@Component({
selector: 'app-nfu-details[applicationSubmission]',
Expand All @@ -13,8 +16,13 @@ export class NfuDetailsComponent {
@Input() showEdit = true;
@Input() draftMode = false;
@Input() updatedFields: string[] = [];
proposalMap: ApplicationDocumentDto[] = [];

constructor(private router: Router) {}
@Input() set applicationDocuments(documents: ApplicationDocumentDto[]) {
this.proposalMap = documents.filter((document) => document.type?.code === DOCUMENT_TYPE.PROPOSAL_MAP);
}

constructor(private router: Router, private applicationDocumentService: ApplicationDocumentService) {}

async onEditSection(step: number) {
if (this.draftMode) {
Expand All @@ -25,4 +33,9 @@ export class NfuDetailsComponent {
await this.router.navigateByUrl(`application/${this.applicationSubmission?.fileNumber}/edit/${step}?errors=t`);
}
}

async openFile(uuid: string) {
const res = await this.applicationDocumentService.openFile(uuid);
window.open(res?.url, '_blank');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ <h6 *ngIf="applicationSubmission">
<app-nfu-proposal
*ngIf="applicationSubmission.typeCode === 'NFUP'"
[$applicationSubmission]="$applicationSubmission"
[$applicationDocuments]="$applicationDocuments"
[showErrors]="showValidationErrors"
(navigateToStep)="onBeforeSwitchStep($event)"
(exit)="onExit()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ <h2>Proposal</h2>
</div>
<div class="subtext">Characters left: {{ 4000 - agricultureSupportText.textLength }}</div>
</div>
<div class="full-row">
<label class="subheading2" for="proposal-map">Proposal Map / Site Plan</label>
<div class="subtext">A visual representation of your proposal.</div>
<app-file-drag-drop
id="proposal-map"
[uploadedFiles]="proposalMap"
(uploadFiles)="attachFile($event, DOCUMENT_TYPE.PROPOSAL_MAP)"
(deleteFile)="onDeleteFile($event)"
(openFile)="openFile($event)"
[showErrors]="showErrors"
[isRequired]="true"
></app-file-drag-drop>
</div>
<div class="full-row">
<label for="will-import-fill">
Do you need to import any fill to construct or conduct the proposed Non-farm use? Fill is any material brought
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router';
import { DeepMocked, createMock } from '@golevelup/ts-jest';
import { BehaviorSubject } from 'rxjs';
import { ApplicationDocumentDto } from '../../../../../services/application-document/application-document.dto';
import { ApplicationDocumentService } from '../../../../../services/application-document/application-document.service';
import { ApplicationSubmissionDetailedDto } from '../../../../../services/application-submission/application-submission.dto';
import { ApplicationSubmissionService } from '../../../../../services/application-submission/application-submission.service';

Expand All @@ -24,6 +27,14 @@ describe('NfuProposalComponent', () => {
provide: ApplicationSubmissionService,
useValue: mockApplicationService,
},
{
provide: ApplicationDocumentService,
useValue: {},
},
{
provide: MatDialog,
useValue: {},
},
{
provide: Router,
useValue: mockRouter,
Expand All @@ -36,6 +47,7 @@ describe('NfuProposalComponent', () => {
fixture = TestBed.createComponent(NfuProposalComponent);
component = fixture.componentInstance;
component.$applicationSubmission = new BehaviorSubject<ApplicationSubmissionDetailedDto | undefined>(undefined);
component.$applicationDocuments = new BehaviorSubject<ApplicationDocumentDto[]>([]);
fixture.detectChanges();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router';
import { takeUntil } from 'rxjs';
import { ApplicationDocumentDto } from '../../../../../services/application-document/application-document.dto';
import { ApplicationDocumentService } from '../../../../../services/application-document/application-document.service';
import { ApplicationSubmissionUpdateDto } from '../../../../../services/application-submission/application-submission.dto';
import { ApplicationSubmissionService } from '../../../../../services/application-submission/application-submission.service';
import { DOCUMENT_TYPE } from '../../../../../shared/dto/document.dto';
import { SoilTableData } from '../../../../../shared/soil-table/soil-table.component';
import { parseStringToBoolean } from '../../../../../shared/utils/string-helper';
import { EditApplicationSteps } from '../../edit-submission.component';
import { StepComponent } from '../../step.partial';
import { SoilTableData } from '../../../../../shared/soil-table/soil-table.component';
import { FilesStepComponent } from '../../files-step.partial';

@Component({
selector: 'app-nfu-proposal',
templateUrl: './nfu-proposal.component.html',
styleUrls: ['./nfu-proposal.component.scss'],
})
export class NfuProposalComponent extends StepComponent implements OnInit, OnDestroy {
export class NfuProposalComponent extends FilesStepComponent implements OnInit, OnDestroy {
currentStep = EditApplicationSteps.Proposal;

fillTableData: SoilTableData = {};
Expand All @@ -40,11 +44,16 @@ export class NfuProposalComponent extends StepComponent implements OnInit, OnDes
fillTypeDescription: this.fillTypeDescription,
fillOriginDescription: this.fillOriginDescription,
});
private fileId = '';
private submissionUuid = '';

constructor(private router: Router, private applicationSubmissionService: ApplicationSubmissionService) {
super();
proposalMap: ApplicationDocumentDto[] = [];

constructor(
private router: Router,
private applicationSubmissionService: ApplicationSubmissionService,
applicationDocumentService: ApplicationDocumentService,
dialog: MatDialog
) {
super(applicationDocumentService, dialog);
}

ngOnInit(): void {
Expand Down Expand Up @@ -81,13 +90,17 @@ export class NfuProposalComponent extends StepComponent implements OnInit, OnDes
}
}
});

this.$applicationDocuments.pipe(takeUntil(this.$destroy)).subscribe((documents) => {
this.proposalMap = documents.filter((document) => document.type?.code === DOCUMENT_TYPE.PROPOSAL_MAP);
});
}

async onSave() {
await this.save();
}

private async save() {
protected async save() {
if (this.fileId && this.form.dirty) {
const nfuHectares = this.hectares.getRawValue();
const purpose = this.purpose.getRawValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ export class ApplicationSubmissionValidatorService {
await this.validateOptionalDocuments(applicantDocuments, errors);

if (applicationSubmission.typeCode === 'NFUP') {
await this.validateNfuProposal(applicationSubmission, errors);
await this.validateNfuProposal(
applicationSubmission,
applicantDocuments,
errors,
);
}
if (applicationSubmission.typeCode === 'TURP') {
await this.validateTurProposal(applicationSubmission, errors);
Expand Down Expand Up @@ -393,6 +397,7 @@ export class ApplicationSubmissionValidatorService {

private async validateNfuProposal(
applicationSubmission: ApplicationSubmission,
applicantDocuments: ApplicationDocument[],
errors: Error[],
) {
if (
Expand Down Expand Up @@ -420,6 +425,17 @@ export class ApplicationSubmissionValidatorService {
);
}
}

const proposalMaps = applicantDocuments.filter(
(document) => document.typeCode === DOCUMENT_TYPE.PROPOSAL_MAP,
);
if (proposalMaps.length === 0) {
errors.push(
new ServiceValidationException(
`${applicationSubmission.typeCode} proposal missing Proposal Map / Site Plan`,
),
);
}
}

private async validateTurProposal(
Expand Down

0 comments on commit 1d914f3

Please sign in to comment.