mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +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:
parent
94c99574f8
commit
826bd32e60
@ -31,6 +31,7 @@ Opens a [Content Node Selector](content-node-selector.component.md) in its own
|
|||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| ---- | ---- | ------------- | ----------- |
|
| ---- | ---- | ------------- | ----------- |
|
||||||
| breadcrumbTransform | `Function` | | Transformation to be performed on the chosen/folder node before building the breadcrumb UI. Can be useful when custom formatting is needed for the breadcrumb. You can change the path elements from the node that are used to build the breadcrumb using this function. |
|
| breadcrumbTransform | `Function` | | Transformation to be performed on the chosen/folder node before building the breadcrumb UI. Can be useful when custom formatting is needed for the breadcrumb. You can change the path elements from the node that are used to build the breadcrumb using this function. |
|
||||||
|
| restrictSearchToCurrentFolderId | `boolean` | false | If true will restrict the search to the currentFolderId. |
|
||||||
| currentFolderId | `string` | null | [Node](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/Node.md) ID of the folder currently listed. |
|
| currentFolderId | `string` | null | [Node](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/Node.md) ID of the folder currently listed. |
|
||||||
| dropdownHideMyFiles | `boolean` | false | Hide the "My Files" option added to the site list by default. See the [Sites Dropdown component](sites-dropdown.component.md) for more information. |
|
| dropdownHideMyFiles | `boolean` | false | Hide the "My Files" option added to the site list by default. See the [Sites Dropdown component](sites-dropdown.component.md) for more information. |
|
||||||
| dropdownSiteList | [`SitePaging`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/SitePaging.md) | null | Custom site for site dropdown. This is the same as the `siteList`. property of the Sites Dropdown component (see its doc page for more information). |
|
| dropdownSiteList | [`SitePaging`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/SitePaging.md) | null | Custom site for site dropdown. This is the same as the `siteList`. property of the Sites Dropdown component (see its doc page for more information). |
|
||||||
|
@ -634,6 +634,25 @@ describe('ContentNodeSelectorComponent', () => {
|
|||||||
expect(component.showingSearchResults).toBeFalsy();
|
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(() => {
|
it('should clear the search field, nodes and chosenNode when deleting the search input', fakeAsync(() => {
|
||||||
spyOn(component, 'clear').and.callThrough();
|
spyOn(component, 'clear').and.callThrough();
|
||||||
typeToSearchBox('a');
|
typeToSearchBox('a');
|
||||||
|
@ -60,6 +60,10 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
|||||||
private showSearchField = true;
|
private showSearchField = true;
|
||||||
private showFiles = false;
|
private showFiles = false;
|
||||||
|
|
||||||
|
/** If true will restrict the search to the currentFolderId */
|
||||||
|
@Input()
|
||||||
|
restrictSearchToCurrentFolderId: boolean = false;
|
||||||
|
|
||||||
/** Node ID of the folder currently listed. */
|
/** Node ID of the folder currently listed. */
|
||||||
@Input()
|
@Input()
|
||||||
currentFolderId: string = null;
|
currentFolderId: string = null;
|
||||||
@ -248,7 +252,11 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
|||||||
this.target = this.documentList;
|
this.target = this.documentList;
|
||||||
this.folderIdToShow = this.currentFolderId;
|
this.folderIdToShow = this.currentFolderId;
|
||||||
if (this.currentFolderId) {
|
if (this.currentFolderId) {
|
||||||
this.getStartSite();
|
if (this.restrictSearchToCurrentFolderId) {
|
||||||
|
this.siteId = this.currentFolderId;
|
||||||
|
} else {
|
||||||
|
this.getStartSite();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.breadcrumbTransform = this.breadcrumbTransform ? this.breadcrumbTransform : null;
|
this.breadcrumbTransform = this.breadcrumbTransform ? this.breadcrumbTransform : null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user