Skip to content

Commit

Permalink
Merge pull request #1988 from bcgov/backport/2024-11-18
Browse files Browse the repository at this point in the history
Backport-2024-11-18
  • Loading branch information
Abradat authored Nov 18, 2024
2 parents 156b3f1 + f4c1f7e commit 4de6610
Show file tree
Hide file tree
Showing 46 changed files with 968 additions and 458 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@
</td>
</ng-container>

<ng-container matColumnDef="portalStatus">
<ng-container matColumnDef="status">
<th class="type-cell" mat-header-cell *matHeaderCellDef mat-sort-header>Portal Status</th>
<td mat-cell class="type-cell" *matCellDef="let element">
<app-application-submission-status-type-pill
*ngIf="element.status"
[type]="element.status"
></app-application-submission-status-type-pill>
<app-spinner-status *ngIf="!element.status" />
</td>
</ng-container>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface SearchResult {
referenceId: string;
board?: string;
class: string;
status?: ApplicationSubmissionStatusPill;
status?: ApplicationSubmissionStatusPill | null;
}

@Component({
Expand All @@ -42,7 +42,7 @@ export class ApplicationSearchTableComponent {

@Output() tableChange = new EventEmitter<TableChange>();

displayedColumns = ['fileId', 'dateSubmitted', 'ownerName', 'type', 'government', 'portalStatus'];
displayedColumns = ['fileId', 'dateSubmitted', 'ownerName', 'type', 'government', 'status'];
dataSource: SearchResult[] = [];
itemsPerPage = 20;
total = 0;
Expand Down Expand Up @@ -88,24 +88,22 @@ export class ApplicationSearchTableComponent {
private mapApplications(applications: ApplicationSearchResultDto[]): SearchResult[] {
return applications.map((e) => {
const status = this.statuses.find((st) => st.code === e.status);

return {
fileNumber: e.fileNumber,
dateSubmitted: e.dateSubmitted,
ownerName: e.ownerName,
type: e.type,
localGovernmentName: e.localGovernmentName,
portalStatus: e.portalStatus,
referenceId: e.referenceId,
board: e.boardCode,
class: e.class,
status: {
backgroundColor: status?.portalBackgroundColor ?? defaultStatusBackgroundColour,
textColor: status?.portalColor ?? defaultStatusColour,
borderColor: status?.portalBackgroundColor,
label: status?.label,
shortLabel: status?.label,
},
status: status ? {
backgroundColor: status.portalBackgroundColor ?? defaultStatusBackgroundColour,
textColor: status.portalColor ?? defaultStatusColour,
borderColor: status.portalBackgroundColor,
label: status.label,
shortLabel: status.label,
} : null,
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@
</td>
</ng-container>

<ng-container matColumnDef="portalStatus">
<ng-container matColumnDef="status">
<th class="type-cell" mat-header-cell *matHeaderCellDef mat-sort-header>Portal Status</th>
<td mat-cell class="type-cell" *matCellDef="let element">
<app-application-submission-status-type-pill
*ngIf="element.status"
[type]="element.status"
></app-application-submission-status-type-pill>
<app-spinner-status *ngIf="!element.status" />
</td>
</ng-container>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface SearchResult {
referenceId: string;
board?: string;
class: string;
status?: ApplicationSubmissionStatusPill;
status?: ApplicationSubmissionStatusPill | null;
}

@Component({
Expand All @@ -41,7 +41,7 @@ export class NoticeOfIntentSearchTableComponent {

@Output() tableChange = new EventEmitter<TableChange>();

displayedColumns = ['fileId', 'dateSubmitted', 'ownerName', 'type', 'government', 'portalStatus'];
displayedColumns = ['fileId', 'dateSubmitted', 'ownerName', 'type', 'government', 'status'];
dataSource: SearchResult[] = [];

itemsPerPage = 20;
Expand Down Expand Up @@ -98,13 +98,13 @@ export class NoticeOfIntentSearchTableComponent {
referenceId: e.referenceId,
board: e.boardCode,
class: e.class,
status: {
status: status ? {
backgroundColor: status!.alcsBackgroundColor,
textColor: status!.alcsColor,
borderColor: status!.alcsBackgroundColor,
label: status!.label,
shortLabel: status!.label,
},
} : null,
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@
</td>
</ng-container>

<ng-container matColumnDef="portalStatus">
<ng-container matColumnDef="status">
<th class="type-cell" mat-header-cell *matHeaderCellDef mat-sort-header>Portal Status</th>
<td mat-cell class="type-cell" *matCellDef="let element">
<app-application-submission-status-type-pill
*ngIf="element.status"
[type]="element.status"
></app-application-submission-status-type-pill>
<app-spinner-status *ngIf="!element.status" />
</td>
</ng-container>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface SearchResult {
referenceId: string;
board?: string;
class: string;
status?: ApplicationSubmissionStatusPill;
status?: ApplicationSubmissionStatusPill | null;
}

@Component({
Expand All @@ -41,7 +41,7 @@ export class NotificationSearchTableComponent {

@Output() tableChange = new EventEmitter<TableChange>();

displayedColumns = ['fileId', 'dateSubmitted', 'ownerName', 'type', 'government', 'portalStatus'];
displayedColumns = ['fileId', 'dateSubmitted', 'ownerName', 'type', 'government', 'status'];
dataSource: SearchResult[] = [];
itemsPerPage = 20;
total = 0;
Expand Down Expand Up @@ -97,13 +97,13 @@ export class NotificationSearchTableComponent {
referenceId: e.referenceId,
board: e.boardCode,
class: e.class,
status: {
status: status ? {
backgroundColor: status ? status!.alcsBackgroundColor : '',
textColor: status ? status!.alcsColor : '',
borderColor: status ? status!.alcsBackgroundColor : '',
label: status ? status!.label : '',
shortLabel: status ? status!.label : '',
},
} : null,
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ <h4>Date Range</h4>

<div class="search-fields-wrapper search-result-wrapper" *ngIf="!searchResultsHidden">
<h2 class="search-title">Search Results:</h2>
<mat-tab-group id="results" mat-align-tabs="start" [mat-stretch-tabs]="isCommissioner" #searchResultTabs>
<mat-tab-group id="results" mat-align-tabs="start" [mat-stretch-tabs]="isCommissioner" (selectedTabChange)="onTabChanged($event.index);" #searchResultTabs>
<mat-tab>
<ng-template mat-tab-label> Applications: {{ applicationTotal }}</ng-template>
<app-application-search-table
Expand Down
73 changes: 73 additions & 0 deletions alcs-frontend/src/app/features/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ import { COMMA, ENTER } from '@angular/cdk/keycodes';
export const defaultStatusBackgroundColour = '#ffffff';
export const defaultStatusColour = '#313132';

enum searchTabs {
Applications = 0,
Nois = 1,
Plannings = 2,
Notifications = 3,
Inquiries = 4,
}

@Component({
selector: 'app-search',
templateUrl: './search.component.html',
Expand Down Expand Up @@ -346,6 +354,7 @@ export class SearchComponent implements OnInit, OnDestroy {

this.applications = result?.data ?? [];
this.applicationTotal = result?.total ?? 0;
this.updateApplicationStatuses();
}

async onNoticeOfIntentSearch() {
Expand All @@ -354,6 +363,7 @@ export class SearchComponent implements OnInit, OnDestroy {

this.noticeOfIntents = result?.data ?? [];
this.noticeOfIntentTotal = result?.total ?? 0;
this.updateNoiStatuses();
}

async onPlanningReviewSearch() {
Expand All @@ -370,6 +380,7 @@ export class SearchComponent implements OnInit, OnDestroy {

this.notifications = result?.data ?? [];
this.notificationTotal = result?.total ?? 0;
this.updateNotificationStatuses();
}

async onInquirySearch() {
Expand Down Expand Up @@ -407,6 +418,22 @@ export class SearchComponent implements OnInit, OnDestroy {
}
}

async onTabChanged(index: number) {
switch (index) {
case searchTabs.Applications:
await this.updateApplicationStatuses();
break;
case searchTabs.Nois:
await this.updateNoiStatuses();
break;
case searchTabs.Notifications:
await this.updateNotificationStatuses();
break;
default:
break;
}
}

onFileTypeChange(fileTypes: string[]) {
this.componentTypeControl.setValue(fileTypes);
}
Expand Down Expand Up @@ -529,6 +556,7 @@ export class SearchComponent implements OnInit, OnDestroy {
];

this.tabGroup.selectedIndex = searchCounts.indexOf(Math.max(...searchCounts));
this.onTabChanged(this.tabGroup.selectedIndex);
}

private formatStringSearchParam(value: string | undefined | null) {
Expand Down Expand Up @@ -563,4 +591,49 @@ export class SearchComponent implements OnInit, OnDestroy {
this.allStatuses = result;
this.allStatuses.sort((a, b) => (a.label > b.label ? 1 : -1));
}

private async updateApplicationStatuses() {
const needsUpdate = this.applications.filter((a) => a.status === null).length > 0;
if (!needsUpdate) return;
const statusUpdates = await this.searchService.advancedSearchApplicationStatusFetch(
this.applications.map((a) => a.fileNumber)
);
this.applications = this.applications.map((a) => {
const updatedStatus = statusUpdates ? statusUpdates.find((s) => s.fileNumber === a.fileNumber) : null;
return {
...a,
status: updatedStatus ? updatedStatus.status : '',
}
});
}

private async updateNoiStatuses() {
const needsUpdate = this.noticeOfIntents.filter((a) => a.status === null).length > 0;
if (!needsUpdate) return;
const statusUpdates = await this.searchService.advancedSearchNoiStatusFetch(
this.noticeOfIntents.map((a) => a.fileNumber)
);
this.noticeOfIntents = this.noticeOfIntents.map((a) => {
const updatedStatus = statusUpdates ? statusUpdates.find((s) => s.fileNumber === a.fileNumber) : null;
return {
...a,
status: updatedStatus ? updatedStatus.status : '',
}
});
}

private async updateNotificationStatuses() {
const needsUpdate = this.notifications.filter((a) => a.status === null).length > 0;
if (!needsUpdate) return;
const statusUpdates = await this.searchService.advancedSearchNotificationStatusFetch(
this.notifications.map((a) => a.fileNumber)
);
this.notifications = this.notifications.map((a) => {
const updatedStatus = statusUpdates ? statusUpdates.find((s) => s.fileNumber === a.fileNumber) : null;
return {
...a,
status: updatedStatus ? updatedStatus.status : '',
}
});
}
}
2 changes: 2 additions & 0 deletions alcs-frontend/src/app/features/search/search.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { NotificationSearchTableComponent } from './notification-search-table/no
import { SearchComponent } from './search.component';
import { InquirySearchTableComponent } from './inquiry-search-table/inquiry-search-table.component';
import { MatChipsModule } from '@angular/material/chips';
import { SpinnerStatusComponent } from './spinner-status/spinner-status.component';

const routes: Routes = [
{
Expand All @@ -30,6 +31,7 @@ const routes: Routes = [
NotificationSearchTableComponent,
FileTypeFilterDropDownComponent,
InquirySearchTableComponent,
SpinnerStatusComponent,
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="spinner-container">
<mat-spinner class="spinner-overlay"></mat-spinner>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.spinner-container {
width: 25px;
height: 25px;
display: flex;
align-items: center;
justify-content: center;
}

.spinner-overlay {
z-index: 2;
opacity: 0.4;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-spinner-status',
templateUrl: './spinner-status.component.html',
styleUrls: ['./spinner-status.component.scss'],
})
export class SpinnerStatusComponent {}
7 changes: 6 additions & 1 deletion alcs-frontend/src/app/services/search/search.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface ApplicationSearchResultDto {
dateSubmitted: number;
portalStatus?: string;
class: string;
status: string;
status?: string | null;
}

export interface NoticeOfIntentSearchResultDto extends ApplicationSearchResultDto {}
Expand Down Expand Up @@ -93,3 +93,8 @@ export interface SearchResultDto {
boardCode?: string;
label?: ApplicationTypeDto;
}

export interface StatusUpdateSearchResultDto {
fileNumber: string;
status: string;
}
Loading

0 comments on commit 4de6610

Please sign in to comment.