[ACS-4565] add search for categories tree in admin cc (#8279)

* ACS-4565 Added possibility to search categories

* ACS-4565 Fixed unit test

* ACS-4565 Fixed lint issue

* ACS-4565 Removed extra empty line

* ACS-4565 Replaced tags label with categories label in unit tests

* ACS-4565 Replaced tags label with categories label in doc
This commit is contained in:
AleksanderSklorz
2023-02-20 16:53:22 +01:00
committed by GitHub
parent 477d49eaee
commit 02dcd4fb48
11 changed files with 226 additions and 20 deletions

View File

@@ -156,9 +156,9 @@ describe('TreeComponent', () => {
it('should clear the selection and load root nodes on refresh', () => {
const selectionSpy = spyOn(component.treeNodesSelection, 'clear');
const getNodesSpy = spyOn(component.treeService, 'getSubNodes').and.callThrough();
component.refreshTree(0, 25);
component.refreshTree(0, 25, 'some term');
expect(selectionSpy).toHaveBeenCalled();
expect(getNodesSpy).toHaveBeenCalledWith('-root-', 0, 25);
expect(getNodesSpy).toHaveBeenCalledWith('-root-', 0, 25, 'some term');
});
it('should call correct server method on collapsing node', () => {

View File

@@ -122,11 +122,12 @@ export class TreeComponent<T extends TreeNode> implements OnInit {
*
* @param skipCount Number of root nodes to skip.
* @param maxItems Maximum number of nodes returned from Observable.
* @param searchTerm Specifies if categories should be filtered out by name or not. If not specified then returns categories without filtering.
*/
public refreshTree(skipCount?: number, maxItems?: number): void {
public refreshTree(skipCount?: number, maxItems?: number, searchTerm?: string): void {
this.loadingRootSource.next(true);
this.treeNodesSelection.clear();
this.treeService.getSubNodes('-root-', skipCount, maxItems).subscribe((response: TreeResponse<T>) => {
this.treeService.getSubNodes('-root-', skipCount, maxItems, searchTerm).subscribe((response: TreeResponse<T>) => {
this.treeService.treeNodes = response.entries;
this.treeNodesSelection.deselect(...response.entries);
this.paginationChanged.emit(response.pagination);

View File

@@ -42,7 +42,7 @@ export abstract class TreeService<T extends TreeNode> extends DataSource<T> {
this.treeNodes = [];
}
public abstract getSubNodes(parentNodeId: string, skipCount?: number, maxItems?: number): Observable<TreeResponse<T>>;
public abstract getSubNodes(parentNodeId: string, skipCount?: number, maxItems?: number, searchTerm?: string): Observable<TreeResponse<T>>;
/**
* Expands node applying subnodes to it.