Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: #659 support FOM for woodlot licensees #661

Merged
merged 30 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9549671
Add new migration script for project_plan_code table and woodlot_plan…
ianliuwk1019 Jul 23, 2024
186b7df
Add projecrt-plan entity
ianliuwk1019 Jul 23, 2024
06bd86f
Add new columns 'woodlotPlanNumber' and 'projectPlanCode' to project …
ianliuwk1019 Jul 23, 2024
e8fa73d
Add projectPlan and woodlotPlanNumber properties to request/response …
ianliuwk1019 Jul 23, 2024
c1c47ce
Add ProjectPlanCode to project module
ianliuwk1019 Jul 23, 2024
93a11b4
Update swagger and gen new api client.
ianliuwk1019 Jul 24, 2024
de2d7ae
Rename woodlotLicenseNumber column
ianliuwk1019 Jul 24, 2024
7b3da00
Add woodlotLicenseNumber and fsp fom field and validations.
ianliuwk1019 Jul 24, 2024
3c102b1
Rest fields when plan selection change.
ianliuwk1019 Jul 24, 2024
7991251
Remove console log
ianliuwk1019 Jul 24, 2024
b9cd279
Update projectPlan to projectPlanCode
ianliuwk1019 Jul 24, 2024
c2ab1ff
Fix column mapping
ianliuwk1019 Jul 24, 2024
423569d
Add readonly fields
ianliuwk1019 Jul 25, 2024
61c5f45
Add WOODLOT to summary
ianliuwk1019 Jul 25, 2024
12ff736
Add woodlot license to view detail
ianliuwk1019 Jul 25, 2024
64b5d96
Add woodlotLicenseNumber and projectPlanCode fields to publicSummary
ianliuwk1019 Jul 25, 2024
0115f0b
Use projectPlanCodeEnum in page so no need to hardcode.
ianliuwk1019 Jul 25, 2024
6a22a5a
Fix some background-color for search result table
ianliuwk1019 Jul 25, 2024
dd5be95
Remove unused projectPlanDescription
ianliuwk1019 Jul 25, 2024
789f17e
Fix test
ianliuwk1019 Jul 25, 2024
ea46614
Open FSP and Woodlot# for edit.
ianliuwk1019 Jul 26, 2024
81f9e86
Add getProjectPlanNumber()
ianliuwk1019 Jul 29, 2024
9948de8
Remove commented out coede.
ianliuwk1019 Jul 29, 2024
a221410
Fix indentation.
ianliuwk1019 Jul 30, 2024
edda065
Fix script mistake.
ianliuwk1019 Jul 30, 2024
b71911f
Merge branch 'main' into feat/659-woodlot-licensees-support
ianliuwk1019 Jul 30, 2024
3bcbeda
Update swagger after merging from main
ianliuwk1019 Jul 30, 2024
60deb58
Add woodlot/fsp_id condition rendering for public notice.
ianliuwk1019 Jul 30, 2024
b8d34bd
align number to center
ianliuwk1019 Jul 30, 2024
e7f3583
Merge branch 'main' into feat/659-woodlot-licensees-support
ianliuwk1019 Jul 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 61 additions & 8 deletions admin/src/app/foms/fom-add-edit/fom-add-edit.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ <h1 class="text-muted">{{isCreate ? 'Add New' : 'Edit'}} FOM {{isCreate ? '' : '
readonly
id="op-end-year"
name="op-end-year"

class="form-control readonly-normal"
type="text"
placeholder="YYYY"
Expand All @@ -159,9 +158,36 @@ <h1 class="text-muted">{{isCreate ? 'Add New' : 'Edit'}} FOM {{isCreate ? '' : '
</div>

<div class="row">

<div class="form-group col-md-2">
<label for="fsp-id" style="white-space: nowrap;"
<div class="form-group col">
<label [ngClass]="{'required': this.isCreate}">Type of Plan Holder</label>
<select *ngIf="this.isCreate"
class="form-control"
formControlName="projectPlanCode"
(change)="onProjectPlanChange($event)"
[ngClass]="{'is-invalid': !fg.get('projectPlanCode').value && isSubmitSaveClicked}"
id="projectPlanSelectId">
<option *ngFor="let option of projectPlanOptions"
[value]="option.code"
[selected]="option.code === fg.get('projectPlanCode').value"
[innerHTML]="option.description"> </option>
</select>
<input *ngIf="!this.isCreate" type="text"
class="form-control"
id="projectPlanDescId"
name="projectPlanDescription"
basilv marked this conversation as resolved.
Show resolved Hide resolved
disabled
[value]="getProjectPlanDesc()"
/>
<div class="invalid-feedback"
*ngIf="(isSubmitSaveClicked || fieldTouchedOrDirty('projectPlanCode'))
&& getErrorMessage('projectPlanCode', 'required')">
{{getErrorMessage('projectPlanCode', 'required')}}
</div>
</div>
<!-- FSP ID Input -->
<div class="form-group col"
*ngIf="fg.get('projectPlanCode').value == projectPlanCodeEnum.Fsp">
<label for="fsp-id" [ngClass]="{'required': true}" style="white-space: nowrap;"
>FSP ID</label>
<input
type="number"
Expand All @@ -172,13 +198,40 @@ <h1 class="text-muted">{{isCreate ? 'Add New' : 'Edit'}} FOM {{isCreate ? '' : '
[appFormControl]="fg.get('fspId')"
/>
<div class="invalid-feedback"
*ngIf="(isSubmitSaveClicked || fieldTouchedOrDirty('fspId'))
&& getErrorMessage('fspId', 'required')">
{{getErrorMessage('fspId', 'required')}}
*ngIf="(isSubmitSaveClicked || fieldTouchedOrDirty('fspId'))">
<div>{{getErrorMessage('fspId', 'required')}}</div>
<div>{{getErrorMessage('fspId', 'numeric')}}</div>
</div>
</div>

<!-- Woodlot License Number Input -->
<div class="form-group col"
*ngIf="fg.get('projectPlanCode').value == projectPlanCodeEnum.Woodlot">
<label for="woodlot-id" [ngClass]="{'required': true}" style="white-space: nowrap;"
>Woodlot License Number</label>
<input
type="text"
class="form-control"
id="woodlot-id"
name="woodlot-id"
formControlName="woodlotLicenseNumber"
[appFormControl]="fg.get('woodlotLicenseNumber')"
/>
<div class="invalid-feedback"
*ngIf="(isSubmitSaveClicked || fieldTouchedOrDirty('woodlotLicenseNumber'))">
<div>
{{getErrorMessage('woodlotLicenseNumber', 'required')}}
</div>
<div>
{{getErrorMessage('woodlotLicenseNumber', 'woodlotFormat')}}
</div>
</div>
</div>
</div>

<div class="row">
<div class="form-group col">
<label for="fsp-id" style="white-space: nowrap;">District</label>
<label for="district-list" style="white-space: nowrap;">District</label>
ianliuwk1019 marked this conversation as resolved.
Show resolved Hide resolved
<select class="sort-comments form-control" [ngClass]="{'is-invalid': !districtIdSelect && isSubmitSaveClicked}" (change)="changeDistrictId($event)" id="district-list">
<option *ngIf="this.isCreate || !districtIdSelect"> </option>
<option [value]="district.id" *ngFor="let district of districts" [selected]="district.id === districtIdSelect" [innerHTML]=" district.name "> </option>
Expand Down
43 changes: 31 additions & 12 deletions admin/src/app/foms/fom-add-edit/fom-add-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,29 @@ import * as moment from 'moment';
import { Observable, Subject, of } from 'rxjs';
import { switchMap, takeUntil, tap } from 'rxjs/operators';

import { MAX_FILEUPLOAD_SIZE } from '@admin-core/utils/constants/constantUtils';
import { DatePipe, NgClass, NgFor, NgIf } from '@angular/common';
import {
AttachmentResponse, DistrictResponse, ForestClientResponse,
ForestClientService,
ProjectCreateRequest, ProjectResponse,
ProjectService, WorkflowStateEnum
} from '@api-client';
import { RxFormBuilder, RxFormGroup } from '@rxweb/reactive-form-validators';
import { User } from "@utility/security/user";
import { AttachmentTypeEnum } from "@admin-core/models/attachmentTypeEnum";
import { AttachmentResolverSvc } from "@admin-core/services/AttachmentResolverSvc";
import { CognitoService } from "@admin-core/services/cognito.service";
import { ModalService } from '@admin-core/services/modal.service';
import { StateService } from '@admin-core/services/state.service';
import { AttachmentUploadService } from "@admin-core/utils/attachmentUploadService";
import { MAX_FILEUPLOAD_SIZE } from '@admin-core/utils/constants/constantUtils';
import { DatePipe, NgClass, NgFor, NgIf } from '@angular/common';
import {
AttachmentResponse, DistrictResponse, ForestClientResponse,
ForestClientService,
ProjectCreateRequest,
ProjectPlanCodeEnum,
ProjectResponse,
ProjectService, WorkflowStateEnum
} from '@api-client';
import { RxFormBuilder, RxFormGroup } from '@rxweb/reactive-form-validators';
import { User } from "@utility/security/user";
import { FomAddEditForm } from './fom-add-edit.form';

import { UploadBoxComponent } from '@admin-core/components/file-upload-box/file-upload-box.component';
import { AppFormControlDirective } from '@admin-core/directives/form-control.directive';
import { ICodeTable } from '@admin-core/models/code-tables';
import { NewlinesPipe } from '@admin-core/pipes/newlines.pipe';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BsDatepickerConfig, BsDatepickerModule } from 'ngx-bootstrap/datepicker';
Expand All @@ -51,10 +54,15 @@ type ApplicationPageType = 'create' | 'edit';
providers: [DatePipe]
})
export class FomAddEditComponent implements OnInit, AfterViewInit, OnDestroy {
readonly projectPlanCodeEnum = ProjectPlanCodeEnum;
fg: RxFormGroup;
state: ApplicationPageType;
originalProjectResponse: ProjectResponse;
districts: DistrictResponse[] = this.stateSvc.getCodeTable('district');
projectPlanOptions: ICodeTable[] = [
{"code": this.projectPlanCodeEnum.Fsp, "description": "Forest Stewardship Plan"},
{"code": this.projectPlanCodeEnum.Woodlot, "description": "Woodlot License Plan"}
];
ianliuwk1019 marked this conversation as resolved.
Show resolved Hide resolved
forestClients: ForestClientResponse[] = [];
public supportingDocuments: any[] = [];
public initialPublicDocument: any[] = [];
Expand Down Expand Up @@ -89,7 +97,7 @@ export class FomAddEditComponent implements OnInit, AfterViewInit, OnDestroy {
private scrollToFragment: string = null;
private snackBarRef: MatSnackBarRef<SimpleSnackBar> = null;
private ngUnsubscribe: Subject<void> = new Subject<void>();

// bsDatepicker config object
readonly bsConfig = {
dateInputFormat: 'YYYY',
Expand Down Expand Up @@ -179,7 +187,6 @@ export class FomAddEditComponent implements OnInit, AfterViewInit, OnDestroy {
const form = new FomAddEditForm(data);
this.fg = <RxFormGroup>this.formBuilder.formGroup(form);
this.initializeFormFields(this.fg, this.user, this.originalProjectResponse);

if(data.description) {
this.descriptionValue = data.description;
}
Expand Down Expand Up @@ -318,6 +325,11 @@ export class FomAddEditComponent implements OnInit, AfterViewInit, OnDestroy {
this.districtIdSelect = parseInt(e.target.value);
}

onProjectPlanChange(e) {
// reset fspId and woodlotLicenseNumber fields when plan selection changed.
this.fg.get('fspId').setValue(null)
this.fg.get('woodlotLicenseNumber').setValue(null)
}
onForestClientChange(e) {
const forestClientField = this.fg.get('forestClient');
this.fg.get('forestClient').setValue(forestClientField.value);
Expand Down Expand Up @@ -418,6 +430,13 @@ export class FomAddEditComponent implements OnInit, AfterViewInit, OnDestroy {
return this.attachmentResolverSvc.isDeleteAttachmentAllowed(attachment.attachmentType.code, this.originalProjectResponse.workflowState.code);
}

getProjectPlanDesc() {
const item = this.projectPlanOptions.filter((item) => {
return item.code == this.originalProjectResponse.projectPlanCode
})[0]["description"];
return item;
}

/**
* Additional setup for form control.
*/
Expand Down
34 changes: 30 additions & 4 deletions admin/src/app/foms/fom-add-edit/fom-add-edit.form.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AbstractControl } from '@angular/forms';
import { DistrictResponse, ForestClientResponse, ProjectResponse, WorkflowStateCode } from '@api-client';
import { maxLength, minDate, minLength, prop, required } from '@rxweb/reactive-form-validators';
import { DistrictResponse, ForestClientResponse, ProjectPlanCodeEnum, ProjectResponse, WorkflowStateCode } from '@api-client';
import { alphaNumeric, maxLength, minDate, minLength, numeric, pattern, prop, required } from '@rxweb/reactive-form-validators';
import * as R from 'remeda';
import moment = require("moment");

Expand All @@ -9,7 +9,9 @@ const updateFields = [
'description',
'commentingOpenDate',
'commentingClosedDate',
'projectPlanCode',
'fspId',
'woodlotLicenseNumber',
'district',
'forestClient',
'workflowState',
Expand All @@ -35,9 +37,33 @@ export class FomAddEditForm implements Pick<ProjectResponse,
commentingClosedDate: string = null;

@prop()
@required({message: 'FSP ID is required.'})
@required({message: 'Type of Plan Holder is required.'})
projectPlanCode: string = ProjectPlanCodeEnum.Fsp

@prop()
@required({
message: 'FSP ID is required.',
conditionalExpression: (x) => {
return x.projectPlanCode == ProjectPlanCodeEnum.Fsp
}
})
@minLength({value: 1})
fspId: number;
@numeric({message: 'Must be a number.'})
fspId?: number = null;

@prop()
@required({
message: 'Woodlot License Plan Number is required.',
conditionalExpression: (x) => {
return x.projectPlanCode == ProjectPlanCodeEnum.Woodlot
}
})
@alphaNumeric({message: 'Only alpha-numberic characters are allowed.'})
@pattern({
expression:{'woodlotFormat': /^W\d{4}$/},
message: 'Must starts with "W" followed by 4 digits.'
})
woodlotLicenseNumber?: string = null;

@prop()
@required({message: 'District is required.'})
Expand Down
12 changes: 10 additions & 2 deletions admin/src/app/foms/fom-detail/fom-detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,21 @@ <h2>Description</h2>
<section>
<h2>Details</h2>
<ul class="nv-list">
<li>
<li *ngIf="project.projectPlanCode == projectPlanCodeEnum.Fsp">
<span class="name">FSP ID:</span>
<span
class="value">
{{project.fspId}}
{{project?.fspId}}
</span>
</li>
<li *ngIf="project.projectPlanCode == projectPlanCodeEnum.Woodlot">
<span class="name">Woodlot License Number:</span>
<span
class="value">
{{project?.woodlotLicenseNumber}}
</span>
</li>

<li>
<span class="name">FOM Holder:</span>
<span
Expand Down
6 changes: 3 additions & 3 deletions admin/src/app/foms/fom-detail/fom-detail.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { AttachmentResolverSvc } from "@admin-core/services/AttachmentResolverSvc";
import { CognitoService } from "@admin-core/services/cognito.service";
import { ModalService } from '@admin-core/services/modal.service';
import { Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import { AttachmentResponse, ProjectMetricsResponse, ProjectResponse, ProjectService, ProjectWorkflowStateChangeRequest, SpatialFeaturePublicResponse, WorkflowStateEnum } from "@api-client";
import { AttachmentResponse, ProjectMetricsResponse, ProjectPlanCodeEnum, ProjectResponse, ProjectService, ProjectWorkflowStateChangeRequest, SpatialFeaturePublicResponse, WorkflowStateEnum } from "@api-client";
import { NgbModal, NgbModalRef, NgbModule, NgbNav } from '@ng-bootstrap/ng-bootstrap';
import { User } from "@utility/security/user";
import { FeatureSelectService } from '@utility/services/featureSelect.service';
import * as moment from 'moment';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { CognitoService } from "@admin-core/services/cognito.service";
import { EnddateChangeModalComponent } from './enddate-change-modal/enddate-change-modal.component';

import { NewlinesPipe } from "@admin-core/pipes/newlines.pipe";
Expand Down Expand Up @@ -37,7 +37,7 @@ import { ShapeInfoComponent } from "../shape-info/shape-info.component";
styleUrls: ['./fom-detail.component.scss']
})
export class FomDetailComponent implements OnInit, OnDestroy {

readonly projectPlanCodeEnum = ProjectPlanCodeEnum;
@ViewChild('scrollContainer')
public scrollContainer: ElementRef;

Expand Down
9 changes: 8 additions & 1 deletion admin/src/app/foms/summary/summary.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ <h4>Description</h4>
<div>
<h4>Details</h4>
<ul class="nv-list">
<li>
<li *ngIf="project.projectPlanCode == projectPlanCodeEnum.Fsp">
<span class="name">FSP ID:</span>
<span class="value">
{{project?.fspId}}
</span>
</li>
<li *ngIf="project.projectPlanCode == projectPlanCodeEnum.Woodlot">
<span class="name">Woodlot License Number:</span>
<span class="value">
{{project?.woodlotLicenseNumber}}
</span>
</li>

<li>
<span class="name">FOM Holder:</span>
<span class="value">
Expand Down
11 changes: 6 additions & 5 deletions admin/src/app/foms/summary/summary.component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AttachmentResolverSvc } from '@admin-core/services/AttachmentResolverSvc';
import { CommonUtil } from '@admin-core/utils/commonUtil';
import { COMMENT_SCOPE_CODE, CommentScopeOpt } from '@admin-core/utils/constants/constantUtils';
import { DatePipe, NgFor, NgIf, TitleCasePipe } from '@angular/common';
Expand All @@ -8,9 +9,10 @@ import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSelectModule } from '@angular/material/select';
import { ActivatedRoute, RouterLink } from '@angular/router';
import {
AttachmentResponse, AttachmentService, InteractionResponse, InteractionService,
ProjectResponse, ProjectService, PublicCommentAdminResponse, PublicCommentService,
SpatialFeaturePublicResponse, SpatialFeatureService
AttachmentResponse, AttachmentService, InteractionResponse, InteractionService,
ProjectPlanCodeEnum,
ProjectResponse, ProjectService, PublicCommentAdminResponse, PublicCommentService,
SpatialFeaturePublicResponse, SpatialFeatureService
} from '@api-client';
import { ConfigService } from '@utility/services/config.service';
import * as _ from 'lodash';
Expand All @@ -20,7 +22,6 @@ import { DetailsMapComponent } from '../details-map/details-map.component';
import { ShapeInfoComponent } from '../shape-info/shape-info.component';
import { CommentsSummaryComponent } from './comments-summary/comments-summary.component';
import { InteractionsSummaryComponent } from './interactions-summary/interactions-summary.component';
import { AttachmentResolverSvc } from '@admin-core/services/AttachmentResolverSvc';

@Component({
standalone: true,
Expand All @@ -44,7 +45,7 @@ import { AttachmentResolverSvc } from '@admin-core/services/AttachmentResolverSv
styleUrls: ['./summary.component.scss']
})
export class SummaryComponent implements OnInit, OnDestroy {

readonly projectPlanCodeEnum = ProjectPlanCodeEnum;
projectId: number;
project: ProjectResponse;
projectReqError: boolean;
Expand Down
8 changes: 4 additions & 4 deletions admin/src/app/search/search.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ <h2 *ngIf="!searching && count > 0">
<tr>
<th id="fomId" class="disp">FOM Number</th>
<th id="fomName" class="client">FOM Name</th>
<th id="fspId" class="disp">FSP ID</th>
<th id="projectPlanNumber" class="plan">Plan Number</th>
<th id="fomHolder" class="client">FOM Holder Name</th>
<th id="district" class="client">District</th>
<th id="district">District</th>
<th id="fomStatus" class="status">FOM Status</th>
<th id="commentClosed" class="client">Commenting Closed Date</th>
<th id="commentClosed">Commenting Closed Date</th>
<th id="actions" class="actions"></th>
</tr>
</thead>
Expand All @@ -129,7 +129,7 @@ <h2 *ngIf="!searching && count > 0">
[innerHTML]="project.name ? project.name : '<em>No FOM name on this File</em>'">
</td>
<td>
{{project.fspId}}
{{getProjectPlanNumber(project)}}
</td>
<td
[innerHTML]="project.forestClient ? (project.forestClient.name | titlecase) : ''">
Expand Down
Loading
Loading