import Vue from 'vue/dist/vue.js'; // pages import './pages/item'; import './pages/seller'; import './pages/profile'; import './pages/messages'; import './pages/buying_messages'; import './pages/not_found'; import PageContainer from './PageContainer.vue'; import Home from './pages/Home.vue'; import SavedProducts from './pages/SavedProducts.vue'; import Publish from './pages/Publish.vue'; import Category from './pages/Category.vue'; import Search from './pages/Search.vue'; import PublishedProducts from './pages/PublishedProducts.vue'; // components import { ProfileDialog } from './components/profile_dialog'; // helpers import './hub_call'; import EventEmitter from './event_emitter'; frappe.provide('hub'); frappe.provide('erpnext.hub'); $.extend(erpnext.hub, EventEmitter.prototype); erpnext.hub.Marketplace = class Marketplace { constructor({ parent }) { this.$parent = $(parent); this.page = parent.page; frappe.db.get_doc('Hub Settings') .then(doc => { hub.settings = doc; this.registered = doc.registered; this.setup_header(); this.make_sidebar(); this.make_body(); this.setup_events(); this.refresh(); }); } setup_header() { this.page.set_title(__('Marketplace')); } setup_events() { this.$parent.on('click', '[data-route]', (e) => { const $target = $(e.currentTarget); const route = $target.data().route; frappe.set_route(route); }); // generic action handler this.$parent.on('click', '[data-action]', e => { const $target = $(e.currentTarget); const action = $target.data().action; if (action && this[action]) { this[action].apply(this, $target); } }) } make_sidebar() { this.$sidebar = this.$parent.find('.layout-side-section').addClass('hidden-xs'); this.make_sidebar_nav_buttons(); this.make_sidebar_categories(); } make_sidebar_nav_buttons() { let $nav_group = this.$sidebar.find('[data-nav-buttons]'); if (!$nav_group.length) { $nav_group = $('