breadcrumb fixes (#2181)

This commit is contained in:
Denys Vuika
2017-08-07 18:39:48 +01:00
committed by Mario Romano
parent 083c9da0d4
commit 6c1a758561
4 changed files with 9 additions and 23 deletions

View File

@@ -359,7 +359,7 @@ DocumentList provides simple breadcrumb element to indicate the current position
| --- | --- | --- |
| target | DocumentListComponent | (optional) DocumentList component to operate with. Upon clicks will instruct the given component to update. |
| folderNode | [MinimalNodeEntryEntity](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md) | Active node, builds UI based on `folderNode.path.elements` collection. |
| root | String | (optional) Name of the folder where you want start the breadcrumb. Note the root will always be shown as first element and it will continue to be displayed until you are not in a subfolder of it. |
| root | String | (optional) Name of the root element of the breadcrumb. You can use this property to rename "Company Home" to "Personal Files" for example. |
### Events

View File

@@ -44,7 +44,7 @@ export class BreadcrumbComponent implements OnChanges {
@Output()
navigate: EventEmitter<PathElementEntity> = new EventEmitter<PathElementEntity>();
public ngOnChanges(changes: SimpleChanges): void {
ngOnChanges(changes: SimpleChanges): void {
if (changes.folderNode) {
let node: MinimalNodeEntryEntity = changes.folderNode.currentValue;
@@ -57,8 +57,8 @@ export class BreadcrumbComponent implements OnChanges {
name: node.name
});
if (this.root) {
route = this.checkRoot(route);
if (this.root && route.length > 0) {
route[0].name = this.root;
}
this.route = route;
@@ -66,25 +66,7 @@ export class BreadcrumbComponent implements OnChanges {
}
}
private checkRoot(route: PathElementEntity[]): PathElementEntity[] {
let isRoot = false;
route = route.filter((currentElement) => {
if (currentElement.name === this.root) {
isRoot = true;
}
return isRoot;
});
if (route.length === 0) {
route.push(<PathElementEntity> {
id: undefined,
name: this.root
});
}
return route;
}
public onRoutePathClick(route: PathElementEntity, event?: Event): void {
onRoutePathClick(route: PathElementEntity, event?: Event): void {
if (event) {
event.preventDefault();
}