From d14b9407682d1d924815e7cd75691a70f9ffd6f9 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 1 Jun 2016 12:15:57 +0100 Subject: [PATCH] #117 Support for setting/getting folder path from code --- .../app/components/files/files.component.html | 18 +++++++-- .../src/components/document-list.ts | 39 +++++++++++-------- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html index 47f5b35455..655a4c3b9d 100644 --- a/demo-shell-ng2/app/components/files/files.component.html +++ b/demo-shell-ng2/app/components/files/files.component.html @@ -5,6 +5,7 @@ uploaddirectory="{{relativePath}}" (onSuccess)="refreshDocumentList($event)"> + +
Single file upload
@@ -126,4 +138,4 @@
- \ 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 423517743c..70c1195d7b 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,8 @@ import { Output, EventEmitter, AfterContentInit, - AfterViewChecked + AfterViewChecked, + OnChanges } from 'angular2/core'; import { AlfrescoService } from './../services/alfresco.service'; import { MinimalNodeEntity, NodePaging } from './../models/document-library.model'; @@ -40,7 +41,7 @@ declare let __moduleName: string; templateUrl: './document-list.html', providers: [AlfrescoService] }) -export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit { +export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit, OnChanges { DEFAULT_ROOT_FOLDER: string = '/Sites/swsdp/documentLibrary'; @@ -105,23 +106,11 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit this.currentFolderPath !== this.rootFolder.path; } - constructor(private _alfrescoService: AlfrescoService) { - } - - _createRootFolder(): any { - let folderArray = this.currentFolderPath.split('/'); - let nameFolder = folderArray[folderArray.length - 1]; - return { - name: nameFolder, - path: this.currentFolderPath - }; - } + constructor( + private _alfrescoService: AlfrescoService) {} ngOnInit() { - this.currentFolderPath = this.currentFolderPath || this.DEFAULT_ROOT_FOLDER; - this.rootFolder = this._createRootFolder(); - this.route.push(this.rootFolder); - this.displayFolderContent(this.rootFolder.path); + this.changePath(null); } ngOnChanges(change) { @@ -141,6 +130,13 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit } } + changePath(path: string) { + this.currentFolderPath = path || this.DEFAULT_ROOT_FOLDER; + this.rootFolder = this._createRootFolder(this.currentFolderPath); + this.route = [this.rootFolder]; + this.displayFolderContent(this.rootFolder.path); + } + /** * Get a list of content actions based on target and type. * @param target Target to filter actions by. @@ -377,6 +373,15 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit return node; } + private _createRootFolder(path: string): any { + let parts = path.split('/'); + let namePart = parts[parts.length - 1]; + return { + name: namePart, + path: path + }; + } + private _hasEntries(node: NodePaging): boolean { return (node && node.list && node.list.entries && node.list.entries.length > 0); }