Skip to content

Commit bd14a7a

Browse files
authored
Merge pull request #1901 from bcgov/develop
Deployment PR - 1337
2 parents b53a438 + 8c9cbf1 commit bd14a7a

File tree

242 files changed

+11646
-2440
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+11646
-2440
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ playwright-report/
1515
playwright/.cache/
1616
.~lock.*
1717

18-
/ora2pg_data
18+
/ora2pg_data

alcs-frontend/src/app/features/admin/admin.component.ts

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { HolidayComponent } from './holiday/holiday.component';
1010
import { LocalGovernmentComponent } from './local-government/local-government.component';
1111
import { NoiSubtypeComponent } from './noi-subtype/noi-subtype.component';
1212
import { UnarchiveComponent } from './unarchive/unarchive.component';
13+
import { TagContainerComponent } from './tag/tag-container.component';
1314

1415
export const childRoutes = [
1516
{
@@ -72,6 +73,12 @@ export const childRoutes = [
7273
icon: 'settings_applications',
7374
component: ConfigurationComponent,
7475
},
76+
{
77+
path: 'tag',
78+
menuTitle: 'Tags/Categories',
79+
icon: 'sell',
80+
component: TagContainerComponent,
81+
},
7582
];
7683

7784
@Component({

alcs-frontend/src/app/features/admin/admin.module.ts

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common';
33
import { NgModule } from '@angular/core';
44
import { MatChipsModule } from '@angular/material/chips';
55
import { MatPaginatorModule } from '@angular/material/paginator';
6+
import { MatTabsModule } from '@angular/material/tabs';
67
import { RouterModule, Routes } from '@angular/router';
78
import { SharedModule } from '../../shared/shared.module';
89
import { AdminComponent, childRoutes } from './admin.component';
@@ -25,6 +26,11 @@ import { LocalGovernmentComponent } from './local-government/local-government.co
2526
import { NoiSubtypeDialogComponent } from './noi-subtype/noi-subtype-dialog/noi-subtype-dialog.component';
2627
import { NoiSubtypeComponent } from './noi-subtype/noi-subtype.component';
2728
import { UnarchiveComponent } from './unarchive/unarchive.component';
29+
import { TagCategoryComponent } from './tag/tag-category/tag-category.component';
30+
import { TagCategoryDialogComponent } from './tag/tag-category/tag-category-dialog/tag-category-dialog.component';
31+
import { TagComponent } from './tag/tag.component';
32+
import { TagDialogComponent } from './tag/tag-dialog/tag-dialog.component';
33+
import { TagContainerComponent } from './tag/tag-container.component';
2834

2935
const routes: Routes = [
3036
{
@@ -56,6 +62,11 @@ const routes: Routes = [
5662
BoardManagementDialogComponent,
5763
ConfigurationComponent,
5864
MaintenanceBannerConfirmationDialogComponent,
65+
TagCategoryComponent,
66+
TagCategoryDialogComponent,
67+
TagComponent,
68+
TagDialogComponent,
69+
TagContainerComponent,
5970
],
6071
imports: [
6172
CommonModule,
@@ -64,6 +75,7 @@ const routes: Routes = [
6475
MatPaginatorModule,
6576
DragDropModule,
6677
MatChipsModule,
78+
MatTabsModule,
6779
],
6880
})
6981
export class AdminModule {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<div mat-dialog-title>
2+
<h4>{{ isEdit ? 'Edit' : 'Create New' }} Category</h4>
3+
</div>
4+
<div mat-dialog-content class="dialog">
5+
<form (ngSubmit)="onSubmit()" #form="ngForm">
6+
7+
<div class="full-width">
8+
<mat-form-field class="description" appearance="outline">
9+
<mat-label>Name</mat-label>
10+
<input required matInput id="name" [(ngModel)]="name" name="name" (ngModelChange)="onChange()" [formControl]="nameControl" />
11+
</mat-form-field>
12+
<div class="warning-section">
13+
<div class="warning" *ngIf="showNameWarning">
14+
<mat-icon>info</mat-icon> <b>Warning: </b>&nbsp; Category already exists. Choose a different category name.
15+
</div>
16+
</div>
17+
</div>
18+
19+
</form>
20+
21+
<mat-dialog-actions align="end">
22+
<div class="button-container">
23+
<button mat-stroked-button color="primary" mat-dialog-close="false">Close</button>
24+
<button
25+
[loading]="isLoading"
26+
(click)="onSubmit()"
27+
mat-flat-button
28+
color="primary"
29+
type="submit"
30+
[disabled]="!form.form.valid"
31+
>
32+
Save
33+
</button>
34+
</div>
35+
</mat-dialog-actions>
36+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@use '../../../../../../styles/colors';
2+
3+
mat-dialog-title {
4+
margin-bottom: 24px;
5+
}
6+
7+
.warning-banner {
8+
margin-top: 8px;
9+
background-color: green;
10+
padding: 16px;
11+
12+
.display-none {
13+
display: none !important;
14+
}
15+
}
16+
17+
.warning {
18+
padding: 16px;
19+
font-size: 14px;
20+
background-color: rgba(colors.$field-warning-bg-color, 0.5);
21+
border-radius: 8px;
22+
display: flex;
23+
align-items: center;
24+
color: colors.$dark-contrast-text;
25+
margin-top: 8px;
26+
27+
mat-icon {
28+
color: colors.$dark-contrast-text;
29+
margin-right: 16px;
30+
}
31+
}
32+
33+
.dialog {
34+
padding: 24px;
35+
36+
form {
37+
display: grid;
38+
grid-template-columns: 1fr 1fr;
39+
row-gap: 24px;
40+
column-gap: 24px;
41+
margin-bottom: 12px;
42+
43+
.description {
44+
margin-top: 20px;
45+
}
46+
47+
.full-width {
48+
grid-column: 1/3;
49+
}
50+
51+
.mat-mdc-form-field {
52+
width: 100%;
53+
}
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { ComponentFixture, TestBed } from '@angular/core/testing';
3+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4+
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
5+
import { TagCategoryService } from '../../../../../services/tag/tag-category/tag-category.service';
6+
7+
import { TagCategoryDialogComponent } from './tag-category-dialog.component';
8+
9+
describe('TagCategoryDialogComponent', () => {
10+
let component: TagCategoryDialogComponent;
11+
let fixture: ComponentFixture<TagCategoryDialogComponent>;
12+
13+
beforeEach(async () => {
14+
await TestBed.configureTestingModule({
15+
imports: [ReactiveFormsModule, FormsModule],
16+
declarations: [TagCategoryDialogComponent],
17+
providers: [
18+
{ provide: MAT_DIALOG_DATA, useValue: undefined },
19+
{ provide: MatDialogRef, useValue: {} },
20+
{
21+
provide: TagCategoryService,
22+
useValue: {},
23+
},
24+
],
25+
schemas: [NO_ERRORS_SCHEMA],
26+
}).compileComponents();
27+
28+
fixture = TestBed.createComponent(TagCategoryDialogComponent);
29+
component = fixture.componentInstance;
30+
fixture.detectChanges();
31+
});
32+
33+
it('should create', () => {
34+
expect(component).toBeTruthy();
35+
});
36+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { Component, Inject } from '@angular/core';
2+
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
3+
import { TagCategoryDto } from '../../../../../services/tag/tag-category/tag-category.dto';
4+
import { TagCategoryService } from '../../../../../services/tag/tag-category/tag-category.service';
5+
import { FormControl } from '@angular/forms';
6+
7+
@Component({
8+
selector: 'app-tag-category-dialog',
9+
templateUrl: './tag-category-dialog.component.html',
10+
styleUrls: ['./tag-category-dialog.component.scss'],
11+
})
12+
export class TagCategoryDialogComponent {
13+
name = '';
14+
uuid = '';
15+
16+
isLoading = false;
17+
isEdit = false;
18+
showNameWarning = false;
19+
nameControl = new FormControl();
20+
21+
constructor(
22+
@Inject(MAT_DIALOG_DATA) public data: TagCategoryDto | undefined,
23+
private dialogRef: MatDialogRef<TagCategoryDialogComponent>,
24+
private tagCategoryService: TagCategoryService,
25+
) {
26+
if (data) {
27+
this.uuid = data.uuid;
28+
this.name = data.name;
29+
}
30+
this.isEdit = !!data;
31+
}
32+
33+
async onSubmit() {
34+
this.isLoading = true;
35+
36+
const dto: TagCategoryDto = {
37+
uuid: this.uuid,
38+
name: this.name,
39+
};
40+
41+
if (this.isEdit) {
42+
try {
43+
await this.tagCategoryService.update(this.uuid, dto);
44+
} catch (e) {
45+
this.showWarning();
46+
this.isLoading = false;
47+
return;
48+
}
49+
} else {
50+
try {
51+
await this.tagCategoryService.create(dto);
52+
} catch (e) {
53+
this.showWarning();
54+
this.isLoading = false;
55+
return;
56+
}
57+
}
58+
this.isLoading = false;
59+
this.dialogRef.close(true);
60+
}
61+
62+
onChange() {
63+
this.showNameWarning = false;
64+
}
65+
66+
private showWarning() {
67+
this.showNameWarning = true;
68+
this.nameControl.setErrors({"invalid": true});
69+
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<div class="container">
2+
<div class="actions-bar">
3+
<div>
4+
<div class="search-control">
5+
<mat-form-field>
6+
<mat-label>Enter category</mat-label>
7+
<input matInput placeholder="Category Name" type="text" [(ngModel)]="search" [matAutocomplete]="auto" (ngModelChange)='updateFilter($event)'>
8+
<mat-autocomplete autoActiveFirstOption #auto="matAutocomplete">
9+
<mat-option *ngFor="let option of filteredOptions" [value]="option">
10+
{{option}}
11+
</mat-option>
12+
</mat-autocomplete>
13+
</mat-form-field>
14+
</div>
15+
<div class="search-control">
16+
<button mat-flat-button color="primary" (click)="fetch()">Search</button>
17+
</div>
18+
</div>
19+
<div class="right">
20+
<button mat-flat-button color="primary" (click)="onCreate()">Create</button>
21+
</div>
22+
</div>
23+
24+
<table mat-table [dataSource]="categories">
25+
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
26+
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
27+
28+
<ng-container matColumnDef="number">
29+
<th mat-header-cell *matHeaderCellDef>Number</th>
30+
<td mat-cell *matCellDef="let row">{{ row.number }}</td>
31+
</ng-container>
32+
33+
<ng-container matColumnDef="name">
34+
<th mat-header-cell *matHeaderCellDef>Name</th>
35+
<td mat-cell *matCellDef="let row">{{ row.name }}</td>
36+
</ng-container>
37+
38+
<ng-container matColumnDef="actions">
39+
<th mat-header-cell *matHeaderCellDef>Actions</th>
40+
<td mat-cell *matCellDef="let row">
41+
<button class="edit-btn" mat-flat-button (click)="onEdit(row)">
42+
<mat-icon>edit</mat-icon>
43+
</button>
44+
<button class="delete-btn" mat-flat-button (click)="onDelete(row)">
45+
<mat-icon>delete</mat-icon>
46+
</button>
47+
</td>
48+
</ng-container>
49+
</table>
50+
51+
<mat-paginator
52+
[length]="total"
53+
[pageSize]="20"
54+
[pageSizeOptions]="[20, 50, 100]"
55+
(page)="onPageChange($event)"
56+
aria-label="Select page of categories"
57+
></mat-paginator>
58+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@use '../../../../../styles/colors';
2+
3+
.container {
4+
.actions-bar {
5+
margin-top: 30px;
6+
display: flex;
7+
justify-content: space-between;
8+
}
9+
10+
.search-control {
11+
margin-right: 30px;
12+
display: inline-block;
13+
}
14+
15+
table {
16+
margin: 35px 2px 30px 2px;
17+
box-shadow: 2px 2px 8px 2px #00000040;
18+
}
19+
20+
.mdc-data-table__table {
21+
min-width: unset!important;
22+
width: 99%;
23+
}
24+
25+
.delete-btn {
26+
color: colors.$error-color;
27+
width: 48px!important;
28+
min-width: unset!important;
29+
}
30+
31+
.mat-icon {
32+
margin-right: 1px;
33+
}
34+
35+
.edit-btn {
36+
color: colors.$primary-color-dark;
37+
width: 48px!important;
38+
min-width: unset!important;
39+
}
40+
41+
.mat-column-name {
42+
width: 70%;
43+
}
44+
45+
.mat-column-actions {
46+
width: 30%;
47+
}
48+
}

0 commit comments

Comments
 (0)