mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4947] Array type supported in data table columns (#5165)
* [WIP] [ADF-4947] Array type supported in data table columns * * removed resolver for aria label * * process services feature added * * fixed docs
This commit is contained in:
@@ -77,6 +77,10 @@ export class DataTableCellComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
tooltip: string;
|
||||
|
||||
/** Custom resolver function which is used to parse dynamic column objects */
|
||||
@Input()
|
||||
resolverFn: (row: DataRow, col: DataColumn) => any = null;
|
||||
|
||||
protected onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(protected alfrescoApiService: AlfrescoApiService) {}
|
||||
@@ -98,7 +102,7 @@ export class DataTableCellComponent implements OnInit, OnDestroy {
|
||||
|
||||
protected updateValue() {
|
||||
if (this.column && this.column.key && this.row && this.data) {
|
||||
const value = this.data.getValue(this.row, this.column);
|
||||
const value = this.data.getValue(this.row, this.column, this.resolverFn);
|
||||
|
||||
this.value$.next(value);
|
||||
|
||||
|
@@ -141,6 +141,7 @@
|
||||
[data]="data"
|
||||
[column]="col"
|
||||
[row]="row"
|
||||
[resolverFn]="resolverFn"
|
||||
[tooltip]="getCellTooltip(row, col)">
|
||||
</adf-date-cell>
|
||||
</div>
|
||||
@@ -150,6 +151,7 @@
|
||||
[data]="data"
|
||||
[column]="col"
|
||||
[row]="row"
|
||||
[resolverFn]="resolverFn"
|
||||
[tooltip]="getCellTooltip(row, col)">
|
||||
</adf-location-cell>
|
||||
</div>
|
||||
@@ -159,6 +161,7 @@
|
||||
[data]="data"
|
||||
[column]="col"
|
||||
[row]="row"
|
||||
[resolverFn]="resolverFn"
|
||||
[tooltip]="getCellTooltip(row, col)">
|
||||
</adf-filesize-cell>
|
||||
</div>
|
||||
@@ -169,6 +172,7 @@
|
||||
[data]="data"
|
||||
[column]="col"
|
||||
[row]="row"
|
||||
[resolverFn]="resolverFn"
|
||||
[tooltip]="getCellTooltip(row, col)">
|
||||
</adf-datatable-cell>
|
||||
</div>
|
||||
@@ -177,6 +181,7 @@
|
||||
[editable]="col.editable"
|
||||
[data]="data"
|
||||
[column]="col"
|
||||
[resolverFn]="resolverFn"
|
||||
[row]="row">
|
||||
</adf-json-cell>
|
||||
</div>
|
||||
@@ -189,7 +194,7 @@
|
||||
<div class="adf-cell-value" tabindex="0">
|
||||
<ng-container
|
||||
[ngTemplateOutlet]="col.template"
|
||||
[ngTemplateOutletContext]="{ $implicit: { data: data, row: row, col: col }, value: data.getValue(row, col) }">
|
||||
[ngTemplateOutletContext]="{ $implicit: { data: data, row: row, col: col }, value: data.getValue(row, col, resolverFn) }">
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -161,6 +161,13 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
||||
@Input()
|
||||
rowMenuCacheEnabled = true;
|
||||
|
||||
/**
|
||||
* Custom resolver function which is used to parse dynamic column objects
|
||||
* see the docs to learn how to configure a resolverFn.
|
||||
*/
|
||||
@Input()
|
||||
resolverFn: (row: DataRow, col: DataColumn) => any = null;
|
||||
|
||||
noContentTemplate: TemplateRef<any>;
|
||||
noPermissionTemplate: TemplateRef<any>;
|
||||
loadingTemplate: TemplateRef<any>;
|
||||
|
@@ -52,12 +52,12 @@ export class JsonCellComponent extends DataTableCellComponent implements OnInit
|
||||
|
||||
ngOnInit() {
|
||||
if (this.column && this.column.key && this.row && this.data) {
|
||||
this.value$.next(this.data.getValue(this.row, this.column));
|
||||
this.value$.next(this.data.getValue(this.row, this.column, this.resolverFn));
|
||||
}
|
||||
}
|
||||
|
||||
view() {
|
||||
const rawValue: string | object = this.data.getValue(this.row, this.column);
|
||||
const rawValue: string | object = this.data.getValue(this.row, this.column, this.resolverFn);
|
||||
const value = typeof rawValue === 'object'
|
||||
? JSON.stringify(rawValue || {}, null, 2)
|
||||
: rawValue;
|
||||
|
@@ -52,7 +52,8 @@ export class LocationCellComponent extends DataTableCellComponent implements OnI
|
||||
if (this.column && this.column.key && this.row && this.data) {
|
||||
const path: PathInfoEntity = this.data.getValue(
|
||||
this.row,
|
||||
this.column
|
||||
this.column,
|
||||
this.resolverFn
|
||||
);
|
||||
|
||||
if (path && path.name && path.elements) {
|
||||
|
@@ -28,7 +28,7 @@ export interface DataTableAdapter {
|
||||
setRows(rows: Array<DataRow>): void;
|
||||
getColumns(): Array<DataColumn>;
|
||||
setColumns(columns: Array<DataColumn>): void;
|
||||
getValue(row: DataRow, col: DataColumn): any;
|
||||
getValue(row: DataRow, col: DataColumn, resolverFn?: (row: DataRow, col: DataColumn) => any): any;
|
||||
getSorting(): DataSorting;
|
||||
setSorting(sorting: DataSorting): void;
|
||||
sort(key?: string, direction?: string): void;
|
||||
|
@@ -99,7 +99,7 @@ export class ObjectDataTableAdapter implements DataTableAdapter {
|
||||
this._columns = columns || [];
|
||||
}
|
||||
|
||||
getValue(row: DataRow, col: DataColumn): any {
|
||||
getValue(row: DataRow, col: DataColumn, resolver?: (row: DataRow, col: DataColumn) => any ): any {
|
||||
if (!row) {
|
||||
throw new Error('Row not found');
|
||||
}
|
||||
@@ -107,6 +107,10 @@ export class ObjectDataTableAdapter implements DataTableAdapter {
|
||||
throw new Error('Column not found');
|
||||
}
|
||||
|
||||
if (resolver) {
|
||||
return resolver(row, col);
|
||||
}
|
||||
|
||||
const value = row.getValue(col.key);
|
||||
|
||||
if (col.type === 'icon') {
|
||||
|
Reference in New Issue
Block a user