#244 breadcrumb as a separate component (doclist only)

This commit is contained in:
Denys Vuika
2016-06-21 15:51:51 +01:00
parent bf7414fc85
commit e101f22e28
10 changed files with 175 additions and 138 deletions

View File

@@ -61,9 +61,6 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit,
@Input('navigation-mode')
navigationMode: string = 'dblclick'; // click|dblclick
@Input()
breadcrumb: boolean = true;
@Input()
thumbnails: boolean = false;
@@ -79,16 +76,10 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit,
@Output()
preview: EventEmitter<any> = new EventEmitter();
rootFolder = {
name: 'Root',
path: '/'
};
@Input()
currentFolderPath: string = this.DEFAULT_ROOT_FOLDER;
errorMessage;
route: { name: string, path: string }[] = [];
actions: ContentActionModel[] = [];
columns: ContentColumnModel[] = [];
@@ -180,7 +171,6 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit,
changePath(path: string) {
this.currentFolderPath = path || this.DEFAULT_ROOT_FOLDER;
this.route = this.parsePath(this.currentFolderPath);
this.displayFolderContent(this.currentFolderPath);
}
@@ -266,33 +256,10 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit,
private performNavigation(node: MinimalNodeEntity) {
if (node && node.entry && node.entry.isFolder) {
let path = this.getNodePath(node);
this.route.push({
name: node.entry.name,
path: path
});
this.displayFolderContent(path);
}
}
/**
* Invoked when a breadcrumb route is clicked.
* @param r Route to navigate to
* @param e DOM event
*/
goToRoute(r, e) {
if (e) {
e.preventDefault();
}
if (this.navigate) {
let idx = this.route.indexOf(r);
if (idx > -1) {
this.route.splice(idx + 1);
this.displayFolderContent(r.path);
}
}
}
/**
* Gets thumbnail URL for the given node.
* @param node Node to get URL for.
@@ -483,30 +450,6 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit,
return val;
}
private parsePath(path: string): { name: string, path: string }[] {
let parts = path.split('/').filter(val => val ? true : false);
let result = [
this.rootFolder
];
let parentPath: string = this.rootFolder.path;
for (let i = 0; i < parts.length; i++) {
if (!parentPath.endsWith('/')) {
parentPath += '/';
}
parentPath += parts[i];
result.push({
name: parts[i],
path: parentPath
});
}
return result;
};
private _hasEntries(node: NodePaging): boolean {
return (node && node.list && node.list.entries && node.list.entries.length > 0);
}