mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Merge branch 'master' into dev-denys-coverage-fixes
# Conflicts: # ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts
This commit is contained in:
@@ -24,7 +24,6 @@ import {
|
||||
AfterContentInit,
|
||||
AfterViewChecked
|
||||
} from 'angular2/core';
|
||||
|
||||
import { AlfrescoService } from './../services/alfresco.service';
|
||||
import { MinimalNodeEntity, NodePaging } from './../models/document-library.model';
|
||||
import { ContentActionModel } from './../models/content-action.model';
|
||||
@@ -42,6 +41,8 @@ declare let __moduleName: string;
|
||||
})
|
||||
export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit {
|
||||
|
||||
DEFAULT_ROOT_FOLDER: string = '/Sites/swsdp/documentLibrary';
|
||||
|
||||
@Input()
|
||||
navigate: boolean = true;
|
||||
|
||||
@@ -58,10 +59,13 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
|
||||
folderClick: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
rootFolder = {
|
||||
name: 'Document Library',
|
||||
path: 'Sites/swsdp/documentLibrary'
|
||||
name: '',
|
||||
path: ''
|
||||
};
|
||||
currentFolderPath: string = 'Sites/swsdp/documentLibrary';
|
||||
|
||||
@Input()
|
||||
currentFolderPath: string;
|
||||
|
||||
folder: NodePaging;
|
||||
errorMessage;
|
||||
|
||||
@@ -82,11 +86,26 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
|
||||
constructor(private _alfrescoService: AlfrescoService) {
|
||||
}
|
||||
|
||||
_createRootFolder(): any {
|
||||
let folderArray = this.currentFolderPath.split('/');
|
||||
let nameFolder = folderArray[folderArray.length - 1];
|
||||
return {
|
||||
name: nameFolder,
|
||||
path: this.currentFolderPath
|
||||
};
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.currentFolderPath = this.currentFolderPath || this.DEFAULT_ROOT_FOLDER;
|
||||
this.rootFolder = this._createRootFolder();
|
||||
this.route.push(this.rootFolder);
|
||||
this.displayFolderContent(this.rootFolder.path);
|
||||
}
|
||||
|
||||
ngOnChanges(change) {
|
||||
this.reload();
|
||||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
if (!this.columns || this.columns.length === 0) {
|
||||
this.setupDefaultColumns();
|
||||
@@ -133,6 +152,9 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
|
||||
this.route.pop();
|
||||
let parent = this.route.length > 0 ? this.route[this.route.length - 1] : this.rootFolder;
|
||||
if (parent) {
|
||||
this.folderClick.emit({
|
||||
value: parent.path
|
||||
});
|
||||
this.displayFolderContent(parent.path);
|
||||
}
|
||||
}
|
||||
@@ -152,8 +174,8 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
|
||||
value: item
|
||||
});
|
||||
|
||||
if (this.navigate && item) {
|
||||
if (item.entry && item.entry.isFolder) {
|
||||
if (this.navigate && item && item.entry) {
|
||||
if (item.entry.isFolder) {
|
||||
let path = this.getNodePath(item);
|
||||
|
||||
this.folderClick.emit({
|
||||
|
@@ -68,26 +68,14 @@ export class AlfrescoService {
|
||||
}
|
||||
|
||||
private getNodesPromise(folder: string) {
|
||||
|
||||
let alfrescoClient = this.getAlfrescoClient();
|
||||
return new Promise(function (resolve, reject) {
|
||||
let apiInstance = new AlfrescoApi.NodesApi(alfrescoClient);
|
||||
let nodeId = '-root-';
|
||||
let opts = {
|
||||
relativePath: folder,
|
||||
include: ['path']
|
||||
};
|
||||
let callback = function (error, data /*, response*/) {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
reject(error);
|
||||
} else {
|
||||
console.log('API returned data', data);
|
||||
resolve(data);
|
||||
}
|
||||
};
|
||||
apiInstance.getNodeChildren(nodeId, opts, callback);
|
||||
});
|
||||
let apiInstance = new AlfrescoApi.NodesApi(alfrescoClient);
|
||||
let nodeId = '-root-';
|
||||
let opts = {
|
||||
relativePath: folder,
|
||||
include: ['path']
|
||||
};
|
||||
return apiInstance.getNodeChildren(nodeId, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user