Skip to content

Commit

Permalink
Merge pull request #1991 from bcgov/feature/ALCS-2302-noi-condition-t…
Browse files Browse the repository at this point in the history
…ypes-on-admin

ALCS-2302 Implement NOI decision type into admin
  • Loading branch information
fbarreta authored Nov 21, 2024
2 parents 8f8d55d + 14d5737 commit 004766b
Show file tree
Hide file tree
Showing 15 changed files with 458 additions and 26 deletions.
4 changes: 2 additions & 2 deletions alcs-frontend/src/app/features/admin/admin.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BoardManagementComponent } from './board-management/board-management.co
import { CardStatusComponent } from './card-status/card-status.component';
import { CeoCriterionComponent } from './ceo-criterion/ceo-criterion.component';
import { ConfigurationComponent } from './configuration/configuration.component';
import { DecisionConditionTypesComponent } from './decision-condition-types/decision-condition-types.component';
import { DecisionConditionContainerComponent } from './decision-condition-types/decision-condition-container.component';
import { DecisionMakerComponent } from './decision-maker/decision-maker.component';
import { HolidayComponent } from './holiday/holiday.component';
import { LocalGovernmentComponent } from './local-government/local-government.component';
Expand Down Expand Up @@ -41,7 +41,7 @@ export const childRoutes = [
path: 'dct',
menuTitle: 'Decision Condition Types',
icon: 'hvac',
component: DecisionConditionTypesComponent,
component: DecisionConditionContainerComponent,
},
{
path: 'noi',
Expand Down
4 changes: 3 additions & 1 deletion alcs-frontend/src/app/features/admin/admin.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { CeoCriterionComponent } from './ceo-criterion/ceo-criterion.component';
import { ConfigurationComponent } from './configuration/configuration.component';
import { MaintenanceBannerConfirmationDialogComponent } from './configuration/maintenance-banner-confirmation-dialog/maintenance-banner-confirmation-dialog.component';
import { DecisionConditionTypesDialogComponent } from './decision-condition-types/decision-condition-types-dialog/decision-condition-types-dialog.component';
import { DecisionConditionContainerComponent } from './decision-condition-types/decision-condition-container.component';
import { DecisionConditionTypesComponent } from './decision-condition-types/decision-condition-types.component';
import { DecisionMakerDialogComponent } from './decision-maker/decision-maker-dialog/decision-maker-dialog.component';
import { DecisionMakerComponent } from './decision-maker/decision-maker.component';
Expand Down Expand Up @@ -54,8 +55,8 @@ const routes: Routes = [
UnarchiveComponent,
DecisionMakerComponent,
DecisionMakerDialogComponent,
DecisionConditionTypesComponent,
DecisionConditionTypesDialogComponent,
DecisionConditionTypesComponent,
CardStatusComponent,
CardStatusDialogComponent,
BoardManagementComponent,
Expand All @@ -67,6 +68,7 @@ const routes: Routes = [
TagComponent,
TagDialogComponent,
TagContainerComponent,
DecisionConditionContainerComponent,
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<mat-tab-group id="conditions" mat-align-tabs="start">
<mat-tab>
<ng-template mat-tab-label>
<span class="tab-label">Application</span>
</ng-template>
<br />
<app-decision-condition-types [service]="applicationService" />
</mat-tab>

<mat-tab>
<ng-template mat-tab-label>
<span class="tab-label">Notice of Intent</span>
</ng-template>
<br />
<app-decision-condition-types [service]="noiService" />
</mat-tab>
</mat-tab-group>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.tab-label {
font-weight: 700;
font-size: 16px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Component } from '@angular/core';
import { ApplicationDecisionConditionTypesService } from '../../../services/application/application-decision-condition-types/application-decision-condition-types.service';
import { NoticeofIntentDecisionConditionTypesService } from '../../../services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service';

@Component({
selector: 'app-decision-condition-container',
templateUrl: './decision-condition-container.component.html',
styleUrls: ['./decision-condition-container.component.scss'],
})
export class DecisionConditionContainerComponent {

applicationService: ApplicationDecisionConditionTypesService;
noiService: NoticeofIntentDecisionConditionTypesService;

constructor(
private aplicationDecisionConditionTypesService: ApplicationDecisionConditionTypesService,
private noiDecisionConditionTypesService: NoticeofIntentDecisionConditionTypesService,
) {
this.applicationService = this.aplicationDecisionConditionTypesService;
this.noiService = this.noiDecisionConditionTypesService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { CeoCriterionService } from '../../../../services/ceo-criterion/ceo-criterion.service';
import { ApplicationDecisionConditionTypesService } from '../../../../services/application/application-decision-condition-types/application-decision-condition-types.service';

import { DecisionConditionTypesDialogComponent } from './decision-condition-types-dialog.component';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { ApplicationDecisionConditionTypeDto } from '../../../../services/application/decision/application-decision-v2/application-decision-v2.dto';
import { ApplicationDecisionConditionTypesService } from '../../../../services/application/application-decision-condition-types/application-decision-condition-types.service';
import { DecisionDialogDataInterface } from '../decision-dialog-data.interface';
import { NoticeofIntentDecisionConditionTypesService } from '../../../../services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service';

@Component({
selector: 'app-decision-condition-types-dialog',
Expand All @@ -15,18 +16,18 @@ export class DecisionConditionTypesDialogComponent {

isLoading = false;
isEdit = false;

service: ApplicationDecisionConditionTypesService | NoticeofIntentDecisionConditionTypesService | undefined;
constructor(
@Inject(MAT_DIALOG_DATA) public data: ApplicationDecisionConditionTypeDto | undefined,
@Inject(MAT_DIALOG_DATA) public data: DecisionDialogDataInterface | undefined,
private dialogRef: MatDialogRef<DecisionConditionTypesDialogComponent>,
private decisionConditionTypesService: ApplicationDecisionConditionTypesService
) {
if (data) {
this.description = data.description;
this.label = data.label;
this.code = data.code;
this.service = data?.service;
if (data?.content) {
this.description = data.content.description;
this.label = data.content.label;
this.code = data.content.code;
}
this.isEdit = !!data;
this.isEdit = !!data?.content;
}

async onSubmit() {
Expand All @@ -37,11 +38,11 @@ export class DecisionConditionTypesDialogComponent {
label: this.label,
description: this.description,
};

if (!this.service) return;
if (this.isEdit) {
await this.decisionConditionTypesService.update(this.code, dto);
await this.service.update(this.code, dto);
} else {
await this.decisionConditionTypesService.create(dto);
await this.service.create(dto);
}
this.isLoading = false;
this.dialogRef.close(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import { Component, OnInit } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Subject } from 'rxjs';
import { ApplicationDecisionConditionTypeDto } from '../../../services/application/decision/application-decision-v2/application-decision-v2.dto';
import { ApplicationDecisionConditionTypesService } from '../../../services/application/application-decision-condition-types/application-decision-condition-types.service';
import { ConfirmationDialogService } from '../../../shared/confirmation-dialog/confirmation-dialog.service';
import { DecisionConditionTypesDialogComponent } from './decision-condition-types-dialog/decision-condition-types-dialog.component';
import { ApplicationDecisionConditionTypesService } from '../../../services/application/application-decision-condition-types/application-decision-condition-types.service';
import { NoticeofIntentDecisionConditionTypesService } from '../../../services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service';
import { NoticeOfIntentDecisionConditionTypeDto } from '../../../services/notice-of-intent/decision-v2/notice-of-intent-decision.dto';

@Component({
selector: 'app-decision-condition-types',
templateUrl: './decision-condition-types.component.html',
styleUrls: ['./decision-condition-types.component.scss'],
})
export class DecisionConditionTypesComponent implements OnInit {

@Input() public service: ApplicationDecisionConditionTypesService | NoticeofIntentDecisionConditionTypesService | undefined;

destroy = new Subject<void>();

decisionConditionTypeDtos: ApplicationDecisionConditionTypeDto[] = [];
decisionConditionTypeDtos: ApplicationDecisionConditionTypeDto[] | NoticeOfIntentDecisionConditionTypeDto[] = [];
displayedColumns: string[] = ['label', 'description', 'code', 'actions'];

constructor(
private decisionConditionTypesService: ApplicationDecisionConditionTypesService,
public dialog: MatDialog,
private confirmationDialogService: ConfirmationDialogService
) {}
Expand All @@ -28,14 +32,18 @@ export class DecisionConditionTypesComponent implements OnInit {
}

async fetch() {
this.decisionConditionTypeDtos = await this.decisionConditionTypesService.fetch();
if (!this.service) return;
this.decisionConditionTypeDtos = await this.service.fetch();
}

async onCreate() {
const dialog = this.dialog.open(DecisionConditionTypesDialogComponent, {
minWidth: '600px',
maxWidth: '800px',
width: '70%',
data: {
service: this.service,
},
});
dialog.beforeClosed().subscribe(async (result) => {
if (result) {
Expand All @@ -44,12 +52,15 @@ export class DecisionConditionTypesComponent implements OnInit {
});
}

async onEdit(decisionConditionTypeDto: ApplicationDecisionConditionTypeDto) {
async onEdit(dto: ApplicationDecisionConditionTypeDto | NoticeOfIntentDecisionConditionTypeDto) {
const dialog = this.dialog.open(DecisionConditionTypesDialogComponent, {
minWidth: '600px',
maxWidth: '800px',
width: '70%',
data: decisionConditionTypeDto,
data: {
service: this.service,
content: dto,
},
});
dialog.beforeClosed().subscribe(async (result) => {
if (result) {
Expand All @@ -58,14 +69,15 @@ export class DecisionConditionTypesComponent implements OnInit {
});
}

async onDelete(decisionConditionTypeDto: ApplicationDecisionConditionTypeDto) {
async onDelete(dto: ApplicationDecisionConditionTypeDto | NoticeOfIntentDecisionConditionTypeDto) {
this.confirmationDialogService
.openDialog({
body: `Are you sure you want to delete ${decisionConditionTypeDto.label}?`,
body: `Are you sure you want to delete ${dto.label}?`,
})
.subscribe(async (answer) => {
if (answer) {
await this.decisionConditionTypesService.delete(decisionConditionTypeDto.code);
if (!this.service) return;
await this.service.delete(dto.code);
await this.fetch();
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { NoticeofIntentDecisionConditionTypesService } from "../../../services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service";
import { ApplicationDecisionConditionTypesService } from "../../../services/application/application-decision-condition-types/application-decision-condition-types.service";
import { ApplicationDecisionConditionTypeDto } from "../../../services/application/decision/application-decision-v2/application-decision-v2.dto";

export interface DecisionDialogDataInterface {
service: ApplicationDecisionConditionTypesService | NoticeofIntentDecisionConditionTypesService;
content: ApplicationDecisionConditionTypeDto;
}
Loading

0 comments on commit 004766b

Please sign in to comment.