add breadcrumbs

This commit is contained in:
Roland Schneider
2025-11-21 15:24:35 +01:00
parent dfc3afd4a9
commit b047ecc589
19 changed files with 294 additions and 73 deletions

View File

@@ -18,12 +18,11 @@ import { GenericTableSearchForm } from './generic-table-search-form/generic-tabl
export class GenericTable<T> implements OnInit {
@Input() config!: GenericTableConfig<T>;
public data$!: Observable<GetDataResponse<T>>;
sanitizer = inject(DomSanitizer);
parser = new DOMParser()
parser = new DOMParser();
ngOnInit(): void {
@@ -31,25 +30,25 @@ export class GenericTable<T> implements OnInit {
this.config.refresh$,
this.config.filter$.pipe(startWith({})),
this.config.page$.pipe(startWith(1)),
this.config.limit$.pipe(startWith(10))
this.config.limit$.pipe(startWith(10)),
]).pipe(
switchMap(([_, filter, page, limit]) => {
const query = { ...filter, page, limit: 10 };
console.info("filter is", filter)
console.info('filter is', filter);
return this.config.dataProvider.getData({
params: {
q: filter.term ?? '',
page,
limit
}
limit,
},
});
})
}),
);
}
resolveValue(item: T, column: ColumnDefinition<T>, cell?: CellDefinition<T>): any {
if ( cell) {
resolveValue(item: T, column: ColumnDefinition<T>, cell?: CellDefinition<T>): any {
if (cell) {
if (cell.value) {
if (typeof cell.value === 'string') {
return cell.value;
@@ -65,16 +64,16 @@ export class GenericTable<T> implements OnInit {
return '';
}
getComponentInputs(item: T|null, column: ColumnDefinition<T>, cell: CellDefinition<T>): { [key: string]: any } {
getComponentInputs(item: T | null, column: ColumnDefinition<T>, cell: CellDefinition<T>): { [key: string]: any } {
if (cell.componentInputs) {
return cell.componentInputs(item);
}
return { data: item }; // Default input
}
getAsHtml(str: string){
getAsHtml(str: string) {
// return this.sanitizer.bypassSecurityTrustHtml(str);
return this.sanitizer.bypassSecurityTrustHtml(this.parser.parseFromString(str, 'text/html').body.innerHTML);
return this.sanitizer.bypassSecurityTrustHtml(this.parser.parseFromString(str, 'text/html').body.innerHTML);
}
changePage(newPage: number): void {
@@ -84,7 +83,7 @@ export class GenericTable<T> implements OnInit {
}
protected searchTermChanged(searchTerm: any) {
console.info("searchterm",searchTerm);
console.info('searchterm', searchTerm);
this.config.page$.next(1);
this.config.filter$.next(searchTerm);
}
@@ -93,4 +92,16 @@ export class GenericTable<T> implements OnInit {
this.config.page$.next(1);
this.config.limit$.next(+value);
}
protected getValueStyleClass(columnDefinition: ColumnDefinition<T>, cellDefinition: CellDefinition<T> | boolean, item: T) {
console.info("co")
if ( (cellDefinition as any).hasOwnProperty("styleClass") ){
const def = (cellDefinition as CellDefinition<T>);
if (def && def.styleClass) {
return (columnDefinition.attribute as string) +" "+def.styleClass({definition: columnDefinition, cellDefinition: def, item});
}
}
return columnDefinition.attribute;
}
}