From 4c0e85aaec10873e30c9d8b4608de1c6fcd1343a Mon Sep 17 00:00:00 2001 From: sahil28297 <37302950+sahil28297@users.noreply.github.com> Date: Thu, 6 Sep 2018 13:48:58 +0530 Subject: [PATCH] Show items on Link focus (#83) --- client/desk/formmodal.js | 2 +- ui/components/controls/Autocomplete.vue | 14 ++++++++++---- ui/components/controls/Link.vue | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/client/desk/formmodal.js b/client/desk/formmodal.js index 52d8624c..ed2883a7 100644 --- a/client/desk/formmodal.js +++ b/client/desk/formmodal.js @@ -44,4 +44,4 @@ module.exports = class FormModal extends Modal { } } -} \ No newline at end of file +} diff --git a/ui/components/controls/Autocomplete.vue b/ui/components/controls/Autocomplete.vue index 2f4b318b..765474de 100644 --- a/ui/components/controls/Autocomplete.vue +++ b/ui/components/controls/Autocomplete.vue @@ -17,15 +17,23 @@ export default { methods: { getInputListeners() { return { - input: async e => { - this.awesomplete.list = await this.getList(e.target.value); + input: e => { + this.updateList(e.target.value); }, 'awesomplete-select': e => { const value = e.text.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) { return this.docfield.getList(text); }, @@ -46,11 +54,9 @@ export default { return li; } }); - this.bindEvents(); }, bindEvents() { - }, sort() { // return a function that handles sorting of items diff --git a/ui/components/controls/Link.vue b/ui/components/controls/Link.vue index f4bb1183..bcdc74df 100644 --- a/ui/components/controls/Link.vue +++ b/ui/components/controls/Link.vue @@ -18,9 +18,9 @@ export default { async getList(query) { const list = await frappe.db.getAll({ doctype: this.getTarget(), - filters: { + filters: query ? { keywords: ['like', query] - }, + } : null, fields: ['name'], limit: 50 });