1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 15:49:44 +02:00

Search history recording

Controller re-worked.
This commit is contained in:
McMatts 2018-03-30 20:00:49 +01:00
parent b4c4decb3b
commit ee10e6db3b

View file

@ -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();
}
}
});