mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Update search component to work with 0.4.0 JS API
- Use new search (query) methods - Allow search parameters to be overridden by component - Fix up tests Refs #555
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, ElementRef, EventEmitter, Input, OnInit, OnChanges, Output, ViewChild } from '@angular/core';
|
||||
import { AlfrescoSearchService } from './../services/alfresco-search.service';
|
||||
import { AlfrescoSearchService, SearchOptions } from './../services/alfresco-search.service';
|
||||
import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service';
|
||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||
|
||||
@@ -43,6 +43,15 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
|
||||
@Input()
|
||||
maxResults: number = 5;
|
||||
|
||||
@Input()
|
||||
resultSort: string = null;
|
||||
|
||||
@Input()
|
||||
rootNodeId: string = '-root';
|
||||
|
||||
@Input()
|
||||
resultType: string = null;
|
||||
|
||||
@Output()
|
||||
fileSelect: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
@@ -84,9 +93,16 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
|
||||
* @param searchTerm Search query entered by user
|
||||
*/
|
||||
private displaySearchResults(searchTerm) {
|
||||
let searchOpts: SearchOptions = {
|
||||
include: ['path'],
|
||||
rootNodeId: this.rootNodeId,
|
||||
nodeType: this.resultType,
|
||||
maxItems: this.maxResults,
|
||||
orderBy: this.resultSort
|
||||
};
|
||||
if (searchTerm !== null && searchTerm !== '') {
|
||||
this.alfrescoSearchService
|
||||
.getLiveSearchResults(searchTerm)
|
||||
.getNodeQueryResults(searchTerm, searchOpts)
|
||||
.subscribe(
|
||||
results => {
|
||||
this.results = results.list.entries.slice(0, this.maxResults);
|
||||
|
Reference in New Issue
Block a user