mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2304] Add option to Content Node Selector to transform the breadcrumb folder node (#2952)
* [ADF-2304] Add option to Content Node Selector to transform the breadcrumb folder node * [ADF-2304] update documentation with recent changes * [ADF-2304] added example of using the breadcrumbTransform
This commit is contained in:
committed by
Eugenio Romano
parent
6b980edcf5
commit
6d0bab9278
@@ -260,6 +260,36 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
done();
|
||||
}, 300);
|
||||
});
|
||||
|
||||
it('should keep breadcrumb\'s folderNode unchanged if breadcrumbTransform is NOT defined', (done) => {
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.breadcrumbTransform).toBeNull();
|
||||
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb.componentInstance.folderNode).toBe(expectedDefaultFolderNode);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should make changes to breadcrumb\'s folderNode if breadcrumbTransform is defined', (done) => {
|
||||
const transformedFolderNode = <MinimalNodeEntryEntity> { path: { elements: [{id: 'testId', name: 'testName'}] } };
|
||||
component.breadcrumbTransform = (() => {
|
||||
return transformedFolderNode;
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.breadcrumbTransform).not.toBeNull();
|
||||
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb.componentInstance.folderNode).toBe(transformedFolderNode);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Search functionality', () => {
|
||||
|
@@ -70,6 +70,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
||||
@Input()
|
||||
isSelectionValid: ValidationFunction = defaultValidation;
|
||||
|
||||
@Input()
|
||||
breadcrumbTransform: (node) => any;
|
||||
|
||||
@Output()
|
||||
select: EventEmitter<MinimalNodeEntryEntity[]> = new EventEmitter<MinimalNodeEntryEntity[]>();
|
||||
|
||||
@@ -123,6 +126,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
this.folderIdToShow = this.currentFolderId;
|
||||
this.paginationStrategy = PaginationStrategy.Infinite;
|
||||
|
||||
this.breadcrumbTransform = this.breadcrumbTransform ? this.breadcrumbTransform : null ;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,11 +164,15 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
||||
* Returns the actually selected|entered folder node or null in case of searching for the breadcrumb
|
||||
*/
|
||||
get breadcrumbFolderNode(): MinimalNodeEntryEntity | null {
|
||||
let folderNode: MinimalNodeEntryEntity;
|
||||
|
||||
if (this.showingSearchResults && this.chosenNode) {
|
||||
return this.chosenNode;
|
||||
folderNode = this.chosenNode;
|
||||
} else {
|
||||
return this.documentList.folderNode;
|
||||
folderNode = this.documentList.folderNode;
|
||||
}
|
||||
|
||||
return this.breadcrumbTransform ? this.breadcrumbTransform(folderNode) : folderNode;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,5 +27,6 @@ export interface ContentNodeSelectorComponentData {
|
||||
rowFilter?: any;
|
||||
imageResolver?: any;
|
||||
isSelectionValid?: (entry: MinimalNodeEntryEntity) => boolean;
|
||||
breadcrumbTransform?: (node) => any;
|
||||
select: Subject<MinimalNodeEntryEntity[]>;
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@
|
||||
[rowFilter]="rowFilter || data?.rowFilter"
|
||||
[imageResolver]="imageResolver || data?.imageResolver"
|
||||
[isSelectionValid]="data?.isSelectionValid"
|
||||
[breadcrumbTransform]="data?.breadcrumbTransform"
|
||||
(select)="onSelect($event)">
|
||||
</adf-content-node-selector-panel>
|
||||
</section>
|
||||
|
Reference in New Issue
Block a user