fixed column template bug in the suggestions data table, added chips for status
LocationBasedServices/smartguide/pipeline/head There was a failure building this commit

This commit is contained in:
2026-10-28 10:43:21 +01:00
parent 2baa01846f
commit bf85fbd760
2 changed files with 58 additions and 35 deletions
@@ -3,7 +3,9 @@
[columns]="columns"
[stickyHeader]="true">
</app-data-table>
<ng-template #createdAtTemplate let-suggestion>
<span>{{ suggestion.created_at | date: 'dd.MM.yyyy HH:mm' }}</span>
</ng-template>
<ng-template #actionTemplate let-suggestion>
<button
mat-stroked-button
@@ -14,5 +16,15 @@
</ng-template>
<ng-template #statusTemplate let-suggestion>
<span class="status">{{ statusLabel(suggestion.status) }}</span>
@switch (statusLabel(suggestion.status)) {
@case ('In Bearbeitung') {
<app-chip [color]="'info'"><span>In Bearbeitung</span></app-chip>
}
@case ('Angenommen') {
<app-chip [color]="'success'"><span>Angenommen</span></app-chip>
}
@case ('Abgelehnt') {
<app-chip [color]="'danger'"><span>Abgelehnt</span></app-chip>
}
}
</ng-template>
@@ -1,12 +1,13 @@
import {
Component,
AfterViewInit,
TemplateRef,
inject,
input,
output,
viewChild,
OnInit,
} from '@angular/core';
import { DatePipe } from '@angular/common';
import { MatButtonModule } from '@angular/material/button';
import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
@@ -19,53 +20,63 @@ import { OrgminerService } from '../../../api/api/orgminer.service';
import { HierarchyTreeEditorComponent } from '../hierarchy-chart/hierarchy-tree-editor/hierarchy-tree-editor.component';
import type { RawNode } from '../hierarchy-chart/hierarchy-chart.component';
import type { HierarchyEditorDialogData } from '../hierarchy-chart/hierarchy-edit-dialog/hierarchy-edit-dialog.component';
import { ChipComponent } from '../../../shared/ui/chip/chip.component';
@Component({
selector: 'app-hierarchy-suggestions',
standalone: true,
imports: [MatButtonModule, DataTableComponent],
imports: [MatButtonModule, DataTableComponent, DatePipe, ChipComponent],
templateUrl: './hierarchy-suggestions.component.html',
})
export class HierarchySuggestionsComponent implements AfterViewInit {
export class HierarchySuggestionsComponent implements OnInit {
readonly suggestions = input.required<HierarchySuggestion[]>();
readonly reload = output<void>();
readonly createdAtTemplate =
viewChild.required<TemplateRef<any>>('createdAtTemplate');
readonly actionTemplate =
viewChild.required<TemplateRef<unknown>>('actionTemplate');
viewChild.required<TemplateRef<any>>('actionTemplate');
readonly statusTemplate =
viewChild.required<TemplateRef<unknown>>('statusTemplate');
readonly columns: GenericColumn<HierarchySuggestion>[] = [
{
id: 'created_at',
header: 'Datum',
type: 'accessor',
accessorKey: 'created_at',
},
{
id: 'institution',
header: 'Institution',
type: 'accessor',
accessorKey: 'institution',
},
{
id: 'suggested_by',
header: 'Vorgeschlagen von',
type: 'accessor',
accessorKey: 'suggested_by',
},
{ id: 'status', header: 'Status', type: 'display' },
{ id: 'actions', header: 'Aktionen', type: 'display' },
];
viewChild.required<TemplateRef<any>>('statusTemplate');
columns: GenericColumn<HierarchySuggestion>[] = [];
private readonly dialog = inject(MatDialog);
private readonly orgminerService = inject(OrgminerService);
private readonly snackBar = inject(MatSnackBar);
ngAfterViewInit(): void {
const statusColumn = this.columns.find((column) => column.id === 'status');
const actionColumn = this.columns.find((column) => column.id === 'actions');
if (statusColumn) statusColumn.cellTemplate = this.statusTemplate();
if (actionColumn) actionColumn.cellTemplate = this.actionTemplate();
ngOnInit(): void {
this.columns = [
{
id: 'created_at',
header: 'Datum',
type: 'accessor',
accessorKey: 'created_at',
cellTemplate: this.createdAtTemplate(),
},
{
id: 'institution',
header: 'Institution',
type: 'accessor',
accessorKey: 'institution',
},
{
id: 'suggested_by',
header: 'Vorgeschlagen von',
type: 'accessor',
accessorKey: 'suggested_by',
},
{
id: 'status',
header: 'Status',
type: 'display',
cellTemplate: this.statusTemplate(),
},
{
id: 'actionsColumn',
header: 'Aktionen',
type: 'display',
cellTemplate: this.actionTemplate(),
},
];
}
statusLabel(status: HierarchySuggestion.StatusEnum): string {