Skip to content

Commit 093f8a5

Browse files
authored
Merge pull request #2093 from bcgov/bugfix/ALCS-2448-NOIs
2448: Apply public search sorting fix to NOI's
2 parents 4c1bd92 + 87125ef commit 093f8a5

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

portal-frontend/src/app/features/public/notice-of-intent/alc-review/submission-documents/submission-documents.component.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { PublicDocumentDto } from '../../../../../services/public/public.dto';
77
import { PublicService } from '../../../../../services/public/public.service';
88
import { openFileInline } from '../../../../../shared/utils/file';
99

10+
type PublicDocumentWithoutTypeDto = Omit<PublicDocumentDto, 'type'>;
11+
1012
@Component({
1113
selector: 'app-submission-documents',
1214
templateUrl: './submission-documents.component.html',
@@ -19,13 +21,27 @@ export class PublicSubmissionDocumentsComponent implements OnInit, OnDestroy {
1921
@Input() documents!: PublicDocumentDto[];
2022
@Input() submission!: PublicNoticeOfIntentSubmissionDto;
2123

22-
@ViewChild(MatSort) sort!: MatSort;
2324
dataSource: MatTableDataSource<PublicDocumentDto> = new MatTableDataSource<PublicDocumentDto>();
25+
@ViewChild(MatSort) sort!: MatSort;
2426

2527
constructor(private publicService: PublicService) {}
2628

2729
ngOnInit(): void {
28-
this.dataSource = new MatTableDataSource(this.documents);
30+
this.dataSource.data = this.documents;
31+
this.dataSource.sortingDataAccessor = (
32+
{ type, ...rest }: PublicDocumentDto,
33+
sortHeaderId: string,
34+
): string | number => {
35+
if (sortHeaderId === 'type') {
36+
return type?.label ?? '';
37+
}
38+
39+
return (rest as PublicDocumentWithoutTypeDto)[sortHeaderId as keyof PublicDocumentWithoutTypeDto] ?? '';
40+
};
41+
}
42+
43+
ngAfterViewInit() {
44+
this.dataSource.sort = this.sort;
2945
}
3046

3147
async openFile(file: PublicDocumentDto) {

0 commit comments

Comments
 (0)