From c3e2588e356ca11cce058ab97493073b9e6782a6 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Tue, 13 Mar 2018 12:10:06 +0000 Subject: [PATCH] [ADF-No-issue-number] search problem type fix (#3068) * search problem type fix * fix type test * fix test node selector * fix test content node selector panel --- .../components/search/search-config-test.service.ts | 2 +- .../content-node-selector-panel.component.spec.ts | 4 ++-- .../content-node-selector.service.spec.ts | 8 ++++---- .../content-node-selector.service.ts | 13 +++++++------ .../search/components/search.component.ts | 2 +- .../interface/search-configuration.interface.ts | 2 +- lib/core/services/search-configuration.service.ts | 2 +- lib/core/services/search.service.ts | 2 +- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/demo-shell/src/app/components/search/search-config-test.service.ts b/demo-shell/src/app/components/search/search-config-test.service.ts index 42683447c3..fcf72d6352 100644 --- a/demo-shell/src/app/components/search/search-config-test.service.ts +++ b/demo-shell/src/app/components/search/search-config-test.service.ts @@ -23,7 +23,7 @@ export class TestSearchConfigurationService implements SearchConfigurationInterf constructor() { } - public generateQueryBody(searchTerm: string, maxResults: string, skipCount: string): QueryBody { + public generateQueryBody(searchTerm: string, maxResults: number, skipCount: number): QueryBody { const defaultQueryBody: QueryBody = { query: { query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm diff --git a/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts b/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts index 8763dc671b..50940002ce 100644 --- a/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts +++ b/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts @@ -292,8 +292,8 @@ describe('ContentNodeSelectorComponent', () => { }, include: ['path', 'allowableOperations'], paging: { - maxItems: '25', - skipCount: skipCount.toString() + maxItems: 25, + skipCount: skipCount }, filterQueries: [ { query: "TYPE:'cm:folder'" }, diff --git a/lib/content-services/content-node-selector/content-node-selector.service.spec.ts b/lib/content-services/content-node-selector/content-node-selector.service.spec.ts index 466a30fda0..b83fee210e 100644 --- a/lib/content-services/content-node-selector/content-node-selector.service.spec.ts +++ b/lib/content-services/content-node-selector/content-node-selector.service.spec.ts @@ -69,15 +69,15 @@ describe('ContentNodeSelectorService', () => { it('should set the maxItems and paging properly by parameters', () => { service.search('nuka cola quantum', null, 10, 100); - expect(search.query.paging.maxItems).toEqual('100'); - expect(search.query.paging.skipCount).toEqual('10'); + expect(search.query.paging.maxItems).toEqual(100); + expect(search.query.paging.skipCount).toEqual(10); }); it('should set the maxItems and paging properly by default', () => { service.search('nuka cola quantum'); - expect(search.query.paging.maxItems).toEqual('25'); - expect(search.query.paging.skipCount).toEqual('0'); + expect(search.query.paging.maxItems).toEqual(25); + expect(search.query.paging.skipCount).toEqual(0); }); it('should filter the search only for folders', () => { diff --git a/lib/content-services/content-node-selector/content-node-selector.service.ts b/lib/content-services/content-node-selector/content-node-selector.service.ts index 65d4856bb1..1efd084ccb 100644 --- a/lib/content-services/content-node-selector/content-node-selector.service.ts +++ b/lib/content-services/content-node-selector/content-node-selector.service.ts @@ -26,7 +26,8 @@ import { Observable } from 'rxjs/Observable'; @Injectable() export class ContentNodeSelectorService { - constructor(private searchService: SearchService) {} + constructor(private searchService: SearchService) { + } /** * Performs a search for content node selection @@ -47,11 +48,11 @@ export class ContentNodeSelectorService { extraNodeIds .filter(id => id !== rootNodeId) .forEach(extraId => { - extraParentFiltering += ` OR ANCESTOR:'workspace://SpacesStore/${extraId}'`; - }); + extraParentFiltering += ` OR ANCESTOR:'workspace://SpacesStore/${extraId}'`; + }); } - const parentFiltering = rootNodeId ? [ { query: `ANCESTOR:'workspace://SpacesStore/${rootNodeId}'${extraParentFiltering}` } ] : []; + const parentFiltering = rootNodeId ? [{ query: `ANCESTOR:'workspace://SpacesStore/${rootNodeId}'${extraParentFiltering}` }] : []; let defaultSearchNode: any = { query: { @@ -59,8 +60,8 @@ export class ContentNodeSelectorService { }, include: ['path', 'allowableOperations'], paging: { - maxItems: `${maxItems}`, - skipCount: `${skipCount}` + maxItems: maxItems, + skipCount: skipCount }, filterQueries: [ { query: "TYPE:'cm:folder'" }, diff --git a/lib/content-services/search/components/search.component.ts b/lib/content-services/search/components/search.component.ts index 287462ed99..e7d210d3f6 100644 --- a/lib/content-services/search/components/search.component.ts +++ b/lib/content-services/search/components/search.component.ts @@ -158,7 +158,7 @@ export class SearchComponent implements AfterContentInit, OnChanges { search$ = this.searchService.searchByQueryBody(this.queryBody); } else { search$ = this.searchService - .search(searchTerm, this.maxResults.toString(), this.skipResults.toString()); + .search(searchTerm, this.maxResults, this.skipResults); } search$.subscribe( results => { diff --git a/lib/core/interface/search-configuration.interface.ts b/lib/core/interface/search-configuration.interface.ts index fe68d17edb..bf4b655c5b 100644 --- a/lib/core/interface/search-configuration.interface.ts +++ b/lib/core/interface/search-configuration.interface.ts @@ -19,6 +19,6 @@ import { QueryBody } from 'alfresco-js-api'; export interface SearchConfigurationInterface { - generateQueryBody(searchTerm: string, maxResults: string, skipCount: string): QueryBody; + generateQueryBody(searchTerm: string, maxResults: number, skipCount: number): QueryBody; } diff --git a/lib/core/services/search-configuration.service.ts b/lib/core/services/search-configuration.service.ts index 92d490d382..79fbbb85f5 100644 --- a/lib/core/services/search-configuration.service.ts +++ b/lib/core/services/search-configuration.service.ts @@ -25,7 +25,7 @@ export class SearchConfigurationService implements SearchConfigurationInterface constructor() { } - public generateQueryBody(searchTerm: string, maxResults: string, skipCount: string): QueryBody { + public generateQueryBody(searchTerm: string, maxResults: number, skipCount: number): QueryBody { let defaultQueryBody: QueryBody = { query: { query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm diff --git a/lib/core/services/search.service.ts b/lib/core/services/search.service.ts index bcf345ca59..c8d2c91966 100644 --- a/lib/core/services/search.service.ts +++ b/lib/core/services/search.service.ts @@ -37,7 +37,7 @@ export class SearchService { .catch(err => this.handleError(err)); } - search(searchTerm: string, maxResults: string, skipCount: string): Observable { + search(searchTerm: string, maxResults: number, skipCount: number): Observable { const searchQuery = Object.assign(this.searchConfigurationService.generateQueryBody(searchTerm, maxResults, skipCount)); const promise = this.apiService.getInstance().search.searchApi.search(searchQuery);