From de426cb543a1389f878bb358bde32fba84c8522f Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Sat, 25 Aug 2018 21:54:49 +0530 Subject: [PATCH] [hub][vue] Home page, add section title in item key in v-for --- .../js/hub/components/ItemCardsContainer.vue | 3 +- .../public/js/hub/components/search_bar.js | 20 ---- erpnext/public/js/hub/marketplace.js | 21 +++- erpnext/public/js/hub/pages/Category.vue | 1 + erpnext/public/js/hub/pages/Home.vue | 103 ++++++++++++++++++ erpnext/public/js/hub/pages/Publish.vue | 1 + .../public/js/hub/pages/PublishedProducts.vue | 1 + erpnext/public/js/hub/pages/SavedProducts.vue | 1 + erpnext/public/js/hub/pages/Search.vue | 5 +- erpnext/public/js/hub/pages/home.js | 60 ---------- 10 files changed, 131 insertions(+), 85 deletions(-) delete mode 100644 erpnext/public/js/hub/components/search_bar.js create mode 100644 erpnext/public/js/hub/pages/Home.vue delete mode 100644 erpnext/public/js/hub/pages/home.js diff --git a/erpnext/public/js/hub/components/ItemCardsContainer.vue b/erpnext/public/js/hub/components/ItemCardsContainer.vue index 741fc6b02c..5af82def82 100644 --- a/erpnext/public/js/hub/components/ItemCardsContainer.vue +++ b/erpnext/public/js/hub/components/ItemCardsContainer.vue @@ -9,7 +9,7 @@ - - ` - ); - wrapper.append($search); - const $search_input = $search.find('input'); - - $search_input.on('keydown', frappe.utils.debounce((e) => { - if (e.which === frappe.ui.keyCode.ENTER) { - const search_value = $search_input.val(); - on_search(search_value); - } - }, 300)); -} - -export { - make_search_bar -} diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js index 0438d6f133..d8bfea8a1b 100644 --- a/erpnext/public/js/hub/marketplace.js +++ b/erpnext/public/js/hub/marketplace.js @@ -1,7 +1,6 @@ import Vue from 'vue/dist/vue.js'; // pages -import './pages/home'; import './pages/item'; import './pages/seller'; import './pages/profile'; @@ -9,6 +8,7 @@ import './pages/messages'; import './pages/buying_messages'; import './pages/not_found'; +import Home from './pages/Home.vue'; import SavedProducts from './pages/SavedProducts.vue'; import Publish from './pages/Publish.vue'; import Category from './pages/Category.vue'; @@ -170,7 +170,7 @@ erpnext.hub.Marketplace = class Marketplace { } if (route[1] === 'home' && !this.subpages.home) { - this.subpages.home = new erpnext.hub.Home(this.$body); + this.subpages.home = new erpnext.hub.HomePage(this.$body); } if (route[1] === 'search' && !this.subpages.search) { @@ -266,6 +266,23 @@ erpnext.hub.Marketplace = class Marketplace { } } +erpnext.hub.HomePage = class { + constructor(parent) { + this.$wrapper = $(`
`).appendTo($(parent)); + + new Vue({ + render: h => h(Home) + }).$mount('#vue-area-home'); + } + + show() { + $('[data-page-name="home"]').show(); + } + + hide() { + $('[data-page-name="home"]').hide(); + } +} erpnext.hub.SavedProductsPage = class { constructor(parent) { diff --git a/erpnext/public/js/hub/pages/Category.vue b/erpnext/public/js/hub/pages/Category.vue index c346ca9392..2a521f4025 100644 --- a/erpnext/public/js/hub/pages/Category.vue +++ b/erpnext/public/js/hub/pages/Category.vue @@ -6,6 +6,7 @@
{{ page_title }}
+
+ + + +
+
+

{{ section.title }}

+

{{ 'See All' }}

+
+ + + +
+ +
+ + + + + diff --git a/erpnext/public/js/hub/pages/Publish.vue b/erpnext/public/js/hub/pages/Publish.vue index f2b3369d2a..b801b92ea1 100644 --- a/erpnext/public/js/hub/pages/Publish.vue +++ b/erpnext/public/js/hub/pages/Publish.vue @@ -21,6 +21,7 @@
{{ page_title }} {{ page_title }} @@ -13,6 +13,7 @@
{{ page_title }}
{ - frappe.set_route('marketplace', 'search', keyword); - } - }); - } - - refresh() { - this.get_items_and_render(); - } - - get_items_and_render() { - this.$wrapper.find('.hub-items-container').empty(); - this.get_data() - .then(data => { - this.render(data); - }); - } - - get_data() { - return hub.call('get_data_for_homepage', { country: frappe.defaults.get_user_default('country') }); - } - - render(data) { - let html = get_item_card_container_html(data.random_items, __('Explore')); - this.$wrapper.append(html); - - if (data.items_by_country.length) { - html = get_item_card_container_html(data.items_by_country, __('Near you')); - this.$wrapper.append(html); - } - - const category_items = data.category_items; - - if (category_items) { - Object.keys(category_items).map(category => { - const items = category_items[category]; - const see_all_link = `

See All

`; - - html = get_item_card_container_html( - items, - __(category), - get_item_card_html, - see_all_link - ); - this.$wrapper.append(html); - }); - } - } -}