mirror of
https://github.com/documize/community.git
synced 2025-07-25 08:09:43 +02:00
Auto-load serach results
This commit is contained in:
parent
c92ab3a589
commit
ddd90a4aaf
9 changed files with 804 additions and 763 deletions
|
@ -9,49 +9,14 @@
|
|||
//
|
||||
// https://documize.com
|
||||
|
||||
import { A } from '@ember/array';
|
||||
import { inject as service } from '@ember/service';
|
||||
import Controller from '@ember/controller';
|
||||
|
||||
export default Controller.extend({
|
||||
searchService: service('search'),
|
||||
queryParams: ['filter', 'matchDoc', 'matchContent', 'matchTag', 'matchFile'],
|
||||
queryParams: ['filter', 'matchDoc', 'matchContent', 'matchTag', 'matchFile', 'slog'],
|
||||
filter: '',
|
||||
matchDoc: true,
|
||||
matchContent: true,
|
||||
matchTag: false,
|
||||
matchFile: false,
|
||||
results: A([]),
|
||||
|
||||
fetch() {
|
||||
let self = this;
|
||||
let payload = {
|
||||
keywords: this.get('filter'),
|
||||
doc: this.get('matchDoc'),
|
||||
attachment: this.get('matchFile'),
|
||||
tag: this.get('matchTag'),
|
||||
content: this.get('matchContent')
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
this.get('searchService').find(payload).then(function(response) {
|
||||
self.set('results', response);
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
onSearch() {
|
||||
this.fetch();
|
||||
}
|
||||
}
|
||||
slog: false,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue