mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Performance improvements (#1166)
#1166 * Update angular libs document-list: performance improvements caching ‘heavy’ cell evaluations (i.e. date pipe) code/test fixes document-list: performance improvements Removed ‘AfterViewChecked’ bottleneck as underlying data-table already does it. data-table: performance improvements
This commit is contained in:
committed by
Eugenio Romano
parent
0f563e38bb
commit
3ca2c28a41
@@ -121,15 +121,21 @@ export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvid
|
||||
if (!col) {
|
||||
throw new Error(this.ERR_COL_NOT_FOUND);
|
||||
}
|
||||
let value = row.getValue(col.key);
|
||||
let dataRow: ShareDataRow = <ShareDataRow> row;
|
||||
let value: any = row.getValue(col.key);
|
||||
if (dataRow.cache[col.key] !== undefined) {
|
||||
return dataRow.cache[col.key];
|
||||
}
|
||||
|
||||
if (col.type === 'date') {
|
||||
let datePipe = new DatePipe('en-US');
|
||||
let format = col.format || this.DEFAULT_DATE_FORMAT;
|
||||
try {
|
||||
return datePipe.transform(value, format);
|
||||
let result = datePipe.transform(value, format);
|
||||
return dataRow.cacheValue(col.key, result);
|
||||
} catch (err) {
|
||||
console.error(`Error parsing date ${value} to format ${format}`);
|
||||
return 'Error';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +180,7 @@ export class ShareDataTableAdapter implements DataTableAdapter, PaginationProvid
|
||||
|
||||
}
|
||||
|
||||
return value;
|
||||
return dataRow.cacheValue(col.key, value);
|
||||
}
|
||||
|
||||
getSorting(): DataSorting {
|
||||
@@ -308,6 +314,7 @@ export class ShareDataRow implements DataRow {
|
||||
|
||||
static ERR_OBJECT_NOT_FOUND: string = 'Object source not found';
|
||||
|
||||
cache: { [key: string]: any } = {};
|
||||
isSelected: boolean = false;
|
||||
|
||||
get node(): NodeMinimalEntry {
|
||||
@@ -320,7 +327,15 @@ export class ShareDataRow implements DataRow {
|
||||
}
|
||||
}
|
||||
|
||||
cacheValue(key: string, value: any): any {
|
||||
this.cache[key] = value;
|
||||
return value;
|
||||
}
|
||||
|
||||
getValue(key: string): any {
|
||||
if (this.cache[key] !== undefined) {
|
||||
return this.cache[key];
|
||||
}
|
||||
return ObjectUtils.getValue(this.obj.entry, key);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user