Skip to content

Commit a7a5ecf

Browse files
authored
Merge pull request #1999 from bcgov/feature/ALCS-2322
Add status and delete to condition types admin UI
2 parents a232b80 + bf2d343 commit a7a5ecf

File tree

28 files changed

+317
-142
lines changed

28 files changed

+317
-142
lines changed

alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types-dialog/decision-condition-types-dialog.component.html

+10-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ <h4>{{ isEdit ? 'Edit' : 'Create' }} Decision Condition Type</h4>
3333
</mat-form-field>
3434
</div>
3535

36+
<div class="dialog-field full-width">
37+
<mat-label>Status *</mat-label>
38+
<mat-button-toggle-group required id="isActive" formControlName="isActive" name="isActive">
39+
<mat-button-toggle [value]="true">Active</mat-button-toggle>
40+
<mat-button-toggle [value]="false">Inactive</mat-button-toggle>
41+
</mat-button-toggle-group>
42+
</div>
43+
3644
<div class="condition-fields-container full-width">
3745
<span>Click to select fields</span>
3846

@@ -116,7 +124,8 @@ <h4>{{ isEdit ? 'Edit' : 'Create' }} Decision Condition Type</h4>
116124
</div>
117125
<div class="warning-section">
118126
<div class="warning" *ngIf="showWarning">
119-
<mat-icon>info</mat-icon> <b>Warning: </b>&nbsp; Changes made here will apply to all instances of this condition
127+
<mat-icon>info</mat-icon> <b>Warning: </b>&nbsp; Changes made here will apply to all instances of this
128+
condition
120129
</div>
121130
</div>
122131
</div>

alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types-dialog/decision-condition-types-dialog.component.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import { ApplicationDecisionConditionTypesService } from '../../../../services/a
66

77
import { DecisionConditionTypesDialogComponent } from './decision-condition-types-dialog.component';
88
import { MatCheckboxModule } from '@angular/material/checkbox';
9+
import { MatButtonToggleGroup } from '@angular/material/button-toggle';
910

