mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Search add wildcard * to match all the (#2079)
This commit is contained in:
committed by
Eugenio Romano
parent
52be6534ae
commit
3d4897b4bb
@@ -91,7 +91,7 @@ results page will be shown.
|
|||||||
| --- | --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- |
|
||||||
| searchTerm | string | | Search term to use when executing the search. Updating this value will run a new search and update the results |
|
| searchTerm | string | | Search term to use when executing the search. Updating this value will run a new search and update the results |
|
||||||
| rootNodeId | string | "-root-" | NodeRef or node name where the search should start. |
|
| rootNodeId | string | "-root-" | NodeRef or node name where the search should start. |
|
||||||
| resultType | string | | Node type to filter search results by, e.g. 'cm:content'. |
|
| resultType | string | | Node type to filter search results by, e.g. 'cm:content', 'cm:folder' if you want only the files. |
|
||||||
| maxResults | number | 20 | Maximum number of results to show in the search. |
|
| maxResults | number | 20 | Maximum number of results to show in the search. |
|
||||||
| resultSort | string | | Criteria to sort search results by, must be one of "name" , "modifiedAt" or "createdAt" |
|
| resultSort | string | | Criteria to sort search results by, must be one of "name" , "modifiedAt" or "createdAt" |
|
||||||
| navigationMode | string | "dblclick" | Event used to initiate a navigation action to a specific result, one of "click" or "dblclick" |
|
| navigationMode | string | "dblclick" | Event used to initiate a navigation action to a specific result, one of "click" or "dblclick" |
|
||||||
|
@@ -101,6 +101,7 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
|
|||||||
orderBy: this.resultSort
|
orderBy: this.resultSort
|
||||||
};
|
};
|
||||||
if (searchTerm !== null && searchTerm !== '') {
|
if (searchTerm !== null && searchTerm !== '') {
|
||||||
|
searchTerm = searchTerm + '*';
|
||||||
this.searchService
|
this.searchService
|
||||||
.getNodeQueryResults(searchTerm, searchOpts)
|
.getNodeQueryResults(searchTerm, searchOpts)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
|
@@ -105,8 +105,8 @@ describe('AlfrescoSearchComponent', () => {
|
|||||||
declarations: [AlfrescoSearchComponent], // declare the test component
|
declarations: [AlfrescoSearchComponent], // declare the test component
|
||||||
providers: [
|
providers: [
|
||||||
AlfrescoSearchService,
|
AlfrescoSearchService,
|
||||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
{provide: AlfrescoTranslationService, useClass: TranslationMock},
|
||||||
{ provide: NotificationService, useClass: NotificationService }
|
{provide: NotificationService, useClass: NotificationService}
|
||||||
]
|
]
|
||||||
}).compileComponents().then(() => {
|
}).compileComponents().then(() => {
|
||||||
fixture = TestBed.createComponent(AlfrescoSearchComponent);
|
fixture = TestBed.createComponent(AlfrescoSearchComponent);
|
||||||
@@ -155,8 +155,10 @@ describe('AlfrescoSearchComponent', () => {
|
|||||||
|
|
||||||
describe('Search results', () => {
|
describe('Search results', () => {
|
||||||
|
|
||||||
it('should call search service with the correct parameters', (done) => {
|
it('should add wildcard in the search parameters', (done) => {
|
||||||
let searchTerm = 'searchTerm63688', options = {
|
let searchTerm = 'searchTerm6368';
|
||||||
|
let searchTermOut = 'searchTerm6368*';
|
||||||
|
let options = {
|
||||||
include: ['path', 'allowableOperations'],
|
include: ['path', 'allowableOperations'],
|
||||||
skipCount: 0,
|
skipCount: 0,
|
||||||
rootNodeId: '-my-',
|
rootNodeId: '-my-',
|
||||||
@@ -164,6 +166,7 @@ describe('AlfrescoSearchComponent', () => {
|
|||||||
maxItems: 20,
|
maxItems: 20,
|
||||||
orderBy: null
|
orderBy: null
|
||||||
};
|
};
|
||||||
|
|
||||||
component.searchTerm = searchTerm;
|
component.searchTerm = searchTerm;
|
||||||
component.rootNodeId = '-my-';
|
component.rootNodeId = '-my-';
|
||||||
component.resultType = 'my:type';
|
component.resultType = 'my:type';
|
||||||
@@ -174,7 +177,7 @@ describe('AlfrescoSearchComponent', () => {
|
|||||||
|
|
||||||
component.resultsLoad.subscribe(() => {
|
component.resultsLoad.subscribe(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(searchService.getQueryNodesPromise).toHaveBeenCalledWith(searchTerm, options);
|
expect(searchService.getQueryNodesPromise).toHaveBeenCalledWith(searchTermOut, options);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -108,6 +108,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
|
|||||||
*/
|
*/
|
||||||
private displaySearchResults(searchTerm) {
|
private displaySearchResults(searchTerm) {
|
||||||
if (searchTerm && this.searchService) {
|
if (searchTerm && this.searchService) {
|
||||||
|
searchTerm = searchTerm + '*';
|
||||||
let searchOpts: SearchOptions = {
|
let searchOpts: SearchOptions = {
|
||||||
include: ['path', 'allowableOperations'],
|
include: ['path', 'allowableOperations'],
|
||||||
skipCount: this.skipCount,
|
skipCount: this.skipCount,
|
||||||
|
Reference in New Issue
Block a user