From 561a43cf73b9d1571bcaa760073c0e7a449d4185 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 12 Jul 2018 20:45:52 +0530 Subject: [PATCH 1/3] Show search only if a route has list --- ui/components/Desk.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/components/Desk.vue b/ui/components/Desk.vue index f191205c..219d8ed1 100644 --- a/ui/components/Desk.vue +++ b/ui/components/Desk.vue @@ -2,7 +2,7 @@
- +
@@ -18,6 +18,11 @@ export default { FrappeSidebar: Sidebar, FrappeMain: Main, FrappeNavbar: Navbar + }, + computed: { + showSearch() { + return /list|edit/.test(this.$route.path) + } } }; From 8bff2e42fbaab2dcd1d56bd26644be69d6812a18 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 12 Jul 2018 20:47:46 +0530 Subject: [PATCH 2/3] Filter list based on search value --- ui/components/List/List.vue | 14 +++++++++++--- ui/components/Navbar.vue | 35 ++++++++++++++++++++++++++++++----- ui/pages/ListAndForm.vue | 4 ++-- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/ui/components/List/List.vue b/ui/components/List/List.vue index 5e4386d8..7a0acf7e 100644 --- a/ui/components/List/List.vue +++ b/ui/components/List/List.vue @@ -29,7 +29,7 @@ import ListItem from './ListItem'; export default { name: 'List', - props: ['doctype', 'filters'], + props: ['doctype'], components: { ListActions, ListItem @@ -53,6 +53,8 @@ export default { frappe.db.on(`change:${this.doctype}`, () => { this.updateList(); }); + this.$root.$on('search', this.updateList) + this.$root.$emit('newList') }, mounted() { this.updateList(); @@ -62,7 +64,13 @@ export default { let doc = await frappe.getNewDoc(this.doctype); this.$router.push(`/edit/${this.doctype}/${doc.name}`); }, - async updateList() { + async updateList(query=null) { + let filters = null + if (query) { + filters = { + keywords : ['like', query] + } + } const indicatorField = this.hasIndicator ? this.meta.indicators.key : null; const fields = [ 'name', @@ -74,7 +82,7 @@ export default { const data = await frappe.db.getAll({ doctype: this.doctype, fields, - filters: this.filters || null + filters: filters || null }); this.data = data; diff --git a/ui/components/Navbar.vue b/ui/components/Navbar.vue index fcf8f81a..bc007bd1 100644 --- a/ui/components/Navbar.vue +++ b/ui/components/Navbar.vue @@ -1,7 +1,32 @@ + diff --git a/ui/pages/ListAndForm.vue b/ui/pages/ListAndForm.vue index e867c1c2..52b36495 100644 --- a/ui/pages/ListAndForm.vue +++ b/ui/pages/ListAndForm.vue @@ -1,7 +1,7 @@