1011
describe('DecisionConditionTypesDialogComponent', () => {
1112
let component: DecisionConditionTypesDialogComponent;
1213
let fixture: ComponentFixture<DecisionConditionTypesDialogComponent>;
1314

1415
beforeEach(async () => {
1516
await TestBed.configureTestingModule({
16-
imports: [ReactiveFormsModule, FormsModule, MatCheckboxModule],
17+
imports: [ReactiveFormsModule, FormsModule, MatCheckboxModule, MatButtonToggleGroup],
1718
declarations: [DecisionConditionTypesDialogComponent],
1819
providers: [
1920
{ provide: MAT_DIALOG_DATA, useValue: undefined },

alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types-dialog/decision-condition-types-dialog.component.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export class DecisionConditionTypesDialogComponent {
3535
]),
3636
label: new FormControl(this.data?.content?.label ? this.data.content.label : '', [Validators.required]),
3737
code: new FormControl(this.data?.content?.code ? this.data.content.code : '', [Validators.required]),
38+
isActive: new FormControl<boolean>(this.data && this.data.content ? this.data.content.isActive : true, [
39+
Validators.required,
40+
]),
3841
isComponentToConditionChecked: new FormControl(
3942
this.data?.content?.isComponentToConditionChecked ? this.data.content.isComponentToConditionChecked : true,
4043
),
@@ -76,7 +79,7 @@ export class DecisionConditionTypesDialogComponent {
7679
}
7780

7881
ngOnInit(): void {
79-
this.conditionTypeForm.valueChanges.subscribe( () => {
82+
this.conditionTypeForm.valueChanges.subscribe(() => {
8083
this.showWarning = this.isEdit ? true : false;
8184
});
8285
}
@@ -88,6 +91,7 @@ export class DecisionConditionTypesDialogComponent {
8891
code: this.conditionTypeForm.get('code')?.value,
8992
label: this.conditionTypeForm.get('label')?.value,
9093
description: this.conditionTypeForm.get('description')?.value,
94+
isActive: this.conditionTypeForm.get('isActive')?.value,
9195
isAdministrativeFeeAmountChecked: this.conditionTypeForm.get('isAdministrativeFeeAmountChecked')?.value,
9296
isAdministrativeFeeAmountRequired: this.conditionTypeForm.get('isAdministrativeFeeAmountRequired')?.value,
9397
administrativeFeeAmount: this.conditionTypeForm.get('administrativeFeeAmount')?.value,

alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.html

+18
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,30 @@ <h3>Decision Condition Types</h3>
2323
<td mat-cell *matCellDef="let row">{{ row.code }}</td>
2424
</ng-container>
2525

26+
<ng-container matColumnDef="isActive">
27+
<th mat-header-cell *matHeaderCellDef>Status</th>
28+
<td mat-cell *matCellDef="let row">
29+
<div class="left" *ngIf="row.isActive">
30+
<mat-icon color="primary">check_circle_outline</mat-icon>
31+
Active
32+
</div>
33+
<div class="left" *ngIf="!row.isActive">
34+
<mat-icon color="warn">not_interested</mat-icon>
35+
Inactive
36+
</div>
37+
</td>
38+
</ng-container>
39+
2640
<ng-container matColumnDef="actions">
2741
<th mat-header-cell *matHeaderCellDef>Actions</th>
2842
<td mat-cell *matCellDef="let row">
2943
<button class="edit-btn" mat-flat-button (click)="onEdit(row)">
3044
<mat-icon>edit</mat-icon>
3145
</button>
46+
47+
<button class="delete-btn" mat-flat-button (click)="onDelete(row)">
48+
<mat-icon>delete</mat-icon>
49+
</button>
3250
</td>
3351
</ng-container>
3452
</table>
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
1+
@use '../../../../styles/colors';
2+
13
.container {
4+
.mat-column-actions {
5+
width: 20%;
6+
}
7+
8+
.actions-bar {
9+
margin-top: 30px;
10+
display: flex;
11+
justify-content: space-between;
12+
}
13+
14+
.edit-btn,
15+
.delete-btn {
16+
width: 48px !important;
17+
min-width: unset !important;
18+
}
19+
220
.edit-btn {
3-
color: green;
21+
color: colors.$primary-color-dark;
422
}
523

624
.delete-btn {
7-
color: red;
25+
color: colors.$error-color;
26+
}
27+
28+
.mat-icon {
29+
margin-right: 1px;
830
}
931
}

alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ import { NoticeOfIntentDecisionConditionTypeDto } from '../../../services/notice
1414
styleUrls: ['./decision-condition-types.component.scss'],
1515
})
1616
export class DecisionConditionTypesComponent implements OnInit {
17-
18-
@Input() public service: ApplicationDecisionConditionTypesService | NoticeofIntentDecisionConditionTypesService | undefined;
17+
@Input() public service:
18+
| ApplicationDecisionConditionTypesService
19+
| NoticeofIntentDecisionConditionTypesService
20+
| undefined;
1921

2022
destroy = new Subject<void>();
2123

2224
decisionConditionTypeDtos: ApplicationDecisionConditionTypeDto[] | NoticeOfIntentDecisionConditionTypeDto[] = [];
23-
displayedColumns: string[] = ['label', 'description', 'code', 'actions'];
25+
displayedColumns: string[] = ['label', 'description', 'code', 'isActive', 'actions'];
2426

2527
constructor(
2628
public dialog: MatDialog,
27-
private confirmationDialogService: ConfirmationDialogService
29+
private confirmationDialogService: ConfirmationDialogService,
2830
) {}
2931

3032
ngOnInit(): void {

alcs-frontend/src/app/features/application/decision/decision-v2/decision-input/decision-conditions/decision-condition/decision-condition.component.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe('DecisionConditionComponent', () => {
2121
code: '',
2222
label: '',
2323
description: '',
24+
isActive: true,
2425
isAdministrativeFeeAmountChecked: false,
2526
isSingleDateChecked: false,
2627
isSecurityAmountChecked: false,

alcs-frontend/src/app/features/application/decision/decision-v2/decision-input/decision-conditions/decision-conditions.component.html

+2-6
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@ <h3>Conditions</h3>
1616
</div>
1717

1818
<mat-menu xPosition="before" #decisionComponentMenu="matMenu">
19-
<button
20-
*ngFor="let conditionType of codes.decisionConditionTypes"
21-
mat-menu-item
22-
(click)="onAddNewCondition(conditionType.code)"
23-
>
19+
<button *ngFor="let type of activeTypes" mat-menu-item (click)="onAddNewCondition(type.code)">
2420
<div class="board-menu-item">
25-
<span>{{ conditionType.label }}</span>
21+
<span>{{ type.label }}</span>
2622
</div>
2723
</button>
2824
</mat-menu>

alcs-frontend/src/app/features/application/decision/decision-v2/decision-input/decision-conditions/decision-conditions.component.spec.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,7 @@ describe('DecisionConditionComponent', () => {
4040

4141
fixture = TestBed.createComponent(DecisionConditionsComponent);
4242
component = fixture.componentInstance;
43-
component.codes = {
44-
ceoCriterion: [],
45-
decisionComponentTypes: [],
46-
decisionMakers: [],
47-
naruSubtypes: [],
48-
outcomes: [],
49-
decisionConditionTypes: [],
50-
};
43+
component.types = [];
5144
fixture.detectChanges();
5245
});
5346

alcs-frontend/src/app/features/application/decision/decision-v2/decision-input/decision-conditions/decision-conditions.component.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import { combineLatestWith, Subject, takeUntil } from 'rxjs';
1313
import {
1414
ApplicationDecisionConditionDto,
1515
ApplicationDecisionDto,
16-
ApplicationDecisionCodesDto,
1716
ApplicationDecisionComponentDto,
1817
UpdateApplicationDecisionConditionDto,
18+
ApplicationDecisionConditionTypeDto,
1919
} from '../../../../../../services/application/decision/application-decision-v2/application-decision-v2.dto';
2020
import { ApplicationDecisionV2Service } from '../../../../../../services/application/decision/application-decision-v2/application-decision-v2.service';
2121
import { ConfirmationDialogService } from '../../../../../../shared/confirmation-dialog/confirmation-dialog.service';
@@ -32,7 +32,10 @@ export type SelectableComponent = { uuid?: string; tempId: string; decisionUuid:
3232
export class DecisionConditionsComponent implements OnInit, OnChanges, OnDestroy {
3333
$destroy = new Subject<void>();
3434

35-
@Input() codes!: ApplicationDecisionCodesDto;
35+
activeTypes!: ApplicationDecisionConditionTypeDto[];
36+
@Input() set types(types: ApplicationDecisionConditionTypeDto[]) {
37+
this.activeTypes = types.filter((type) => type.isActive);
38+
}
3639
@Input() components: ApplicationDecisionComponentDto[] = [];
3740
@Input() conditions: ApplicationDecisionConditionDto[] = [];
3841
@Input() showError = false;
@@ -91,7 +94,7 @@ export class DecisionConditionsComponent implements OnInit, OnChanges, OnDestroy
9194
}
9295

9396
onAddNewCondition(typeCode: string) {
94-
const matchingType = this.codes.decisionConditionTypes.find((code) => code.code === typeCode);
97+
const matchingType = this.activeTypes.find((type) => type.code === typeCode);
9598
this.mappedConditions.unshift({
9699
type: matchingType,
97100
tempUuid: (Math.random() * 10000).toFixed(0),
@@ -177,8 +180,8 @@ export class DecisionConditionsComponent implements OnInit, OnChanges, OnDestroy
177180
decisionYear: number | null
178181
) {
179182
return components.map((component) => {
180-
const matchingType = this.codes.decisionComponentTypes.find(
181-
(type) => type.code === component.applicationDecisionComponentTypeCode
183+
const matchingType = this.activeTypes.find(
184+
(type) => type.code === component.applicationDecisionComponentTypeCode,
182185
);
183186
return {
184187
uuid: component.uuid,

alcs-frontend/src/app/features/application/decision/decision-v2/decision-input/decision-input-v2.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ <h3>Resolution</h3>
202202
<div>
203203
<app-app-decision-conditions
204204
*ngIf="codes && showComponents && showConditions"
205-
[codes]="codes"
205+
[types]="codes.decisionConditionTypes"
206206
[components]="components"
207207
[conditions]="conditions"
208208
(conditionsChange)="onConditionsChange($event)"

alcs-frontend/src/app/features/notice-of-intent/decision/decision-v2/decision-input/decision-conditions/decision-condition/decision-condition.component.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe('DecisionConditionComponent', () => {
2020
code: '',
2121
label: '',
2222
description: '',
23+
isActive: true,
2324
isAdministrativeFeeAmountChecked: false,
2425
isSingleDateChecked: false,
2526
isSecurityAmountChecked: false,

alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ describe('DecisionConditionTypesService', () => {
4444
code: '',
4545
label: '',
4646
description: '',
47+
isActive: true,
4748
isAdministrativeFeeAmountChecked: false,
4849
isSingleDateChecked: false,
4950
isSecurityAmountChecked: false,
@@ -65,6 +66,7 @@ describe('DecisionConditionTypesService', () => {
6566
code: '',
6667
label: '',
6768
description: '',
69+
isActive: true,
6870
isAdministrativeFeeAmountChecked: false,
6971
isSingleDateChecked: false,
7072
isSecurityAmountChecked: false,
@@ -86,6 +88,7 @@ describe('DecisionConditionTypesService', () => {
8688
code: '',
8789
label: '',
8890
description: '',
91+
isActive: true,
8992
isAdministrativeFeeAmountChecked: false,
9093
isSingleDateChecked: false,
9194
isSecurityAmountChecked: false,
@@ -107,6 +110,7 @@ describe('DecisionConditionTypesService', () => {
107110
code: '',
108111
label: '',
109112
description: '',
113+
isActive: true,
110114
isAdministrativeFeeAmountChecked: false,
111115
isSingleDateChecked: false,
112116
isSecurityAmountChecked: false,

alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class ApplicationDecisionConditionTypesService {
3131
return await firstValueFrom(this.http.post<ApplicationDecisionConditionTypeDto>(`${this.url}`, createDto));
3232
} catch (e) {
3333
this.toastService.showErrorToast('Failed to create decision condition type');
34-
console.log(e);
34+
console.error(e);
3535
}
3636
return;
3737
}
@@ -43,17 +43,21 @@ export class ApplicationDecisionConditionTypesService {
4343
);
4444
} catch (e) {
4545
this.toastService.showErrorToast('Failed to update decision condition type');
46-
console.log(e);
46+
console.error(e);
4747
}
4848
return;
4949
}
5050

5151
async delete(code: string) {
5252
try {
5353
return await firstValueFrom(this.http.delete<ApplicationDecisionConditionTypeDto>(`${this.url}/${code}`));
54-
} catch (e) {
55-
this.toastService.showErrorToast('Failed to delete decision condition type');
56-
console.log(e);
54+
} catch (e: any) {
55+
if (e && e.error && e.error.message) {
56+
this.toastService.showErrorToast(e.error.message);
57+
} else {
58+
this.toastService.showErrorToast('Failed to delete decision condition type');
59+
}
60+
console.error(e);
5761
}
5862
return;
5963
}

alcs-frontend/src/app/services/application/decision/application-decision-v2/application-decision-v2.dto.ts

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ export enum DateLabel {
222222
}
223223

224224
export interface ApplicationDecisionConditionTypeDto extends BaseCodeDto {
225+
isActive: boolean;
225226
isComponentToConditionChecked?: boolean | null;
226227
isDescriptionChecked?: boolean | null;
227228
isAdministrativeFeeAmountChecked: boolean;

alcs-frontend/src/app/services/notice-of-intent/decision-v2/notice-of-intent-decision.dto.ts

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export interface NoticeOfIntentDecisionDocumentDto {
6969
export interface NoticeOfIntentDecisionOutcomeCodeDto extends BaseCodeDto {}
7070

7171
export interface NoticeOfIntentDecisionConditionTypeDto extends BaseCodeDto {
72+
isActive: boolean;
7273
isComponentToConditionChecked?: boolean | null;
7374
isDescriptionChecked?: boolean | null;
7475
isAdministrativeFeeAmountChecked: boolean;

0 commit comments

Comments
 (0)