2018-08-25 15:01:48 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
class="marketplace-page"
|
|
|
|
:data-page-name="page_name"
|
|
|
|
>
|
|
|
|
<search-input
|
|
|
|
:placeholder="search_placeholder"
|
2018-08-25 16:24:49 +00:00
|
|
|
:on_search="set_route_and_get_items"
|
2018-08-25 15:01:48 +00:00
|
|
|
v-model="search_value"
|
|
|
|
>
|
|
|
|
</search-input>
|
|
|
|
|
|
|
|
<h5>{{ page_title }}</h5>
|
|
|
|
|
|
|
|
<item-cards-container
|
2018-08-25 16:24:49 +00:00
|
|
|
container_name="Search"
|
2018-08-25 15:01:48 +00:00
|
|
|
:items="items"
|
|
|
|
:item_id_fieldname="item_id_fieldname"
|
|
|
|
:on_click="go_to_item_details_page"
|
|
|
|
:empty_state_message="empty_state_message"
|
|
|
|
>
|
|
|
|
</item-cards-container>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
page_name: frappe.get_route()[1],
|
|
|
|
items: [],
|
2019-11-28 13:27:42 +00:00
|
|
|
category: frappe.get_route()[2],
|
|
|
|
search_value: frappe.get_route()[3],
|
2018-08-27 08:41:48 +00:00
|
|
|
item_id_fieldname: 'name',
|
2019-11-28 13:27:42 +00:00
|
|
|
filters: {},
|
2018-08-25 15:01:48 +00:00
|
|
|
|
|
|
|
// Constants
|
|
|
|
search_placeholder: __('Search for anything ...'),
|
|
|
|
empty_state_message: __('')
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
page_title() {
|
|
|
|
return this.items.length
|
2020-11-25 03:41:51 +00:00
|
|
|
? __('Results for "{0}" {1}', [
|
|
|
|
this.search_value,
|
|
|
|
this.category !== 'All' ? __('in category {0}', [this.category]) : ''
|
|
|
|
])
|
2018-08-30 10:05:06 +00:00
|
|
|
: __('No Items found.');
|
2018-08-25 15:01:48 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.get_items();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
get_items() {
|
2019-11-28 13:27:42 +00:00
|
|
|
if (this.category !== 'All') {
|
2019-12-04 12:21:08 +00:00
|
|
|
this.filters['hub_category'] = this.category;
|
2019-11-28 13:27:42 +00:00
|
|
|
}
|
2019-12-04 12:21:08 +00:00
|
|
|
hub.call('get_items', {
|
|
|
|
keyword: this.search_value,
|
2019-11-28 13:27:42 +00:00
|
|
|
filters: this.filters
|
|
|
|
})
|
2018-08-25 15:01:48 +00:00
|
|
|
.then((items) => {
|
|
|
|
this.items = items;
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2018-08-25 16:24:49 +00:00
|
|
|
set_route_and_get_items() {
|
2019-11-28 13:27:42 +00:00
|
|
|
frappe.set_route('marketplace', 'search', this.category, this.search_value);
|
2018-08-25 15:01:48 +00:00
|
|
|
this.get_items();
|
|
|
|
},
|
|
|
|
|
2018-08-27 08:41:48 +00:00
|
|
|
go_to_item_details_page(hub_item_name) {
|
|
|
|
frappe.set_route(`marketplace/item/${hub_item_name}`);
|
2018-08-25 15:01:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|