From 1243b661c20367d067c22a03223eb6b4ed9781c6 Mon Sep 17 00:00:00 2001 From: "greenlogic.ar@gmail.com" Date: Wed, 31 Jan 2018 19:47:49 -0300 Subject: [PATCH] search component added option inputValue, allows to set the value of input field without triggering a search, if input value changes a new search is made and the inputValue is ignored, usefull in forms where a search trigger a query to google maps and add a form with the selected address, if the form is opened for editing the search field must show a formatted_address without triggering a search. --- src/modules/search/components/search.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/modules/search/components/search.ts b/src/modules/search/components/search.ts index d6dc2cfc7..057fe0871 100644 --- a/src/modules/search/components/search.ts +++ b/src/modules/search/components/search.ts @@ -54,6 +54,7 @@ export interface IResultContext extends ITemplateRefContext { export class SuiSearch implements AfterViewInit, OnDestroy { public dropdownService:DropdownService; public searchService:SearchService; + private _inputValue:any = false; @ViewChild(SuiDropdownMenu) private _menu:SuiDropdownMenu; @@ -85,6 +86,12 @@ export class SuiSearch implements AfterViewInit, OnDestroy { this._placeholder = placeholder; } + // Sets the input value text without triggering a search. + @Input() + public set inputValue(query:string) { + this._inputValue = (query == '' || query == null)?false:query; + } + private _localeValues:ISearchLocaleValues; public localeOverrides:RecursivePartial; @@ -94,10 +101,16 @@ export class SuiSearch implements AfterViewInit, OnDestroy { } public get query():string { - return this.searchService.query; + if(this._inputValue){ + return this._inputValue; + } + else{ + return this.searchService.query; + } } public set query(query:string) { + this._inputValue = false; this.selectedResult = undefined; // Initialise a delayed search. this.searchService.updateQueryDelayed(query, () =>