2018-08-01 08:39:07 +00:00
|
|
|
frappe.provide('erpnext.hub');
|
2017-12-10 16:32:41 +00:00
|
|
|
|
2018-07-23 13:14:46 +00:00
|
|
|
frappe.views.marketplaceFactory = class marketplaceFactory extends frappe.views.Factory {
|
|
|
|
show() {
|
2018-08-31 10:05:32 +00:00
|
|
|
is_marketplace_disabled()
|
|
|
|
.then(disabled => {
|
|
|
|
if (disabled) {
|
|
|
|
frappe.show_not_found('Marketplace');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frappe.pages.marketplace) {
|
|
|
|
frappe.container.change_to('marketplace');
|
|
|
|
erpnext.hub.marketplace.refresh();
|
|
|
|
} else {
|
|
|
|
this.make('marketplace');
|
|
|
|
}
|
|
|
|
});
|
2018-07-23 13:14:46 +00:00
|
|
|
}
|
2017-12-10 16:32:41 +00:00
|
|
|
|
2018-07-23 13:14:46 +00:00
|
|
|
make(page_name) {
|
|
|
|
const assets = [
|
2018-08-01 08:39:07 +00:00
|
|
|
'/assets/js/marketplace.min.js'
|
2018-07-23 13:14:46 +00:00
|
|
|
];
|
2018-01-25 03:48:32 +00:00
|
|
|
|
2018-07-23 13:14:46 +00:00
|
|
|
frappe.require(assets, () => {
|
|
|
|
erpnext.hub.marketplace = new erpnext.hub.Marketplace({
|
|
|
|
parent: this.make_page(true, page_name)
|
|
|
|
});
|
2018-02-15 04:47:07 +00:00
|
|
|
});
|
2018-07-25 11:21:01 +00:00
|
|
|
}
|
2018-08-29 08:57:47 +00:00
|
|
|
};
|
2018-04-03 05:14:13 +00:00
|
|
|
|
2018-08-31 10:05:32 +00:00
|
|
|
function is_marketplace_disabled() {
|
|
|
|
return frappe.model.with_doc('Hub Settings')
|
|
|
|
.then(doc => doc.disable_marketplace);
|
|
|
|
}
|
|
|
|
|
2018-08-01 10:26:39 +00:00
|
|
|
$(document).on('toolbar_setup', () => {
|
|
|
|
$('#toolbar-user .navbar-reload').after(`
|
|
|
|
<li>
|
2018-08-31 10:05:32 +00:00
|
|
|
<a class="marketplace-link" href="#marketplace/home">${__('Marketplace')}
|
2018-08-01 10:26:39 +00:00
|
|
|
</li>
|
2018-08-29 08:57:47 +00:00
|
|
|
`);
|
2018-08-31 10:05:32 +00:00
|
|
|
|
|
|
|
is_marketplace_disabled()
|
|
|
|
.then(disabled => {
|
|
|
|
if (disabled) {
|
|
|
|
$('#toolbar-user .marketplace-link').hide();
|
|
|
|
}
|
|
|
|
});
|
2018-08-29 08:57:47 +00:00
|
|
|
});
|