[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

@@ -37,7 +37,7 @@ Opens a [Content Node Selector](content-node-selector.component.md) in its own
| imageResolver | [`ImageResolver`](../../../lib/content-services/src/lib/document-list/data/image-resolver.model.ts) | null | Custom image resolver function. See the [Image Resolver Model](image-resolver.model.md) page for more information. |
| isSelectionValid | [`ValidationFunction`](../../../lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts) | defaultValidation | Function used to decide if the selected node has permission to be selected. Default value is a function that always returns true. |
| pageSize | `number` | | Number of items shown per page in the list. |
| restrictSearchToCurrentFolderId | `boolean` | false | If true will restrict the search to the currentFolderId |
| restrictRootToCurrentFolderId | `boolean` | false | If true will restrict the search and breadcrumbs to the currentFolderId |
| where | `string` | | Custom _where_ filter function. See the [Document List component](../../content-services/components/document-list.component.md) for more information. |
| excludeSiteContent | `string[]` | | Custom list of site content componentIds. Used to filter out the corresponding items from the displayed nodes |
| rowFilter | [`RowFilter`](../../../lib/content-services/src/lib/document-list/data/row-filter.model.ts) | | Custom row filter function. See the [Row Filter Model](row-filter.model.md) page for more information. |

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"

View File

@@ -45,6 +45,7 @@ export class ContentCloudNodeSelectorService {
title: 'Select a file',
actionName: 'Choose',
currentFolderId,
restrictRootToCurrentFolderId: true,
select,
selectionMode,
isSelectionValid: (entry: Node) => entry.isFile,