Skip to content

Commit 4f95191

Browse files
committed
Handle API response where report category returns '(NULL)' string, displaying empty cell instead of null text in table
1 parent cbc7cd5 commit 4f95191

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/app/system/manage-reports/manage-reports.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242

4343
<ng-container matColumnDef="reportCategory">
4444
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.Report Category' | translate }}</th>
45-
<td mat-cell *matCellDef="let report">{{ report.reportCategory | translateKey: 'catalogs' }}</td>
45+
<td mat-cell *matCellDef="let report">
46+
{{ report.reportCategory ? (report.reportCategory | translateKey: 'catalogs') : '' }}
47+
</td>
4648
</ng-container>
4749

4850
<ng-container matColumnDef="coreReport">

src/app/system/manage-reports/manage-reports.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { CompletionDialogComponent } from '../../configuration-wizard/completion
3535
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
3636
import { MatTooltip } from '@angular/material/tooltip';
3737
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
38+
import { log } from 'console';
3839

3940
/**
4041
* Manage Reports Component.
@@ -104,6 +105,7 @@ export class ManageReportsComponent implements OnInit, AfterViewInit {
104105
constructor() {
105106
this.route.data.subscribe((data: { reports: any }) => {
106107
this.reportsData = data.reports;
108+
console.log('Reports Data:', this.reportsData);
107109
});
108110
}
109111

@@ -118,7 +120,14 @@ export class ManageReportsComponent implements OnInit, AfterViewInit {
118120
* Initializes the data source, paginator and sorter for reports table.
119121
*/
120122
setReports() {
121-
this.dataSource = new MatTableDataSource(this.reportsData);
123+
// Transform data to replace "(NULL)" strings with null
124+
const transformedData = this.reportsData.map((report: any) => ({
125+
...report,
126+
reportCategory: report.reportCategory === '(NULL)' ? null : report.reportCategory,
127+
description: report.description === '(NULL)' ? null : report.description
128+
}));
129+
130+
this.dataSource = new MatTableDataSource(transformedData);
122131
this.dataSource.paginator = this.paginator;
123132
this.dataSource.sort = this.sort;
124133
}

0 commit comments

Comments
 (0)