brotherton-erpnext/erpnext/public/js/hub/hub_factory.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-12-10 16:32:41 +00:00
frappe.provide('erpnext.hub.pages');
frappe.views.HubFactory = frappe.views.Factory.extend({
make(route) {
const page_name = frappe.get_route_str();
const page = route[1];
2018-01-25 03:48:32 +00:00
const assets = {
'List': [
'/assets/erpnext/js/hub/hub_page.js',
'/assets/erpnext/css/hub.css',
],
'Form': [
'/assets/erpnext/js/hub/hub_form.js',
'/assets/erpnext/css/hub.css',
]
};
console.log("make factory?");
2017-12-10 16:32:41 +00:00
if (!erpnext.hub.pages[page_name]) {
2018-01-25 03:48:32 +00:00
console.log("pages?");
2017-12-10 16:32:41 +00:00
if (page === 'Item' && !route[2]) {
2018-01-25 03:48:32 +00:00
frappe.require(assets['List'], () => {
2017-12-10 16:32:41 +00:00
erpnext.hub.pages[page_name] = new erpnext.hub.HubPage({
doctype: 'Hub Settings',
parent: this.make_page(true, page_name)
});
window.hub_page = erpnext.hub.pages[page_name];
});
} else if(route[2]) {
2018-01-25 03:48:32 +00:00
console.log("form?");
frappe.require(assets['Form'], () => {
2017-12-10 16:32:41 +00:00
erpnext.hub.pages[page_name] = new erpnext.hub.HubForm({
hub_item_code: route[2],
doctype: 'Hub Settings',
parent: this.make_page(true, page_name)
});
window.hub_page = erpnext.hub.pages[page_name];
});
}
} else {
2018-01-25 03:48:32 +00:00
console.log("else?");
2017-12-10 16:32:41 +00:00
frappe.container.change_to(page_name);
window.hub_page = erpnext.hub.pages[page_name];
}
}
});