fix: add new routes to handle category wise search
This commit is contained in:
parent
647331bbd7
commit
2597817cde
@ -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,
|
||||
|
@ -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);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -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 <strong>${this.search_value}<strong> 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();
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user