mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#117 Support for setting/getting folder path from code
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
uploaddirectory="{{relativePath}}"
|
uploaddirectory="{{relativePath}}"
|
||||||
(onSuccess)="refreshDocumentList($event)">
|
(onSuccess)="refreshDocumentList($event)">
|
||||||
<alfresco-document-list
|
<alfresco-document-list
|
||||||
|
#documentList
|
||||||
[currentFolderPath]="absolutePath"
|
[currentFolderPath]="absolutePath"
|
||||||
[breadcrumb]="breadcrumb"
|
[breadcrumb]="breadcrumb"
|
||||||
(itemClick)="showFile($event)"
|
(itemClick)="showFile($event)"
|
||||||
@@ -103,11 +104,22 @@
|
|||||||
|
|
||||||
<div class="p-10">
|
<div class="p-10">
|
||||||
<ul>
|
<ul>
|
||||||
<li>Relative path: {{relativePath}}</li>
|
<li>Current relative path: {{relativePath}}</li>
|
||||||
<li>Absolute path: {{absolutePath}}</li>
|
<li>Current absolute path: {{absolutePath}}</li>
|
||||||
|
<li>
|
||||||
|
<button (click)="documentList.changePath('/Sites/swsdp/documentLibrary/Agency Files/Contracts')">Go to agency contracts</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button (click)="documentList.changePath('')">Got to site root</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button (click)="documentList.changePath('/')">Go to root</button>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Single file upload</h5>
|
<h5>Single file upload</h5>
|
||||||
<alfresco-upload-button data-automation-id="single-file-upload" uploaddirectory="{{relativePath}}" currentFolderPath="{{absolutePath}}"
|
<alfresco-upload-button data-automation-id="single-file-upload" uploaddirectory="{{relativePath}}" currentFolderPath="{{absolutePath}}"
|
||||||
(onSuccess)="refreshDocumentList($event)"></alfresco-upload-button>
|
(onSuccess)="refreshDocumentList($event)"></alfresco-upload-button>
|
||||||
|
@@ -22,7 +22,8 @@ import {
|
|||||||
Output,
|
Output,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
AfterContentInit,
|
AfterContentInit,
|
||||||
AfterViewChecked
|
AfterViewChecked,
|
||||||
|
OnChanges
|
||||||
} from 'angular2/core';
|
} from 'angular2/core';
|
||||||
import { AlfrescoService } from './../services/alfresco.service';
|
import { AlfrescoService } from './../services/alfresco.service';
|
||||||
import { MinimalNodeEntity, NodePaging } from './../models/document-library.model';
|
import { MinimalNodeEntity, NodePaging } from './../models/document-library.model';
|
||||||
@@ -40,7 +41,7 @@ declare let __moduleName: string;
|
|||||||
templateUrl: './document-list.html',
|
templateUrl: './document-list.html',
|
||||||
providers: [AlfrescoService]
|
providers: [AlfrescoService]
|
||||||
})
|
})
|
||||||
export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit {
|
export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit, OnChanges {
|
||||||
|
|
||||||
DEFAULT_ROOT_FOLDER: string = '/Sites/swsdp/documentLibrary';
|
DEFAULT_ROOT_FOLDER: string = '/Sites/swsdp/documentLibrary';
|
||||||
|
|
||||||
@@ -105,23 +106,11 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
|
|||||||
this.currentFolderPath !== this.rootFolder.path;
|
this.currentFolderPath !== this.rootFolder.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private _alfrescoService: AlfrescoService) {
|
constructor(
|
||||||
}
|
private _alfrescoService: AlfrescoService) {}
|
||||||
|
|
||||||
_createRootFolder(): any {
|
|
||||||
let folderArray = this.currentFolderPath.split('/');
|
|
||||||
let nameFolder = folderArray[folderArray.length - 1];
|
|
||||||
return {
|
|
||||||
name: nameFolder,
|
|
||||||
path: this.currentFolderPath
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.currentFolderPath = this.currentFolderPath || this.DEFAULT_ROOT_FOLDER;
|
this.changePath(null);
|
||||||
this.rootFolder = this._createRootFolder();
|
|
||||||
this.route.push(this.rootFolder);
|
|
||||||
this.displayFolderContent(this.rootFolder.path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(change) {
|
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.
|
* Get a list of content actions based on target and type.
|
||||||
* @param target Target to filter actions by.
|
* @param target Target to filter actions by.
|
||||||
@@ -377,6 +373,15 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
|
|||||||
return node;
|
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 {
|
private _hasEntries(node: NodePaging): boolean {
|
||||||
return (node && node.list && node.list.entries && node.list.entries.length > 0);
|
return (node && node.list && node.list.entries && node.list.entries.length > 0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user