mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-3114] Ability to restrict search to a root folder (#5890)
* Ability to restrict the search to a specific root in case there is no site concept * Add unit test * Initialize the siteId with root * Fix unit test * Reuse existing property and add boolean * add new line before extect * Rename to restrictSearchToCurrentFolderId * Typo * Rename property into doc
This commit is contained in:
@@ -634,6 +634,25 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
expect(component.showingSearchResults).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should restrict the search to the currentFolderId in case is defined', () => {
|
||||
component.currentFolderId = 'my-root-id';
|
||||
component.restrictSearchToCurrentFolderId = true;
|
||||
component.ngOnInit();
|
||||
component.search('search');
|
||||
|
||||
expect(cnSearchSpy).toHaveBeenCalledWith('search', 'my-root-id', 0, 25, [], false);
|
||||
});
|
||||
|
||||
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.ngOnInit();
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: 'my-site-id' } });
|
||||
component.search('search');
|
||||
|
||||
expect(cnSearchSpy).toHaveBeenCalledWith('search', 'my-site-id', 0, 25, [], false);
|
||||
});
|
||||
|
||||
it('should clear the search field, nodes and chosenNode when deleting the search input', fakeAsync(() => {
|
||||
spyOn(component, 'clear').and.callThrough();
|
||||
typeToSearchBox('a');
|
||||
|
@@ -60,6 +60,10 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
private showSearchField = true;
|
||||
private showFiles = false;
|
||||
|
||||
/** If true will restrict the search to the currentFolderId */
|
||||
@Input()
|
||||
restrictSearchToCurrentFolderId: boolean = false;
|
||||
|
||||
/** Node ID of the folder currently listed. */
|
||||
@Input()
|
||||
currentFolderId: string = null;
|
||||
@@ -248,7 +252,11 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
this.target = this.documentList;
|
||||
this.folderIdToShow = this.currentFolderId;
|
||||
if (this.currentFolderId) {
|
||||
this.getStartSite();
|
||||
if (this.restrictSearchToCurrentFolderId) {
|
||||
this.siteId = this.currentFolderId;
|
||||
} else {
|
||||
this.getStartSite();
|
||||
}
|
||||
}
|
||||
|
||||
this.breadcrumbTransform = this.breadcrumbTransform ? this.breadcrumbTransform : null;
|
||||
|
Reference in New Issue
Block a user