Display column title name in crudlist
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th *ngFor="let col of this.displayedColumns" scope="col" sortable="name" (sort)="onSort($event)">{{ col }}</th>
|
||||
<th *ngFor="let col of this.displayedColumns" scope="col" sortable="name" (sort)="onSort($event)">{{ col.title }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let row of listData$ | async" (click)="onSelect(row._id)">
|
||||
<td *ngFor="let col of this.displayedColumns">
|
||||
<ngb-highlight [result]="getColumnValue(row,col)" [term]="searchTerm"></ngb-highlight>
|
||||
<ngb-highlight [result]="getColumnValue(row, col.path)" [term]="searchTerm"></ngb-highlight>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -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<NgbdSortableHeader> = new QueryList<NgbdSortableHeader>();
|
||||
|
||||
public displayedColumns: string[] = [];
|
||||
public displayedColumns: Column[] = [];
|
||||
|
||||
private _loading$ = new BehaviorSubject<boolean>(true);
|
||||
//private _search$ = new Subject<void>();
|
||||
@@ -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!
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user