[AAE-3113] Node selector - Be able to restrict the breadcrums to a specific root (#5912)

* Be able to restrict the breadcrums to a specific root

* Add unit test for breadcrumbs restriction

* Fix refresh
This commit is contained in:
Maurizio Vitale
2020-07-29 12:46:37 +01:00
committed by GitHub
parent 506f0dfbb1
commit c7237486df
7 changed files with 26 additions and 6 deletions

View File

@@ -42,6 +42,7 @@
class="adf-content-node-selector-content-breadcrumb"
(navigate)="clearSearch()"
[target]="documentList"
[rootId]="breadcrumbRootId"
[transform]="breadcrumbTransform"
[folderNode]="breadcrumbFolderNode"
[root]="breadcrumbFolderTitle"

View File

@@ -638,7 +638,7 @@ describe('ContentNodeSelectorComponent', () => {
it('should restrict the search to the currentFolderId in case is defined', () => {
component.currentFolderId = 'my-root-id';
component.restrictSearchToCurrentFolderId = true;
component.restrictRootToCurrentFolderId = true;
component.ngOnInit();
component.search('search');
@@ -647,7 +647,7 @@ describe('ContentNodeSelectorComponent', () => {
it('should restrict the search to the site and not to the currentFolderId in case is changed', () => {
component.currentFolderId = 'my-root-id';
component.restrictSearchToCurrentFolderId = true;
component.restrictRootToCurrentFolderId = true;
component.ngOnInit();
component.siteChanged(<SiteEntry> { entry: { guid: 'my-site-id' } });
component.search('search');
@@ -655,6 +655,20 @@ describe('ContentNodeSelectorComponent', () => {
expect(cnSearchSpy).toHaveBeenCalledWith('search', 'my-site-id', 0, 25, [], false);
});
it('should restrict the breadcrumb to the currentFolderId in case restrictedRoot is true', () => {
component.currentFolderId = 'my-root-id';
component.restrictRootToCurrentFolderId = true;
component.ngOnInit();
expect(component.breadcrumbRootId).toEqual('my-root-id');
});
it('should NOT restrict the breadcrumb to the currentFolderId in case restrictedRoot is false', () => {
component.currentFolderId = 'my-root-id';
component.restrictRootToCurrentFolderId = false;
component.ngOnInit();
expect(component.breadcrumbRootId).toBeUndefined();
});
it('should clear the search field, nodes and chosenNode when deleting the search input', fakeAsync(() => {
spyOn(component, 'clear').and.callThrough();
typeToSearchBox('a');

View File

@@ -60,9 +60,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
private showSearchField = true;
private showFiles = false;
/** If true will restrict the search to the currentFolderId */
/** If true will restrict the search and breadcrumbs to the currentFolderId */
@Input()
restrictSearchToCurrentFolderId: boolean = false;
restrictRootToCurrentFolderId: boolean = false;
/** Node ID of the folder currently listed. */
@Input()
@@ -198,6 +198,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
nodePaging: NodePaging | null = null;
siteId: null | string;
breadcrumbRootId: null | string;
searchTerm: string = '';
showingSearchResults: boolean = false;
loadingSearchResults: boolean = false;
@@ -252,7 +253,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
this.target = this.documentList;
this.folderIdToShow = this.currentFolderId;
if (this.currentFolderId) {
if (this.restrictSearchToCurrentFolderId) {
if (this.restrictRootToCurrentFolderId) {
this.breadcrumbRootId = this.currentFolderId;
this.siteId = this.currentFolderId;
} else {
this.getStartSite();

View File

@@ -23,6 +23,7 @@ export interface ContentNodeSelectorComponentData {
actionName?: string;
currentFolderId: string;
dropdownHideMyFiles?: boolean;
restrictRootToCurrentFolderId?: boolean;
dropdownSiteList?: SitePaging;
rowFilter?: any;
where?: string;

View File

@@ -7,6 +7,7 @@
<mat-dialog-content>
<adf-content-node-selector-panel
[currentFolderId]="data?.currentFolderId"
[restrictRootToCurrentFolderId]="data?.restrictRootToCurrentFolderId"
[dropdownHideMyFiles]="data?.dropdownHideMyFiles"
[dropdownSiteList]="data?.dropdownSiteList"
[rowFilter]="data?.rowFilter"