mirror of
https://github.com/documize/community.git
synced 2025-07-27 00:59:43 +02:00
Search history recording
Controller re-worked.
This commit is contained in:
parent
b4c4decb3b
commit
ee10e6db3b
1 changed files with 10 additions and 25 deletions
|
@ -9,7 +9,7 @@
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
import { debounce } from '@ember/runloop';
|
import { A } from '@ember/array';
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
import Controller from '@ember/controller';
|
import Controller from '@ember/controller';
|
||||||
|
|
||||||
|
@ -17,34 +17,11 @@ export default Controller.extend({
|
||||||
searchService: service('search'),
|
searchService: service('search'),
|
||||||
queryParams: ['filter', 'matchDoc', 'matchContent', 'matchTag', 'matchFile'],
|
queryParams: ['filter', 'matchDoc', 'matchContent', 'matchTag', 'matchFile'],
|
||||||
filter: '',
|
filter: '',
|
||||||
onKeywordChange: function () {
|
|
||||||
debounce(this, this.fetch, 750);
|
|
||||||
}.observes('filter'),
|
|
||||||
|
|
||||||
matchDoc: true,
|
matchDoc: true,
|
||||||
onMatchDoc: function () {
|
|
||||||
debounce(this, this.fetch, 750);
|
|
||||||
}.observes('matchDoc'),
|
|
||||||
|
|
||||||
matchContent: true,
|
matchContent: true,
|
||||||
onMatchContent: function () {
|
|
||||||
debounce(this, this.fetch, 750);
|
|
||||||
}.observes('matchContent'),
|
|
||||||
|
|
||||||
matchTag: false,
|
matchTag: false,
|
||||||
onMatchTag: function () {
|
|
||||||
debounce(this, this.fetch, 750);
|
|
||||||
}.observes('matchTag'),
|
|
||||||
|
|
||||||
matchFile: false,
|
matchFile: false,
|
||||||
onMatchFile: function () {
|
results: A([]),
|
||||||
debounce(this, this.fetch, 750);
|
|
||||||
}.observes('matchFile'),
|
|
||||||
|
|
||||||
init() {
|
|
||||||
this._super(...arguments);
|
|
||||||
this.results = [];
|
|
||||||
},
|
|
||||||
|
|
||||||
fetch() {
|
fetch() {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
@ -59,9 +36,11 @@ export default Controller.extend({
|
||||||
payload.keywords = payload.keywords.trim();
|
payload.keywords = payload.keywords.trim();
|
||||||
|
|
||||||
if (payload.keywords.length == 0) {
|
if (payload.keywords.length == 0) {
|
||||||
|
this.set('results', A([]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!payload.doc && !payload.tag && !payload.content && !payload.attachment) {
|
if (!payload.doc && !payload.tag && !payload.content && !payload.attachment) {
|
||||||
|
this.set('results', A([]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,4 +48,10 @@ export default Controller.extend({
|
||||||
self.set('results', response);
|
self.set('results', response);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
onSearch() {
|
||||||
|
this.fetch();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue