From 647331bbd70a8d1b7c1b47c974175bbcbb70d15e Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Mon, 25 Nov 2019 13:56:00 +0530 Subject: [PATCH 1/4] feat: add search in category --- erpnext/public/js/hub/pages/Category.vue | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/erpnext/public/js/hub/pages/Category.vue b/erpnext/public/js/hub/pages/Category.vue index 3a0e6bfab8..a1d5d729cc 100644 --- a/erpnext/public/js/hub/pages/Category.vue +++ b/erpnext/public/js/hub/pages/Category.vue @@ -3,6 +3,12 @@ class="marketplace-page" :data-page-name="page_name" > + +
{{ page_title }}
From 2597817cdeb025caa1f4d4fb7fee49831761778a Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Thu, 28 Nov 2019 18:57:42 +0530 Subject: [PATCH 2/4] fix: add new routes to handle category wise search --- erpnext/public/js/hub/PageContainer.vue | 2 +- erpnext/public/js/hub/pages/Category.vue | 2 +- erpnext/public/js/hub/pages/Home.vue | 2 +- erpnext/public/js/hub/pages/Search.vue | 15 +++++++++++---- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/erpnext/public/js/hub/PageContainer.vue b/erpnext/public/js/hub/PageContainer.vue index f151add8d5..54c359766d 100644 --- a/erpnext/public/js/hub/PageContainer.vue +++ b/erpnext/public/js/hub/PageContainer.vue @@ -24,7 +24,7 @@ import NotFound from './pages/NotFound.vue'; function get_route_map() { const read_only_routes = { 'marketplace/home': Home, - 'marketplace/search/:keyword': Search, + 'marketplace/search/:category/:keyword': Search, 'marketplace/category/:category': Category, 'marketplace/item/:item': Item, 'marketplace/seller/:seller': Seller, diff --git a/erpnext/public/js/hub/pages/Category.vue b/erpnext/public/js/hub/pages/Category.vue index a1d5d729cc..057fe8bc61 100644 --- a/erpnext/public/js/hub/pages/Category.vue +++ b/erpnext/public/js/hub/pages/Category.vue @@ -67,7 +67,7 @@ export default { }, set_search_route() { - frappe.set_route('marketplace', 'search', this.search_value); + frappe.set_route('marketplace', 'search', this.category, this.search_value); }, } } diff --git a/erpnext/public/js/hub/pages/Home.vue b/erpnext/public/js/hub/pages/Home.vue index 353656957d..aaeaa7eb7c 100644 --- a/erpnext/public/js/hub/pages/Home.vue +++ b/erpnext/public/js/hub/pages/Home.vue @@ -98,7 +98,7 @@ export default { }, set_search_route() { - frappe.set_route('marketplace', 'search', this.search_value); + frappe.set_route('marketplace', 'search', 'All', this.search_value); }, } } diff --git a/erpnext/public/js/hub/pages/Search.vue b/erpnext/public/js/hub/pages/Search.vue index 5118a814e0..2a6088925f 100644 --- a/erpnext/public/js/hub/pages/Search.vue +++ b/erpnext/public/js/hub/pages/Search.vue @@ -29,8 +29,10 @@ export default { return { page_name: frappe.get_route()[1], items: [], - search_value: frappe.get_route()[2], + category: frappe.get_route()[2], + search_value: frappe.get_route()[3], item_id_fieldname: 'name', + filters: {}, // Constants search_placeholder: __('Search for anything ...'), @@ -40,7 +42,7 @@ export default { computed: { page_title() { return this.items.length - ? __(`Results for "${this.search_value}"`) + ? __(`Results for ${this.search_value} in category ${this.category}`) : __('No Items found.'); } }, @@ -49,14 +51,19 @@ export default { }, methods: { get_items() { - hub.call('get_items', { keyword: this.search_value }) + if (this.category !== 'All') { + this.filters['hub_category']=this.category; + } + hub.call('get_items', { keyword: this.search_value, + filters: this.filters + }) .then((items) => { this.items = items; }) }, set_route_and_get_items() { - frappe.set_route('marketplace', 'search', this.search_value); + frappe.set_route('marketplace', 'search', this.category, this.search_value); this.get_items(); }, From ad66677029bccd534639ef8158dcf7f1af03e2d7 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Fri, 29 Nov 2019 23:59:02 +0530 Subject: [PATCH 3/4] fix: add conditional message in template string --- erpnext/public/js/hub/pages/Search.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/hub/pages/Search.vue b/erpnext/public/js/hub/pages/Search.vue index 2a6088925f..8ab48d0e8d 100644 --- a/erpnext/public/js/hub/pages/Search.vue +++ b/erpnext/public/js/hub/pages/Search.vue @@ -42,7 +42,7 @@ export default { computed: { page_title() { return this.items.length - ? __(`Results for ${this.search_value} in category ${this.category}`) + ? __(`Results for "${this.search_value}" ${this.category!=='All'? `in category ${this.category}`: ''}`) : __('No Items found.'); } }, From e4274cbfa64d7c364cfd2e0907fda5e459194a70 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Wed, 4 Dec 2019 17:51:08 +0530 Subject: [PATCH 4/4] fix: change formatting --- erpnext/public/js/hub/pages/Search.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/public/js/hub/pages/Search.vue b/erpnext/public/js/hub/pages/Search.vue index 8ab48d0e8d..103284289b 100644 --- a/erpnext/public/js/hub/pages/Search.vue +++ b/erpnext/public/js/hub/pages/Search.vue @@ -42,7 +42,7 @@ export default { computed: { page_title() { return this.items.length - ? __(`Results for "${this.search_value}" ${this.category!=='All'? `in category ${this.category}`: ''}`) + ? __(`Results for "${this.search_value}" ${this.category !== 'All'? `in category ${this.category}` : ''}`) : __('No Items found.'); } }, @@ -52,9 +52,10 @@ export default { methods: { get_items() { if (this.category !== 'All') { - this.filters['hub_category']=this.category; + this.filters['hub_category'] = this.category; } - hub.call('get_items', { keyword: this.search_value, + hub.call('get_items', { + keyword: this.search_value, filters: this.filters }) .then((items) => {