mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user