From 012d62eb55c19c331310b542da0bf67c4ac49591 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Fri, 7 Jul 2017 09:26:44 +0100 Subject: [PATCH] [ADF-1006] fix 'isEmpty' issue and code cleanup (#2053) * fix 'isEmpty' issue and code cleanup * Update tsconfig.json --- .../content-column-list.component.ts | 1 + .../content-column.component.ts | 4 +++- .../src/components/document-list.component.ts | 4 ++-- .../src/services/document-actions.service.ts | 18 ++++++++++++++++-- .../services/folder-actions.service.spec.ts | 11 ++++------- .../src/services/folder-actions.service.ts | 19 +++++++++++++++++-- 6 files changed, 43 insertions(+), 14 deletions(-) diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-column/content-column-list.component.ts b/ng2-components/ng2-alfresco-documentlist/src/components/content-column/content-column-list.component.ts index ac1580efa2..3433c676fd 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-column/content-column-list.component.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/content-column/content-column-list.component.ts @@ -27,6 +27,7 @@ import { DocumentListComponent } from './../document-list.component'; export class ContentColumnListComponent { constructor(private documentList: DocumentListComponent) { + console.log('ContentColumnListComponent is deprecated starting with 1.7.0 and may be removed in future versions. Use DataColumnListComponent instead.'); } /** diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-column/content-column.component.ts b/ng2-components/ng2-alfresco-documentlist/src/components/content-column/content-column.component.ts index 3ec9bb93c7..0d1a777db9 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-column/content-column.component.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/content-column/content-column.component.ts @@ -53,7 +53,9 @@ export class ContentColumnComponent implements OnInit, AfterContentInit, DataCol @Input('class') cssClass: string; - constructor(private list: ContentColumnListComponent) {} + constructor(private list: ContentColumnListComponent) { + console.log('ContentColumnComponent is deprecated starting with 1.7.0 and may be removed in future versions. Use DataColumnComponent instead.'); + } ngOnInit() { if (!this.srTitle && this.key === '$thumbnail') { diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.component.ts b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.component.ts index 624cb2bded..231abc4d89 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.component.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.component.ts @@ -167,7 +167,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni constructor(private documentListService: DocumentListService, private ngZone: NgZone, - private translateService: AlfrescoTranslationService, + translateService: AlfrescoTranslationService, private el: ElementRef) { if (translateService) { @@ -263,7 +263,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni } isEmpty() { - return this.data.getRows().length === 0; + return !this.data || this.data.getRows().length === 0; } isPaginationEnabled() { diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.ts b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.ts index 4ebaa6f0d3..39ddf76dc2 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.ts @@ -66,12 +66,26 @@ export class DocumentActionsService { } // TODO: for demo purposes only, will be removed during future revisions - private handleStandardAction1(obj: any) { + /** + * @deprecated in 1.7.0 + * + * @private + * @memberof DocumentActionsService + */ + private handleStandardAction1(/*obj: any*/) { + console.log('handleStandardAction1 is deprecated in 1.7.0 and will be removed in future versions'); window.alert('standard document action 1'); } // TODO: for demo purposes only, will be removed during future revisions - private handleStandardAction2(obj: any) { + /** + * @deprecated in 1.7.0 + * + * @private + * @memberof DocumentActionsService + */ + private handleStandardAction2(/*obj: any*/) { + console.log('handleStandardAction2 is deprecated in 1.7.0 and will be removed in future versions'); window.alert('standard document action 2'); } diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.spec.ts b/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.spec.ts index 0ea7cc0e35..355657fd58 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.spec.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.spec.ts @@ -32,8 +32,7 @@ describe('FolderActionsService', () => { }); it('should register custom action handler', () => { - let handler: ContentActionHandler = function (obj: any) { - }; + let handler: ContentActionHandler = function () {}; service.setHandler('', handler); expect(service.getHandler('')).toBe(handler); }); @@ -43,8 +42,7 @@ describe('FolderActionsService', () => { }); it('should be case insensitive for keys', () => { - let handler: ContentActionHandler = function (obj: any) { - }; + let handler: ContentActionHandler = function () {}; service.setHandler('', handler); expect(service.getHandler('')).toBe(handler); }); @@ -69,8 +67,7 @@ describe('FolderActionsService', () => { }); it('should set new handler only by key', () => { - let handler: ContentActionHandler = function (obj: any) { - }; + let handler: ContentActionHandler = function () {}; expect(service.setHandler(null, handler)).toBeFalsy(); expect(service.setHandler('', handler)).toBeFalsy(); expect(service.setHandler('my-handler', handler)).toBeTruthy(); @@ -122,7 +119,7 @@ describe('FolderActionsService', () => { const deleteObservale = service.getHandler('delete')(folderWithPermission, null, permission); expect(documentListService.deleteNode).toHaveBeenCalledWith(folder.entry.id); - expect(deleteObservale.subscribe).toBeDefined; + expect(deleteObservale.subscribe).toBeDefined(); }); it('should not delete the folder node if there is no delete permission', (done) => { diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.ts b/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.ts index ec19da3976..4e1b11fb87 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.ts @@ -62,12 +62,27 @@ export class FolderActionsService { } // TODO: for demo purposes only, will be removed during future revisions - private handleStandardAction1(document: any) { + /** + * @deprecated in 1.7.0 + * + * @private + * @param {*} document + * @memberof FolderActionsService + */ + private handleStandardAction1(/*document: any*/) { + console.log('handleStandardAction1 is deprecated in 1.7.0 and will be removed in future versions'); window.alert('standard folder action 1'); } // TODO: for demo purposes only, will be removed during future revisions - private handleStandardAction2(document: any) { + /** + * @deprecated in 1.7.0 + * + * @private + * @memberof FolderActionsService + */ + private handleStandardAction2(/*document: any*/) { + console.log('handleStandardAction1 is deprecated in 1.7.0 and will be removed in future versions'); window.alert('standard folder action 2'); }