From 3390acbc829b3ef583372b9d59f557439fd4403c Mon Sep 17 00:00:00 2001 From: ewandor Date: Sun, 12 Mar 2023 13:23:49 +0100 Subject: [PATCH] Display column title name in crudlist --- .../app/src/common/crud/jsonschemas.service.ts | 2 +- .../src/common/crud/list/list.component.html | 4 ++-- .../app/src/common/crud/list/list.component.ts | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/front/app/src/common/crud/jsonschemas.service.ts b/front/app/src/common/crud/jsonschemas.service.ts index de3a2efb..9f4f560b 100644 --- a/front/app/src/common/crud/jsonschemas.service.ts +++ b/front/app/src/common/crud/jsonschemas.service.ts @@ -181,7 +181,7 @@ export class JsonschemasService { } else if (this.is_union(resource)) { for (const ref of resource.oneOf!) { // @ts-ignore - if (this.has_property(ref, property_name)) { + if (this.has_descendant(ref, property_name)) { // @ts-ignore return this.get_descendant(ref, property_name); } diff --git a/front/app/src/common/crud/list/list.component.html b/front/app/src/common/crud/list/list.component.html index a806a7a4..986298bd 100644 --- a/front/app/src/common/crud/list/list.component.html +++ b/front/app/src/common/crud/list/list.component.html @@ -22,13 +22,13 @@ - + diff --git a/front/app/src/common/crud/list/list.component.ts b/front/app/src/common/crud/list/list.component.ts index 7d281935..3e01f565 100644 --- a/front/app/src/common/crud/list/list.component.ts +++ b/front/app/src/common/crud/list/list.component.ts @@ -16,6 +16,11 @@ interface State { searchFilters: {[key: string]: any} } +interface Column { + path: string, + title: string +} + @Component({ selector: 'crud-list', templateUrl: './list.component.html', @@ -32,7 +37,7 @@ export class ListComponent implements OnInit { @ViewChildren(NgbdSortableHeader) headers: QueryList = new QueryList(); - public displayedColumns: string[] = []; + public displayedColumns: Column[] = []; private _loading$ = new BehaviorSubject(true); //private _search$ = new Subject(); @@ -65,14 +70,20 @@ export class ListComponent implements OnInit { getColumnDefinition(schema: JSONSchema7) { for (let column of this.columns) { if (this.jsonSchemasService.path_exists(schema, column)) { - this.displayedColumns.push(column); + this.displayedColumns.push({ + path: column, + title: this.jsonSchemasService.get_property_by_path(schema, column).title! + }); } } if (this.displayedColumns.length == 0) { for (let param_name in schema.properties) { if (param_name != "_id") { - this.displayedColumns.push(param_name); + this.displayedColumns.push({ + path: param_name, + title: this.jsonSchemasService.get_property_by_path(schema, param_name).title! + }); } } }
{{ col }}{{ col.title }}
- +