diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html
index 1ea0941097..0c8d3ff4aa 100644
--- a/demo-shell-ng2/app/components/files/files.component.html
+++ b/demo-shell-ng2/app/components/files/files.component.html
@@ -1,191 +1,189 @@
-
-
-
+
+
+
+
-
-
-
+ [contextMenuActions]="true"
+ [contentActions]="true"
+ (preview)="showFile($event)"
+ (folderChange)="onFolderChanged($event)">
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - Current path: {{documentList.currentFolderPath}}
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Upload
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Current path: {{documentList.currentFolderPath}}
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Upload
+
+
+
+
+
+
+
+
+
{
let handler = jasmine.createSpyObj('componentHandler', ['upgradeAllRegistered']);
window['componentHandler'] = handler;
- dataTable.ngAfterViewChecked();
+ dataTable.ngOnInit();
expect(handler.upgradeAllRegistered).toHaveBeenCalled();
});
it('should upgrade MDL components only when component handler present', () => {
expect(window['componentHandler']).toBeNull();
- dataTable.ngAfterViewChecked();
+ dataTable.ngOnInit();
});
it('should invert "select all" status', () => {
diff --git a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.ts b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.ts
index 573ba6967a..cd0d2e7547 100644
--- a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.ts
+++ b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.ts
@@ -15,16 +15,7 @@
* limitations under the License.
*/
-import {
- Component,
- OnInit,
- Input,
- Output,
- EventEmitter,
- AfterViewChecked,
- TemplateRef
-} from '@angular/core';
-
+import { Component, OnInit, Input, Output, EventEmitter, TemplateRef } from '@angular/core';
import {
DataTableAdapter,
DataRow,
@@ -42,7 +33,7 @@ declare var componentHandler;
styleUrls: ['./datatable.component.css'],
templateUrl: './datatable.component.html'
})
-export class DataTableComponent implements OnInit, AfterViewChecked {
+export class DataTableComponent implements OnInit {
@Input()
data: DataTableAdapter;
@@ -79,9 +70,7 @@ export class DataTableComponent implements OnInit, AfterViewChecked {
if (!this.data) {
this.data = new ObjectDataTableAdapter([], []);
}
- }
- ngAfterViewChecked() {
// workaround for MDL issues with dynamic components
if (componentHandler) {
componentHandler.upgradeAllRegistered();
diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.spec.ts b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.spec.ts
index 8315e839a3..14078e6be7 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.spec.ts
+++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.spec.ts
@@ -272,11 +272,6 @@ describe('DocumentList', () => {
expect(documentList.executeContentAction).not.toHaveBeenCalled();
});
- it('should upgrade material design components', () => {
- documentList.ngAfterViewChecked();
- expect(componentHandler.upgradeAllRegistered).toHaveBeenCalled();
- });
-
it('should subscribe to context action handler', () => {
spyOn(documentList, 'displayFolderContent').and.stub();
spyOn(documentList, 'contextActionCallback').and.stub();
diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts
index 64e8f16c91..fb239ad44a 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts
+++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts
@@ -22,7 +22,6 @@ import {
Output,
EventEmitter,
AfterContentInit,
- AfterViewChecked,
TemplateRef,
NgZone,
ViewChild,
@@ -41,15 +40,13 @@ import {
ImageResolver
} from './../data/share-datatable-adapter';
-declare var componentHandler;
-
@Component({
moduleId: module.id,
selector: 'alfresco-document-list',
styleUrls: ['./document-list.css'],
templateUrl: './document-list.html'
})
-export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit {
+export class DocumentList implements OnInit, AfterContentInit {
static SINGLE_CLICK_NAVIGATION: string = 'click';
static DOUBLE_CLICK_NAVIGATION: string = 'dblclick';
@@ -196,16 +193,8 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
return false;
}
- ngAfterViewChecked() {
- // workaround for MDL issues with dynamic components
- if (componentHandler) {
- componentHandler.upgradeAllRegistered();
- }
- }
-
isMobile(): boolean {
return !!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
-
}
getNodeActions(node: MinimalNodeEntity): ContentActionModel[] {
diff --git a/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.spec.ts b/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.spec.ts
index ee12c9b5a1..96248783b9 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.spec.ts
+++ b/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.spec.ts
@@ -203,8 +203,8 @@ describe('ShareDataTableAdapter', () => {
spyOn(console, 'error').and.stub();
let value = adapter.getValue(row, col);
- expect(value).toBe(dateValue);
- expect(console.error).toHaveBeenCalledWith(`Error parsing date ${value} to format ${col.format}`);
+ expect(value).toBe('Error');
+ expect(console.error).toHaveBeenCalled();
});
it('should generate fallback icon for a file thumbnail with unknown mime type', () => {
diff --git a/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.ts b/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.ts
index 1754c5f594..f2c7a2078d 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.ts
+++ b/ng2-components/ng2-alfresco-documentlist/src/data/share-datatable-adapter.ts
@@ -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 = 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);
}