Display column title name in crudlist
This commit is contained in:
@@ -181,7 +181,7 @@ export class JsonschemasService {
|
|||||||
} else if (this.is_union(resource)) {
|
} else if (this.is_union(resource)) {
|
||||||
for (const ref of resource.oneOf!) {
|
for (const ref of resource.oneOf!) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (this.has_property(ref, property_name)) {
|
if (this.has_descendant(ref, property_name)) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return this.get_descendant(ref, property_name);
|
return this.get_descendant(ref, property_name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,13 +22,13 @@
|
|||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<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>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let row of listData$ | async" (click)="onSelect(row._id)">
|
<tr *ngFor="let row of listData$ | async" (click)="onSelect(row._id)">
|
||||||
<td *ngFor="let col of this.displayedColumns">
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ interface State {
|
|||||||
searchFilters: {[key: string]: any}
|
searchFilters: {[key: string]: any}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Column {
|
||||||
|
path: string,
|
||||||
|
title: string
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'crud-list',
|
selector: 'crud-list',
|
||||||
templateUrl: './list.component.html',
|
templateUrl: './list.component.html',
|
||||||
@@ -32,7 +37,7 @@ export class ListComponent implements OnInit {
|
|||||||
|
|
||||||
@ViewChildren(NgbdSortableHeader) headers: QueryList<NgbdSortableHeader> = new QueryList<NgbdSortableHeader>();
|
@ViewChildren(NgbdSortableHeader) headers: QueryList<NgbdSortableHeader> = new QueryList<NgbdSortableHeader>();
|
||||||
|
|
||||||
public displayedColumns: string[] = [];
|
public displayedColumns: Column[] = [];
|
||||||
|
|
||||||
private _loading$ = new BehaviorSubject<boolean>(true);
|
private _loading$ = new BehaviorSubject<boolean>(true);
|
||||||
//private _search$ = new Subject<void>();
|
//private _search$ = new Subject<void>();
|
||||||
@@ -65,14 +70,20 @@ export class ListComponent implements OnInit {
|
|||||||
getColumnDefinition(schema: JSONSchema7) {
|
getColumnDefinition(schema: JSONSchema7) {
|
||||||
for (let column of this.columns) {
|
for (let column of this.columns) {
|
||||||
if (this.jsonSchemasService.path_exists(schema, column)) {
|
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) {
|
if (this.displayedColumns.length == 0) {
|
||||||
for (let param_name in schema.properties) {
|
for (let param_name in schema.properties) {
|
||||||
if (param_name != "_id") {
|
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