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:
Will Abson
2016-11-04 14:21:19 +00:00
parent 903c313615
commit 0e127c26af
13 changed files with 172 additions and 65 deletions

View File

@@ -56,16 +56,29 @@ export class AlfrescoSearchControlComponent implements OnInit, OnDestroy {
searchControl: FormControl;
@ViewChild('searchInput', {}) searchInput: ElementRef;
@ViewChild('searchInput', {})
searchInput: ElementRef;
@ViewChild('autocomplete')
autocompleteComponent: AlfrescoSearchAutocompleteComponent;
@ViewChild(AlfrescoSearchAutocompleteComponent)
liveSearchComponent: AlfrescoSearchAutocompleteComponent;
@Input()
autocompleteEnabled = true;
liveSearchEnabled: boolean = true;
@Input()
autocompleteSearchTerm = '';
liveSearchTerm: string = '';
@Input()
liveSearchRoot: string = '-root-';
@Input()
liveSearchResultType: string = 'cm:content';
@Input()
liveSearchResultSort: string = null;
@Input()
liveSearchMaxResults: number = 5;
searchActive = false;
@@ -99,7 +112,7 @@ export class AlfrescoSearchControlComponent implements OnInit, OnDestroy {
private onSearchTermChange(value: string): void {
this.setAutoCompleteDisplayed(true);
this.autocompleteSearchTerm = value;
this.liveSearchTerm = value;
this.searchControl.setValue(value, true);
this.searchValid = this.searchControl.valid;
this.searchChange.emit({
@@ -195,7 +208,7 @@ export class AlfrescoSearchControlComponent implements OnInit, OnDestroy {
onArrowDown(): void {
if (this.isAutoCompleteDisplayed()) {
this.autocompleteComponent.focusResult();
this.liveSearchComponent.focusResult();
} else {
this.setAutoCompleteDisplayed(true);
}