2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00

Show items on Link focus (#83)

This commit is contained in:
sahil28297 2018-09-06 13:48:58 +05:30 committed by Faris Ansari
parent 6ada1a8648
commit 4c0e85aaec
3 changed files with 13 additions and 7 deletions

View File

@ -44,4 +44,4 @@ module.exports = class FormModal extends Modal {
} }
} }
} }

View File

@ -17,15 +17,23 @@ export default {
methods: { methods: {
getInputListeners() { getInputListeners() {
return { return {
input: async e => { input: e => {
this.awesomplete.list = await this.getList(e.target.value); this.updateList(e.target.value);
}, },
'awesomplete-select': e => { 'awesomplete-select': e => {
const value = e.text.value; const value = e.text.value;
this.handleChange(value); this.handleChange(value);
},
focus: async e => {
await this.updateList();
this.awesomplete.evaluate();
this.awesomplete.open();
} }
} }
}, },
async updateList(value) {
this.awesomplete.list = await this.getList(value);
},
getList(text) { getList(text) {
return this.docfield.getList(text); return this.docfield.getList(text);
}, },
@ -46,11 +54,9 @@ export default {
return li; return li;
} }
}); });
this.bindEvents(); this.bindEvents();
}, },
bindEvents() { bindEvents() {
}, },
sort() { sort() {
// return a function that handles sorting of items // return a function that handles sorting of items

View File

@ -18,9 +18,9 @@ export default {
async getList(query) { async getList(query) {
const list = await frappe.db.getAll({ const list = await frappe.db.getAll({
doctype: this.getTarget(), doctype: this.getTarget(),
filters: { filters: query ? {
keywords: ['like', query] keywords: ['like', query]
}, } : null,
fields: ['name'], fields: ['name'],
limit: 50 limit: 50
}); });