diff --git a/gui/app/pods/search/controller.js b/gui/app/pods/search/controller.js index 311136ac..ac386c69 100644 --- a/gui/app/pods/search/controller.js +++ b/gui/app/pods/search/controller.js @@ -9,7 +9,7 @@ // // https://documize.com -import { debounce } from '@ember/runloop'; +import { A } from '@ember/array'; import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; @@ -17,34 +17,11 @@ export default Controller.extend({ searchService: service('search'), queryParams: ['filter', 'matchDoc', 'matchContent', 'matchTag', 'matchFile'], filter: '', - onKeywordChange: function () { - debounce(this, this.fetch, 750); - }.observes('filter'), - matchDoc: true, - onMatchDoc: function () { - debounce(this, this.fetch, 750); - }.observes('matchDoc'), - matchContent: true, - onMatchContent: function () { - debounce(this, this.fetch, 750); - }.observes('matchContent'), - matchTag: false, - onMatchTag: function () { - debounce(this, this.fetch, 750); - }.observes('matchTag'), - matchFile: false, - onMatchFile: function () { - debounce(this, this.fetch, 750); - }.observes('matchFile'), - - init() { - this._super(...arguments); - this.results = []; - }, + results: A([]), fetch() { let self = this; @@ -59,9 +36,11 @@ export default Controller.extend({ payload.keywords = payload.keywords.trim(); if (payload.keywords.length == 0) { + this.set('results', A([])); return; } if (!payload.doc && !payload.tag && !payload.content && !payload.attachment) { + this.set('results', A([])); return; } @@ -69,4 +48,10 @@ export default Controller.extend({ self.set('results', response); }); }, + + actions: { + onSearch() { + this.fetch(); + } + } });