mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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
This commit is contained in:
@@ -23,7 +23,7 @@ export class TestSearchConfigurationService implements SearchConfigurationInterf
|
|||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public generateQueryBody(searchTerm: string, maxResults: string, skipCount: string): QueryBody {
|
public generateQueryBody(searchTerm: string, maxResults: number, skipCount: number): QueryBody {
|
||||||
const defaultQueryBody: QueryBody = {
|
const defaultQueryBody: QueryBody = {
|
||||||
query: {
|
query: {
|
||||||
query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm
|
query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm
|
||||||
|
@@ -292,8 +292,8 @@ describe('ContentNodeSelectorComponent', () => {
|
|||||||
},
|
},
|
||||||
include: ['path', 'allowableOperations'],
|
include: ['path', 'allowableOperations'],
|
||||||
paging: {
|
paging: {
|
||||||
maxItems: '25',
|
maxItems: 25,
|
||||||
skipCount: skipCount.toString()
|
skipCount: skipCount
|
||||||
},
|
},
|
||||||
filterQueries: [
|
filterQueries: [
|
||||||
{ query: "TYPE:'cm:folder'" },
|
{ query: "TYPE:'cm:folder'" },
|
||||||
|
@@ -69,15 +69,15 @@ describe('ContentNodeSelectorService', () => {
|
|||||||
it('should set the maxItems and paging properly by parameters', () => {
|
it('should set the maxItems and paging properly by parameters', () => {
|
||||||
service.search('nuka cola quantum', null, 10, 100);
|
service.search('nuka cola quantum', null, 10, 100);
|
||||||
|
|
||||||
expect(search.query.paging.maxItems).toEqual('100');
|
expect(search.query.paging.maxItems).toEqual(100);
|
||||||
expect(search.query.paging.skipCount).toEqual('10');
|
expect(search.query.paging.skipCount).toEqual(10);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the maxItems and paging properly by default', () => {
|
it('should set the maxItems and paging properly by default', () => {
|
||||||
service.search('nuka cola quantum');
|
service.search('nuka cola quantum');
|
||||||
|
|
||||||
expect(search.query.paging.maxItems).toEqual('25');
|
expect(search.query.paging.maxItems).toEqual(25);
|
||||||
expect(search.query.paging.skipCount).toEqual('0');
|
expect(search.query.paging.skipCount).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should filter the search only for folders', () => {
|
it('should filter the search only for folders', () => {
|
||||||
|
@@ -26,7 +26,8 @@ import { Observable } from 'rxjs/Observable';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class ContentNodeSelectorService {
|
export class ContentNodeSelectorService {
|
||||||
|
|
||||||
constructor(private searchService: SearchService) {}
|
constructor(private searchService: SearchService) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a search for content node selection
|
* Performs a search for content node selection
|
||||||
@@ -47,11 +48,11 @@ export class ContentNodeSelectorService {
|
|||||||
extraNodeIds
|
extraNodeIds
|
||||||
.filter(id => id !== rootNodeId)
|
.filter(id => id !== rootNodeId)
|
||||||
.forEach(extraId => {
|
.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 = {
|
let defaultSearchNode: any = {
|
||||||
query: {
|
query: {
|
||||||
@@ -59,8 +60,8 @@ export class ContentNodeSelectorService {
|
|||||||
},
|
},
|
||||||
include: ['path', 'allowableOperations'],
|
include: ['path', 'allowableOperations'],
|
||||||
paging: {
|
paging: {
|
||||||
maxItems: `${maxItems}`,
|
maxItems: maxItems,
|
||||||
skipCount: `${skipCount}`
|
skipCount: skipCount
|
||||||
},
|
},
|
||||||
filterQueries: [
|
filterQueries: [
|
||||||
{ query: "TYPE:'cm:folder'" },
|
{ query: "TYPE:'cm:folder'" },
|
||||||
|
@@ -158,7 +158,7 @@ export class SearchComponent implements AfterContentInit, OnChanges {
|
|||||||
search$ = this.searchService.searchByQueryBody(this.queryBody);
|
search$ = this.searchService.searchByQueryBody(this.queryBody);
|
||||||
} else {
|
} else {
|
||||||
search$ = this.searchService
|
search$ = this.searchService
|
||||||
.search(searchTerm, this.maxResults.toString(), this.skipResults.toString());
|
.search(searchTerm, this.maxResults, this.skipResults);
|
||||||
}
|
}
|
||||||
search$.subscribe(
|
search$.subscribe(
|
||||||
results => {
|
results => {
|
||||||
|
@@ -19,6 +19,6 @@ import { QueryBody } from 'alfresco-js-api';
|
|||||||
|
|
||||||
export interface SearchConfigurationInterface {
|
export interface SearchConfigurationInterface {
|
||||||
|
|
||||||
generateQueryBody(searchTerm: string, maxResults: string, skipCount: string): QueryBody;
|
generateQueryBody(searchTerm: string, maxResults: number, skipCount: number): QueryBody;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ export class SearchConfigurationService implements SearchConfigurationInterface
|
|||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public generateQueryBody(searchTerm: string, maxResults: string, skipCount: string): QueryBody {
|
public generateQueryBody(searchTerm: string, maxResults: number, skipCount: number): QueryBody {
|
||||||
let defaultQueryBody: QueryBody = {
|
let defaultQueryBody: QueryBody = {
|
||||||
query: {
|
query: {
|
||||||
query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm
|
query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm
|
||||||
|
@@ -37,7 +37,7 @@ export class SearchService {
|
|||||||
.catch(err => this.handleError(err));
|
.catch(err => this.handleError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
search(searchTerm: string, maxResults: string, skipCount: string): Observable<NodePaging> {
|
search(searchTerm: string, maxResults: number, skipCount: number): Observable<NodePaging> {
|
||||||
const searchQuery = Object.assign(this.searchConfigurationService.generateQueryBody(searchTerm, maxResults, skipCount));
|
const searchQuery = Object.assign(this.searchConfigurationService.generateQueryBody(searchTerm, maxResults, skipCount));
|
||||||
const promise = this.apiService.getInstance().search.searchApi.search(searchQuery);
|
const promise = this.apiService.getInstance().search.searchApi.search(searchQuery);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user