diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.d.ts b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.d.ts index 6be54edb46..6801800392 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.d.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.d.ts @@ -46,8 +46,8 @@ export declare class DocumentList implements OnInit, AfterViewChecked, AfterCont goToRoute(r: any, $event: any): void; getContentUrl(document: DocumentEntity): string; getDocumentThumbnailUrl(document: DocumentEntity): string; - executeContentAction(document: DocumentEntity, action: ContentActionModel): void; - private getItemPath(item); - private displayFolderContent(path); - private setupDefaultColumns(); + executeContentAction(node: DocumentEntity, action: ContentActionModel): void; + displayFolderContent(path: any): void; + private _getItemPath(item); + private _setupDefaultColumns(); } diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.js b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.js index d00905faed..9d22aca89c 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.js +++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.js @@ -65,7 +65,7 @@ System.register(['angular2/core', './../services/alfresco.service', './../models }; DocumentList.prototype.ngAfterContentInit = function () { if (!this.columns || this.columns.length === 0) { - this.setupDefaultColumns(); + this._setupDefaultColumns(); } }; DocumentList.prototype.ngAfterViewChecked = function () { @@ -106,7 +106,7 @@ System.register(['angular2/core', './../services/alfresco.service', './../models }); if (this.navigate && item) { if (item.isFolder) { - var path = this.getItemPath(item); + var path = this._getItemPath(item); this.route.push({ name: item.displayName, path: path @@ -133,24 +133,27 @@ System.register(['angular2/core', './../services/alfresco.service', './../models DocumentList.prototype.getDocumentThumbnailUrl = function (document) { return this._alfrescoService.getDocumentThumbnailUrl(document); }; - DocumentList.prototype.executeContentAction = function (document, action) { - // todo: safety checks - action.handler(document); + DocumentList.prototype.executeContentAction = function (node, action) { + if (action) { + action.handler(node); + } }; - DocumentList.prototype.getItemPath = function (item) { + DocumentList.prototype.displayFolderContent = function (path) { + var _this = this; + if (path) { + this.currentFolderPath = path; + this._alfrescoService + .getFolder(path) + .subscribe(function (folder) { return _this.folder = folder; }, function (error) { return _this.errorMessage = error; }); + } + }; + DocumentList.prototype._getItemPath = function (item) { var container = item.location.container; var path = item.location.path !== '/' ? (item.location.path + '/') : '/'; var relativePath = container + path + item.fileName; return item.location.site + '/' + relativePath; }; - DocumentList.prototype.displayFolderContent = function (path) { - var _this = this; - this.currentFolderPath = path; - this._alfrescoService - .getFolder(path) - .subscribe(function (folder) { return _this.folder = folder; }, function (error) { return _this.errorMessage = error; }); - }; - DocumentList.prototype.setupDefaultColumns = function () { + DocumentList.prototype._setupDefaultColumns = function () { var thumbnailCol = new content_column_model_1.ContentColumnModel(); thumbnailCol.source = '$thumbnail'; var nameCol = new content_column_model_1.ContentColumnModel(); diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.js.map b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.js.map index b5e6756603..e86a566357 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.js.map +++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.js.map @@ -1 +1 @@ -{"version":3,"file":"document-list.js","sourceRoot":"","sources":["document-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;YA0BH;gBA8BI,sBAAoB,gBAAgC;oBAAhC,qBAAgB,GAAhB,gBAAgB,CAAgB;oBA3BpD,aAAQ,GAAW,IAAI,CAAC;oBAExB,eAAU,GAAW,KAAK,CAAC;oBAK3B,cAAS,GAAqB,IAAI,mBAAY,EAAE,CAAC;oBAEjD,eAAU,GAAG;wBACT,IAAI,EAAE,kBAAkB;wBACxB,IAAI,EAAE,uBAAuB;qBAChC,CAAC;oBACF,sBAAiB,GAAU,uBAAuB,CAAC;oBAInD,UAAK,GAAS,EAAE,CAAC;oBAEjB,YAAO,GAAwB,EAAE,CAAC;oBAClC,YAAO,GAAwB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BACvC,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC;oBACvB,OAAO,CAAC,MAAM,GAAG,aAAa,CAAC;oBAC/B,OAAO,CAAC,QAAQ,GAAG,wBAAwB,CAAC;oBAE5C,IAAI,CAAC,OAAO,GAAG;wBACX,YAAY;wBACZ,OAAO;qBACV,CAAC;gBACN,CAAC;gBAhKD;oBAAC,YAAK,EAAE;;8DAAA;gBAGR;oBAAC,YAAK,EAAE;;gEAAA;gBAGR;oBAAC,YAAK,CAAC,aAAa,CAAC;;gEAAA;gBAGrB;oBAAC,aAAM,EAAE;;+DAAA;gBAlBb;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,YAAY;wBACtB,QAAQ,EAAE,wBAAwB;wBAClC,SAAS,EAAE,CAAC,qBAAqB,CAAC;wBAClC,WAAW,EAAE,sBAAsB;wBACnC,SAAS,EAAE,CAAC,kCAAe,CAAC;qBAC/B,CAAC;;gCAAA;gBAoKF,mBAAC;YAAD,CAAC,AAnKD,IAmKC;YAnKD,uCAmKC,CAAA"} \ No newline at end of file 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 3757cbec77..e254c56e23 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts @@ -30,7 +30,7 @@ import {ContentActionModel} from './../models/content-action.model'; import {ContentColumnModel} from './../models/content-column.model'; declare var componentHandler; -declare let __moduleName:string; +declare let __moduleName: string; @Component({ moduleId: __moduleName, @@ -42,34 +42,36 @@ declare let __moduleName:string; export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit { @Input() - navigate:boolean = true; + navigate: boolean = true; + @Input() - breadcrumb:boolean = false; + breadcrumb: boolean = false; + @Input('folder-icon') - folderIcon:string; + folderIcon: string; @Output() - itemClick:EventEmitter = new EventEmitter(); + itemClick: EventEmitter = new EventEmitter(); rootFolder = { name: 'Document Library', path: 'swsdp/documentLibrary' }; - currentFolderPath:string = 'swsdp/documentLibrary'; - folder:FolderEntity; + currentFolderPath: string = 'swsdp/documentLibrary'; + folder: FolderEntity; errorMessage; - route:any[] = []; + route: any[] = []; - actions:ContentActionModel[] = []; - columns:ContentColumnModel[] = []; + actions: ContentActionModel[] = []; + columns: ContentColumnModel[] = []; - canNavigateParent():boolean { + canNavigateParent(): boolean { return this.navigate && !this.breadcrumb && this.currentFolderPath !== this.rootFolder.path; } - constructor(private _alfrescoService:AlfrescoService) { + constructor(private _alfrescoService: AlfrescoService) { } ngOnInit() { @@ -79,7 +81,7 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit ngAfterContentInit() { if (!this.columns || this.columns.length === 0) { - this.setupDefaultColumns(); + this._setupDefaultColumns(); } } @@ -90,7 +92,7 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit } } - getContentActions(target:string, type:string) { + getContentActions(target: string, type: string) { if (target && type) { let ltarget = target.toLowerCase(); @@ -118,7 +120,7 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit } } - onItemClick(item:DocumentEntity, $event) { + onItemClick(item: DocumentEntity, $event) { if ($event) { $event.preventDefault(); } @@ -129,7 +131,7 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit if (this.navigate && item) { if (item.isFolder) { - let path = this.getItemPath(item); + let path = this._getItemPath(item); this.route.push({ name: item.displayName, path: path @@ -153,37 +155,40 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit } } - getContentUrl(document:DocumentEntity) { + getContentUrl(document: DocumentEntity) { return this._alfrescoService.getContentUrl(document); } - getDocumentThumbnailUrl(document:DocumentEntity) { + getDocumentThumbnailUrl(document: DocumentEntity) { return this._alfrescoService.getDocumentThumbnailUrl(document); } - executeContentAction(document:DocumentEntity, action:ContentActionModel) { - // todo: safety checks - action.handler(document); + executeContentAction(node: DocumentEntity, action: ContentActionModel) { + if (action) { + action.handler(node); + } } - private getItemPath(item:DocumentEntity):string { + displayFolderContent(path) { + if (path) { + this.currentFolderPath = path; + this._alfrescoService + .getFolder(path) + .subscribe( + folder => this.folder = folder, + error => this.errorMessage = error + ); + } + } + + private _getItemPath(item: DocumentEntity): string { let container = item.location.container; let path = item.location.path !== '/' ? (item.location.path + '/' ) : '/'; let relativePath = container + path + item.fileName; return item.location.site + '/' + relativePath; } - private displayFolderContent(path) { - this.currentFolderPath = path; - this._alfrescoService - .getFolder(path) - .subscribe( - folder => this.folder = folder, - error => this.errorMessage = error - ); - } - - private setupDefaultColumns() { + private _setupDefaultColumns() { let thumbnailCol = new ContentColumnModel(); thumbnailCol.source = '$thumbnail'; diff --git a/ng2-components/ng2-alfresco-documentlist/test/components/document-list.spec.ts b/ng2-components/ng2-alfresco-documentlist/test/components/document-list.spec.ts index c7e5fce4dd..9d0f07a2a6 100644 --- a/ng2-components/ng2-alfresco-documentlist/test/components/document-list.spec.ts +++ b/ng2-components/ng2-alfresco-documentlist/test/components/document-list.spec.ts @@ -23,83 +23,188 @@ import { import {DocumentList} from '../../src/components/document-list'; import {ContentColumnModel} from '../../src/models/content-column.model'; import {AlfrescoServiceMock} from '../assets/alfresco.service.mock'; +import {DocumentEntity} from '../../src/models/document-library.model'; +import {ContentActionModel} from '../../src/models/content-action.model'; describe('document-list', () => { + let alfrescoServiceMock: AlfrescoServiceMock; + let documentList: DocumentList; + + beforeEach(() => { + alfrescoServiceMock = new AlfrescoServiceMock(); + documentList = new DocumentList(alfrescoServiceMock); + }); + it('should setup default columns', () => { - let list: DocumentList = new DocumentList(null); - list.ngAfterContentInit(); - expect(list.columns.length).not.toBe(0); + documentList.ngAfterContentInit(); + expect(documentList.columns.length).not.toBe(0); }); it('should use custom columns instead of default ones', () => { - let list: DocumentList = new DocumentList(null); let column: ContentColumnModel = { title: 'title', source: 'source', cssClass: 'css' }; - list.columns.push(column); + documentList.columns.push(column); - list.ngAfterContentInit(); - expect(list.columns.length).toBe(1); - expect(list.columns[0]).toBe(column); + documentList.ngAfterContentInit(); + expect(documentList.columns.length).toBe(1); + expect(documentList.columns[0]).toBe(column); }); it('should setup default root for breadcrumb', () => { + documentList.ngOnInit(); + expect(documentList.route.length).toBe(1); + expect(documentList.route[0]).toBe(documentList.rootFolder); + }); - let service = new AlfrescoServiceMock(); - /* - spyOn(service, 'getFolder').and.returnValue( - Observable.create(observer => { - var value = {}; - observer.next(value); - observer.complete(); - }) - ); - */ - let list: DocumentList = new DocumentList(service); + it('should display custom root path', () => { + spyOn(documentList, 'displayFolderContent').and.stub(); - list.ngOnInit(); - expect(list.route.length).toBe(1); - expect(list.route[0]).toBe(list.rootFolder); + let root = { + name: '', + path: '' + }; + + documentList.rootFolder = root; + documentList.ngOnInit(); + expect(documentList.displayFolderContent).toHaveBeenCalledWith(root.path); }); it('should fetch folder', () => { let folder = { 'nodeRef': 'workspace://SpacesStore/8bb36efb-c26d-4d2b-9199-ab6922f53c28' }; - let service = new AlfrescoServiceMock(); - service._folderToReturn = folder; + alfrescoServiceMock._folderToReturn = folder; + documentList.ngOnInit(); - let list: DocumentList = new DocumentList(service); - list.ngOnInit(); - - expect(list.folder).toBe(folder); + expect(documentList.folder).toBe(folder); }); it('should get content url', () => { let url = 'URL'; - let service = new AlfrescoServiceMock(); - spyOn(service, 'getContentUrl').and.returnValue(url); + spyOn(alfrescoServiceMock, 'getContentUrl').and.returnValue(url); - let list: DocumentList = new DocumentList(service); - let result = list.getContentUrl(null); + let result = documentList.getContentUrl(null); expect(result).toBe(url); - expect(service.getContentUrl).toHaveBeenCalled(); + expect(alfrescoServiceMock.getContentUrl).toHaveBeenCalled(); }); it('should get thumbnail url', () => { let url = 'URL'; - let service = new AlfrescoServiceMock(); - spyOn(service, 'getDocumentThumbnailUrl').and.returnValue(url); + spyOn(alfrescoServiceMock, 'getDocumentThumbnailUrl').and.returnValue(url); - let list: DocumentList = new DocumentList(service); - let result = list.getDocumentThumbnailUrl(null); + let result = documentList.getDocumentThumbnailUrl(null); expect(result).toBe(url); - expect(service.getDocumentThumbnailUrl).toHaveBeenCalled(); + expect(alfrescoServiceMock.getDocumentThumbnailUrl).toHaveBeenCalled(); + }); + + it('should execute action with node', () => { + let node = new DocumentEntity(); + let action = new ContentActionModel(); + action.handler = function() {}; + + spyOn(action, 'handler').and.stub(); + + documentList.executeContentAction(node, action); + expect(action.handler).toHaveBeenCalledWith(node); + + }); + + it('should execute action without node provided', () => { + let action = new ContentActionModel(); + action.handler = function() {}; + + spyOn(action, 'handler').and.stub(); + documentList.executeContentAction(null, action); + expect(action.handler).toHaveBeenCalledWith(null); + }); + + it('should update current folder path', () => { + expect(documentList.currentFolderPath).toBe(documentList.rootFolder.path); + + let path = ''; + documentList.displayFolderContent(path); + + expect(documentList.currentFolderPath).toBe(path); + }); + + it('should give no content actions for empty target', () => { + let actions = documentList.getContentActions(null, 'button'); + expect(actions.length).toBe(0); + }); + + it('should give no content actions for empty type', () => { + let actions = documentList.getContentActions('folder', null); + expect(actions.length).toBe(0); + }); + + it('should filter content actions for various types and targets', () => { + var folderButton = new ContentActionModel(); + folderButton.target = "folder"; + folderButton.type = "button"; + + var folderMenu = new ContentActionModel(); + folderMenu.target = "folder"; + folderMenu.type = "menu"; + + var documentButton = new ContentActionModel(); + documentButton.target = "document"; + documentButton.type = "button"; + + var documentMenu = new ContentActionModel(); + documentMenu.target = "document"; + documentMenu.type = "menu"; + + documentList.actions = [ + folderButton, + folderMenu, + documentButton, + documentMenu + ]; + + let actions = documentList.getContentActions('folder', 'button'); + expect(actions.length).toBe(1); + expect(actions[0]).toBe(folderButton); + + actions = documentList.getContentActions('folder', 'menu'); + expect(actions.length).toBe(1); + expect(actions[0]).toBe(folderMenu); + + actions = documentList.getContentActions('document', 'button'); + expect(actions.length).toBe(1); + expect(actions[0]).toBe(documentButton); + + actions = documentList.getContentActions('document', 'menu'); + expect(actions.length).toBe(1); + expect(actions[0]).toBe(documentMenu); + }); + + it('should be case insensitive when filtering content actions', () => { + var documentButton = new ContentActionModel(); + documentButton.target = 'document'; + documentButton.type = 'button'; + + documentList.actions = [documentButton]; + + var actions = documentList.getContentActions('DoCuMeNt', 'BUTTON'); + expect(actions.length).toBe(1); + expect(actions[0]).toBe(documentButton); + }); + + it('should find no content actions', () => { + var documentButton = new ContentActionModel(); + documentButton.target = 'document'; + documentButton.type = 'button'; + + documentList.actions = [documentButton]; + + var actions = documentList.getContentActions('unknown', 'value'); + expect(actions.length).toBe(0); }); });