diff --git a/alcs-frontend/src/app/features/application/decision/conditions/condition/condition.component.ts b/alcs-frontend/src/app/features/application/decision/conditions/condition/condition.component.ts
index 4e77b18c9c..e9b87993a2 100644
--- a/alcs-frontend/src/app/features/application/decision/conditions/condition/condition.component.ts
+++ b/alcs-frontend/src/app/features/application/decision/conditions/condition/condition.component.ts
@@ -7,6 +7,8 @@ import {
APPLICATION_DECISION_COMPONENT_TYPE,
ApplicationDecisionComponentDto,
UpdateApplicationDecisionConditionDto,
+ DateType,
+ ApplicationDecisionConditionDateDto,
} from '../../../../../services/application/decision/application-decision-v2/application-decision-v2.dto';
import {
DECISION_CONDITION_COMPLETE_LABEL,
@@ -19,7 +21,6 @@ import {
} from '../conditions.component';
import { environment } from '../../../../../../environments/environment';
-
type Condition = ApplicationDecisionConditionWithStatus & {
componentLabelsStr?: string;
componentLabels?: ConditionComponentLabels[];
@@ -35,6 +36,10 @@ export class ConditionComponent implements OnInit, AfterViewInit {
@Input() isDraftDecision!: boolean;
@Input() fileNumber!: string;
+ DateType = DateType;
+
+ dates: ApplicationDecisionConditionDateDto[] = [];
+
incompleteLabel = DECISION_CONDITION_INCOMPLETE_LABEL;
completeLabel = DECISION_CONDITION_COMPLETE_LABEL;
@@ -48,24 +53,27 @@ export class ConditionComponent implements OnInit, AfterViewInit {
isReadMoreClicked = false;
isReadMoreVisible = false;
- conditionStatus: string = '';
isRequireSurveyPlan = false;
subdComponent?: ApplicationDecisionComponentDto;
planNumbers: ApplicationDecisionConditionToComponentPlanNumberDto[] = [];
constructor(
private conditionService: ApplicationDecisionConditionService,
- private conditionLotService: ApplicationDecisionComponentToConditionLotService
+ private conditionLotService: ApplicationDecisionComponentToConditionLotService,
) {}
ngOnInit() {
- this.updateStatus();
if (this.condition) {
- this.singleDateFormated = this.condition.singleDate ? moment(this.condition.singleDate).format(environment.dateFormat) : undefined;
+ this.fetchDates(this.condition.uuid);
+
this.singleDateLabel = this.condition.type?.singleDateLabel ? this.condition.type?.singleDateLabel : 'End Date';
- this.showSingleDateField = this.condition.type?.isSingleDateChecked ? this.condition.type?.isSingleDateChecked : false;
- this.showAdmFeeField = this.condition.type?.isAdministrativeFeeAmountChecked ? this.condition.type?.isAdministrativeFeeAmountChecked : false;
- this.showSecurityAmountField = this.condition.type?.isSecurityAmountChecked ? this.condition.type?.isSecurityAmountChecked : false;
+ this.showSingleDateField = this.condition.type?.dateType === DateType.SINGLE;
+ this.showAdmFeeField = this.condition.type?.isAdministrativeFeeAmountChecked
+ ? this.condition.type?.isAdministrativeFeeAmountChecked
+ : false;
+ this.showSecurityAmountField = this.condition.type?.isSecurityAmountChecked
+ ? this.condition.type?.isSecurityAmountChecked
+ : false;
this.condition = {
...this.condition,
componentLabelsStr: this.condition.conditionComponentsLabels?.flatMap((e) => e.label).join(';\n'),
@@ -80,7 +88,7 @@ export class ConditionComponent implements OnInit, AfterViewInit {
async loadLots() {
if (this.condition.components) {
const subdComponent = this.condition.components.find(
- (component) => component.applicationDecisionComponentTypeCode === APPLICATION_DECISION_COMPONENT_TYPE.SUBD
+ (component) => component.applicationDecisionComponentTypeCode === APPLICATION_DECISION_COMPONENT_TYPE.SUBD,
);
if (subdComponent && subdComponent.uuid) {
const planNumbers = await this.conditionLotService.fetchConditionLots(this.condition.uuid, subdComponent.uuid);
@@ -99,23 +107,23 @@ export class ConditionComponent implements OnInit, AfterViewInit {
async loadPlanNumber() {
const subdComponent = this.condition.components?.find(
- (component) => component.applicationDecisionComponentTypeCode === APPLICATION_DECISION_COMPONENT_TYPE.SUBD
+ (component) => component.applicationDecisionComponentTypeCode === APPLICATION_DECISION_COMPONENT_TYPE.SUBD,
);
if (
this.condition.components &&
this.condition.components.some(
- (component) => component.applicationDecisionComponentTypeCode !== APPLICATION_DECISION_COMPONENT_TYPE.SUBD
+ (component) => component.applicationDecisionComponentTypeCode !== APPLICATION_DECISION_COMPONENT_TYPE.SUBD,
) &&
this.isRequireSurveyPlan
) {
const planNumbers = (await this.conditionService.fetchPlanNumbers(this.condition.uuid)).filter(
- (planNumber) => planNumber.applicationDecisionComponentUuid !== subdComponent?.uuid
+ (planNumber) => planNumber.applicationDecisionComponentUuid !== subdComponent?.uuid,
);
this.planNumbers =
this.condition.components
?.filter(
- (component) => component.applicationDecisionComponentTypeCode !== APPLICATION_DECISION_COMPONENT_TYPE.SUBD
+ (component) => component.applicationDecisionComponentTypeCode !== APPLICATION_DECISION_COMPONENT_TYPE.SUBD,
)
.map(
(component) =>
@@ -123,9 +131,9 @@ export class ConditionComponent implements OnInit, AfterViewInit {
applicationDecisionComponentUuid: component.uuid,
applicationDecisionConditionUuid: this.condition.uuid,
planNumbers: planNumbers.find(
- (planNumber) => planNumber.applicationDecisionComponentUuid === component.uuid
+ (planNumber) => planNumber.applicationDecisionComponentUuid === component.uuid,
)?.planNumbers,
- } as ApplicationDecisionConditionToComponentPlanNumberDto)
+ }) as ApplicationDecisionConditionToComponentPlanNumberDto,
) ?? [];
}
}
@@ -136,7 +144,7 @@ export class ConditionComponent implements OnInit, AfterViewInit {
async onUpdateCondition(
field: keyof UpdateApplicationDecisionConditionDto,
- value: string[] | string | number | null
+ value: string[] | string | number | null,
) {
const condition = this.condition;
@@ -147,8 +155,6 @@ export class ConditionComponent implements OnInit, AfterViewInit {
const labels = this.condition.componentLabelsStr;
this.condition = { ...update, componentLabelsStr: labels } as Condition;
-
- this.updateStatus();
}
}
@@ -166,16 +172,6 @@ export class ConditionComponent implements OnInit, AfterViewInit {
return this.isReadMoreClicked || this.isEllipsisActive(this.condition.uuid + 'Description');
}
- updateStatus() {
- const today = moment().startOf('day').toDate().getTime();
-
- if (this.condition.completionDate && this.condition.completionDate <= today) {
- this.conditionStatus = CONDITION_STATUS.COMPLETE;
- } else {
- this.conditionStatus = CONDITION_STATUS.INCOMPLETE;
- }
- }
-
async savePlanNumbers(lotUuid: string, conditionUuid: string, planNumbers: string | null) {
if (this.subdComponent && this.subdComponent.uuid && this.subdComponent?.lots) {
await this.conditionLotService.update(lotUuid, conditionUuid, planNumbers);
@@ -191,4 +187,15 @@ export class ConditionComponent implements OnInit, AfterViewInit {
getComponentLabel(componentUuid: string) {
return this.condition.conditionComponentsLabels?.find((e) => e.componentUuid === componentUuid)?.label;
}
+
+ async fetchDates(uuid: string | undefined) {
+ if (!uuid) {
+ return;
+ }
+
+ this.dates = await this.conditionService.getDates(uuid);
+
+ this.singleDateFormated =
+ this.dates[0] && this.dates[0].date ? moment(this.dates[0].date).format(environment.dateFormat) : undefined;
+ }
}
diff --git a/alcs-frontend/src/app/features/application/decision/conditions/conditions.component.spec.ts b/alcs-frontend/src/app/features/application/decision/conditions/conditions.component.spec.ts
index f3116b4875..8a80363628 100644
--- a/alcs-frontend/src/app/features/application/decision/conditions/conditions.component.spec.ts
+++ b/alcs-frontend/src/app/features/application/decision/conditions/conditions.component.spec.ts
@@ -8,6 +8,7 @@ import { ApplicationDto } from '../../../../services/application/application.dto
import { ApplicationDecisionV2Service } from '../../../../services/application/decision/application-decision-v2/application-decision-v2.service';
import { ConditionsComponent } from './conditions.component';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
describe('ConditionsComponent', () => {
let component: ConditionsComponent;
@@ -42,6 +43,7 @@ describe('ConditionsComponent', () => {
},
],
schemas: [NO_ERRORS_SCHEMA],
+ imports: [HttpClientTestingModule],
}).compileComponents();
fixture = TestBed.createComponent(ConditionsComponent);
diff --git a/alcs-frontend/src/app/features/application/decision/conditions/conditions.component.ts b/alcs-frontend/src/app/features/application/decision/conditions/conditions.component.ts
index 2817cbb5b2..14aa25ed25 100644
--- a/alcs-frontend/src/app/features/application/decision/conditions/conditions.component.ts
+++ b/alcs-frontend/src/app/features/application/decision/conditions/conditions.component.ts
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import moment from 'moment';
-import { Subject, takeUntil } from 'rxjs';
+import { from, map, Subject, switchMap, takeUntil } from 'rxjs';
import { ApplicationDetailService } from '../../../../services/application/application-detail.service';
import { ApplicationDto } from '../../../../services/application/application.dto';
import {
@@ -9,6 +9,7 @@ import {
ApplicationDecisionDto,
ApplicationDecisionWithLinkedResolutionDto,
ApplicationDecisionCodesDto,
+ ApplicationDecisionConditionDateDto,
} from '../../../../services/application/decision/application-decision-v2/application-decision-v2.dto';
import { ApplicationDecisionV2Service } from '../../../../services/application/decision/application-decision-v2/application-decision-v2.service';
import {
@@ -17,6 +18,7 @@ import {
RECON_TYPE_LABEL,
RELEASED_DECISION_TYPE_LABEL,
} from '../../../../shared/application-type-pill/application-type-pill.constants';
+import { ApplicationDecisionConditionService } from '../../../../services/application/decision/application-decision-v2/application-decision-condition/application-decision-condition.service';
export type ConditionComponentLabels = {
label: string[];
@@ -63,7 +65,8 @@ export class ConditionsComponent implements OnInit {
constructor(
private applicationDetailService: ApplicationDetailService,
private decisionService: ApplicationDecisionV2Service,
- private activatedRouter: ActivatedRoute
+ private conditionService: ApplicationDecisionConditionService,
+ private activatedRouter: ActivatedRoute,
) {
this.today = moment().startOf('day').toDate().getTime();
}
@@ -82,26 +85,52 @@ export class ConditionsComponent implements OnInit {
async loadDecisions(fileNumber: string) {
this.codes = await this.decisionService.fetchCodes();
- this.decisionService.$decisions.pipe(takeUntil(this.$destroy)).subscribe((decisions) => {
- this.decisions = decisions.map((decision) => {
- if (decision.uuid === this.decisionUuid) {
- const conditions = this.mapConditions(decision, decisions);
-
- this.sortConditions(decision, conditions);
-
- this.decision = decision as ApplicationDecisionWithConditionComponentLabels;
- }
+ this.decisionService.$decisions
+ .pipe(takeUntil(this.$destroy))
+ .pipe(
+ switchMap((decisions) =>
+ from(this.getDatesByConditionUuid(decisions)).pipe(
+ map((datesByConditionUuid) => ({
+ decisions,
+ datesByConditionUuid,
+ })),
+ ),
+ ),
+ )
+ .subscribe(({ decisions, datesByConditionUuid }) => {
+ this.decisions = decisions.map((decision) => {
+ if (decision.uuid === this.decisionUuid) {
+ const conditions = this.mapConditions(decision, datesByConditionUuid, decisions);
+
+ this.sortConditions(decision, conditions);
+
+ this.decision = decision as ApplicationDecisionWithConditionComponentLabels;
+ }
- return decision as ApplicationDecisionWithConditionComponentLabels;
+ return decision as ApplicationDecisionWithConditionComponentLabels;
+ });
});
- });
this.decisionService.loadDecisions(fileNumber);
}
+ private async getDatesByConditionUuid(
+ decisions: ApplicationDecisionWithLinkedResolutionDto[],
+ ): Promise
+
+