[ADF-2361] added breadcrumb transform function to the breadcrumb comp… (#3050)

* [ADF-2361] added breadcrumb transform function to the breadcrumb component

* [ADF-2361] added PR review changes
This commit is contained in:
Vito
2018-03-08 18:05:00 +00:00
committed by Eugenio Romano
parent f8f79b3f31
commit f0dcaa02fb
6 changed files with 48 additions and 6 deletions

View File

@@ -15,7 +15,14 @@
* limitations under the License.
*/
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { Component,
EventEmitter,
Input,
OnChanges,
Output,
SimpleChanges,
ViewEncapsulation,
OnInit } from '@angular/core';
import { MinimalNodeEntryEntity, PathElementEntity } from 'alfresco-js-api';
import { DocumentListComponent } from '../document-list';
@@ -28,7 +35,7 @@ import { DocumentListComponent } from '../document-list';
'class': 'adf-breadcrumb'
}
})
export class BreadcrumbComponent implements OnChanges {
export class BreadcrumbComponent implements OnInit, OnChanges {
/** Active node, builds UI based on folderNode.path.elements collection. */
@Input()
@@ -53,6 +60,9 @@ export class BreadcrumbComponent implements OnChanges {
@Input()
target: DocumentListComponent;
@Input()
transform: (node) => any;
route: PathElementEntity[] = [];
get hasRoot(): boolean {
@@ -63,9 +73,14 @@ export class BreadcrumbComponent implements OnChanges {
@Output()
navigate: EventEmitter<PathElementEntity> = new EventEmitter<PathElementEntity>();
ngOnInit() {
this.transform = this.transform ? this.transform : null ;
}
ngOnChanges(changes: SimpleChanges): void {
if (changes.folderNode) {
const node: MinimalNodeEntryEntity = changes.folderNode.currentValue;
let node: MinimalNodeEntryEntity = null;
node = this.transform ? this.transform(changes.folderNode.currentValue) : changes.folderNode.currentValue;
this.route = this.parseRoute(node);
}
}