frappe.provide('erpnext.hub.pages'); frappe.views.marketplaceFactory = class marketplaceFactory extends frappe.views.Factory { show() { const page_name = frappe.get_route_str(); if (frappe.pages.marketplace) { frappe.container.change_to('marketplace'); erpnext.hub.marketplace.refresh(); } else { this.make('marketplace'); } } make(page_name) { const assets = [ '/assets/erpnext/js/hub/hub_listing.js' ]; frappe.require(assets, () => { erpnext.hub.marketplace = new erpnext.hub.Marketplace({ parent: this.make_page(true, page_name) }); }); } } frappe.views.HubFactory = class HubFactory extends frappe.views.Factory { make(route) { const page_name = frappe.get_route_str(); const page = route[1]; const assets = { 'List': [ '/assets/erpnext/js/hub/hub_listing.js', ], 'Form': [ '/assets/erpnext/js/hub/hub_form.js' ] }; frappe.model.with_doc('Hub Settings', 'Hub Settings', () => { this.hub_settings = frappe.get_doc('Hub Settings'); if (!erpnext.hub.pages[page_name]) { if(!frappe.is_online()) { this.render_offline_card(); return; } if (!route[2]) { frappe.require(assets['List'], () => { if(page === 'Favourites') { erpnext.hub.pages[page_name] = new erpnext.hub['Favourites']({ parent: this.make_page(true, page_name), hub_settings: this.hub_settings }); } else { erpnext.hub.pages[page_name] = new erpnext.hub[page+'Listing']({ parent: this.make_page(true, page_name), hub_settings: this.hub_settings }); } }); } else if (!route[3]){ frappe.require(assets['Form'], () => { erpnext.hub.pages[page_name] = new erpnext.hub[page+'Page']({ unique_id: route[2], doctype: route[2], parent: this.make_page(true, page_name), hub_settings: this.hub_settings }); }); } else { frappe.require(assets['List'], () => { frappe.route_options = {}; frappe.route_options["company_name"] = route[2] erpnext.hub.pages[page_name] = new erpnext.hub['ItemListing']({ parent: this.make_page(true, page_name), hub_settings: this.hub_settings }); }); } window.hub_page = erpnext.hub.pages[page_name]; } else { frappe.container.change_to(page_name); window.hub_page = erpnext.hub.pages[page_name]; } }); } render_offline_card() { let html = `
${'Failed to connect'}

${ __("Please check your network connection.") }

${ __("Reload") }
`; let page = $('#body_div'); page.append(html); return; } }