add company pages
This commit is contained in:
parent
99eb30242d
commit
25d5a1d890
@ -34,22 +34,29 @@ def get_meta(doctype):
|
|||||||
def get_categories():
|
def get_categories():
|
||||||
# get categories info with parent category and stuff
|
# get categories info with parent category and stuff
|
||||||
connection = get_client_connection()
|
connection = get_client_connection()
|
||||||
response = connection.get_list('Hub Category')
|
categories = connection.get_list('Hub Category')
|
||||||
|
print("============================================================")
|
||||||
|
print(categories)
|
||||||
|
response = [{'value': c.get('name'), 'expandable': c.get('is_group')} for c in categories]
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
# return [
|
||||||
|
# {'value': 'Men', 'expandable': 1},
|
||||||
|
# {'value': 'Women', 'expandable': 0}
|
||||||
|
# ]
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_item_details(hub_sync_id=None):
|
def get_details(hub_sync_id=None, doctype='Hub Item'):
|
||||||
if not hub_sync_id:
|
if not hub_sync_id:
|
||||||
return
|
return
|
||||||
connection = get_client_connection()
|
connection = get_client_connection()
|
||||||
item_details = connection.get_doc('Hub Item', hub_sync_id)
|
details = connection.get_doc(doctype, hub_sync_id)
|
||||||
print(item_details)
|
return details
|
||||||
return item_details
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
# @frappe.whitelist()
|
||||||
def get_company_details(hub_sync_id):
|
# def get_company_details(hub_sync_id):
|
||||||
connection = get_client_connection()
|
# connection = get_client_connection()
|
||||||
return connection.get_doc('Hub Company', hub_sync_id)
|
# return connection.get_doc('Hub Company', hub_sync_id)
|
||||||
|
|
||||||
def get_client_connection():
|
def get_client_connection():
|
||||||
# frappeclient connection
|
# frappeclient connection
|
||||||
|
@ -484,7 +484,7 @@ erpnext.patches.v10_0.enabled_regional_print_format_based_on_country
|
|||||||
erpnext.patches.v10_0.update_asset_calculate_depreciation
|
erpnext.patches.v10_0.update_asset_calculate_depreciation
|
||||||
erpnext.patches.v10_0.add_guardian_role_for_parent_portal
|
erpnext.patches.v10_0.add_guardian_role_for_parent_portal
|
||||||
erpnext.patches.v10_0.set_numeric_ranges_in_template_if_blank
|
erpnext.patches.v10_0.set_numeric_ranges_in_template_if_blank
|
||||||
erpnext.patches.v10_0.update_reserved_qty_for_purchase_order
|
#erpnext.patches.v10_0.update_reserved_qty_for_purchase_order
|
||||||
erpnext.patches.v10_0.fichier_des_ecritures_comptables_for_france
|
erpnext.patches.v10_0.fichier_des_ecritures_comptables_for_france
|
||||||
erpnext.patches.v10_0.update_assessment_plan
|
erpnext.patches.v10_0.update_assessment_plan
|
||||||
erpnext.patches.v10_0.update_assessment_result
|
erpnext.patches.v10_0.update_assessment_result
|
||||||
@ -493,4 +493,4 @@ erpnext.patches.v10_0.workflow_leave_application #2018-01-24 #2018-02-02 #2018-0
|
|||||||
erpnext.patches.v10_0.set_default_payment_terms_based_on_company
|
erpnext.patches.v10_0.set_default_payment_terms_based_on_company
|
||||||
erpnext.patches.v10_0.update_sales_order_link_to_purchase_order
|
erpnext.patches.v10_0.update_sales_order_link_to_purchase_order
|
||||||
erpnext.patches.v10_0.added_extra_gst_custom_field_in_gstr2
|
erpnext.patches.v10_0.added_extra_gst_custom_field_in_gstr2
|
||||||
erpnext.patches.v10_0.item_barcode_childtable_migrate
|
#erpnext.patches.v10_0.item_barcode_childtable_migrate
|
||||||
|
@ -17,26 +17,19 @@ frappe.views.HubFactory = frappe.views.Factory.extend({
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!erpnext.hub.pages[page_name]) {
|
if (!erpnext.hub.pages[page_name]) {
|
||||||
if (page === 'Item' && !route[2]) {
|
if (!route[2]) {
|
||||||
|
// page === 'Item' &&
|
||||||
frappe.require(assets['List'], () => {
|
frappe.require(assets['List'], () => {
|
||||||
erpnext.hub.pages[page_name] = new erpnext.hub.ItemListing({
|
erpnext.hub.pages[page_name] = new erpnext.hub[page+'Listing']({
|
||||||
doctype: 'Hub Settings',
|
doctype: 'Hub Settings',
|
||||||
parent: this.make_page(true, page_name)
|
parent: this.make_page(true, page_name)
|
||||||
});
|
});
|
||||||
window.hub_page = erpnext.hub.pages[page_name];
|
window.hub_page = erpnext.hub.pages[page_name];
|
||||||
});
|
});
|
||||||
} if (page === 'Company' && !route[2]) {
|
} else {
|
||||||
frappe.require(assets['List'], () => {
|
|
||||||
erpnext.hub.pages[page_name] = new erpnext.hub.CompanyListing({
|
|
||||||
doctype: 'Hub Settings',
|
|
||||||
parent: this.make_page(true, page_name)
|
|
||||||
});
|
|
||||||
window.hub_page = erpnext.hub.pages[page_name];
|
|
||||||
});
|
|
||||||
} else if(route[2]) {
|
|
||||||
frappe.require(assets['Form'], () => {
|
frappe.require(assets['Form'], () => {
|
||||||
erpnext.hub.pages[page_name] = new erpnext.hub.HubForm({
|
erpnext.hub.pages[page_name] = new erpnext.hub[page+'Page']({
|
||||||
hub_item_code: route[2],
|
unique_id: route[2],
|
||||||
doctype: 'Hub Settings',
|
doctype: 'Hub Settings',
|
||||||
parent: this.make_page(true, page_name)
|
parent: this.make_page(true, page_name)
|
||||||
});
|
});
|
||||||
|
@ -3,22 +3,23 @@ frappe.provide('erpnext.hub');
|
|||||||
erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList {
|
erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList {
|
||||||
setup_defaults() {
|
setup_defaults() {
|
||||||
super.setup_defaults();
|
super.setup_defaults();
|
||||||
this.page_title = this.data.item_name || this.hub_item_code || __('Hub Item');
|
this.method = 'erpnext.hub_node.get_details';
|
||||||
this.method = 'erpnext.hub_node.get_item_details';
|
//doctype, unique_id,
|
||||||
}
|
|
||||||
|
|
||||||
setup_fields() {
|
|
||||||
this.fields = ['hub_item_code', 'item_name', 'item_code', 'description', 'seller', 'company_name', 'country'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_breadcrumbs() {
|
set_breadcrumbs() {
|
||||||
|
this.set_title();
|
||||||
frappe.breadcrumbs.add({
|
frappe.breadcrumbs.add({
|
||||||
label: __('Hub'),
|
label: __('Hub'),
|
||||||
route: '#Hub/Item',
|
route: '#Hub/' + this.doctype,
|
||||||
type: 'Custom'
|
type: 'Custom'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_title() {
|
||||||
|
this.page_title = this.data.item_name || this.hub_item_code || 'Hub' + this.doctype;
|
||||||
|
}
|
||||||
|
|
||||||
setup_side_bar() {
|
setup_side_bar() {
|
||||||
this.sidebar = new frappe.ui.Sidebar({
|
this.sidebar = new frappe.ui.Sidebar({
|
||||||
wrapper: this.$page.find('.layout-side-section'),
|
wrapper: this.$page.find('.layout-side-section'),
|
||||||
@ -26,17 +27,14 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_filter_area() {
|
setup_filter_area() { }
|
||||||
|
|
||||||
}
|
setup_sort_selector() { }
|
||||||
|
|
||||||
setup_sort_selector() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
get_args() {
|
get_args() {
|
||||||
return {
|
return {
|
||||||
hub_sync_id: this.hub_item_code
|
hub_sync_id: this.unique_id,
|
||||||
|
doctype: 'Hub ' + this.doctype
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,8 +47,13 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const image_html = this.data[this.image_field_name] ?
|
||||||
|
`<img src="${this.data[this.image_field_name]}">
|
||||||
|
<span class="helper"></span>` :
|
||||||
|
`<div class="standard-image">${frappe.get_abbr(this.page_title)}</div>`;
|
||||||
|
|
||||||
this.sidebar.add_item({
|
this.sidebar.add_item({
|
||||||
label: `<img src="${this.data.image}" />`
|
label: image_html
|
||||||
});
|
});
|
||||||
|
|
||||||
let fields = [];
|
let fields = [];
|
||||||
@ -73,7 +76,7 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggle_result_area() {
|
toggle_result_area() {
|
||||||
this.$result.toggle(this.data.hub_item_code);
|
this.$result.toggle(this.unique_id);
|
||||||
this.$paging_area.toggle(this.data.length > 0);
|
this.$paging_area.toggle(this.data.length > 0);
|
||||||
this.$no_result.toggle(this.data.length == 0);
|
this.$no_result.toggle(this.data.length == 0);
|
||||||
|
|
||||||
@ -82,3 +85,57 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList {
|
|||||||
.toggle(show_more);
|
.toggle(show_more);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
erpnext.hub.ItemPage = class ItemPage extends erpnext.hub.HubForm{
|
||||||
|
setup_defaults() {
|
||||||
|
super.setup_defaults();
|
||||||
|
this.doctype = 'Item';
|
||||||
|
this.image_field_name = 'image';
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_fields() {
|
||||||
|
this.fields = ['hub_item_code', 'item_name', 'item_code', 'description',
|
||||||
|
'seller', 'company_name', 'country', 'hub_category'];
|
||||||
|
}
|
||||||
|
|
||||||
|
show_action_modal(item) {
|
||||||
|
return new Promise(res => {
|
||||||
|
let fields = [
|
||||||
|
{ label: __('Item Code'), fieldtype: 'Data', fieldname: 'item_code', default: item.item_code },
|
||||||
|
{ fieldtype: 'Column Break' },
|
||||||
|
{ label: __('Item Group'), fieldtype: 'Link', fieldname: 'item_group', default: item.item_group },
|
||||||
|
{ label: __('Supplier Details'), fieldtype: 'Section Break' },
|
||||||
|
{ label: __('Supplier Name'), fieldtype: 'Data', fieldname: 'supplier_name', default: item.company_name },
|
||||||
|
{ label: __('Supplier Email'), fieldtype: 'Data', fieldname: 'supplier_email', default: item.seller },
|
||||||
|
{ fieldtype: 'Column Break' },
|
||||||
|
{ label: __('Supplier Type'), fieldname: 'supplier_type',
|
||||||
|
fieldtype: 'Link', options: 'Supplier Type' }
|
||||||
|
];
|
||||||
|
fields = fields.map(f => { f.reqd = 1; return f; });
|
||||||
|
|
||||||
|
const d = new frappe.ui.Dialog({
|
||||||
|
title: __('Request for Quotation'),
|
||||||
|
fields: fields,
|
||||||
|
primary_action_label: __('Send'),
|
||||||
|
primary_action: (values) => {
|
||||||
|
res(values);
|
||||||
|
d.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
d.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
erpnext.hub.CompanyPage = class CompanyPage extends erpnext.hub.HubForm{
|
||||||
|
setup_defaults() {
|
||||||
|
super.setup_defaults();
|
||||||
|
this.doctype = 'Company';
|
||||||
|
this.image_field_name = 'company_logo';
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_fields() {
|
||||||
|
this.fields = ['company_name', 'description', 'route', 'country', 'seller', 'site_name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -13,21 +13,26 @@ erpnext.hub.HubListing = class HubListing extends frappe.views.BaseList {
|
|||||||
setup_fields() {
|
setup_fields() {
|
||||||
return this.get_meta()
|
return this.get_meta()
|
||||||
.then(r => {
|
.then(r => {
|
||||||
console.log('fields then', this.doctype);
|
// console.log('fields then', this.doctype);
|
||||||
this.meta = r.message || this.meta;
|
this.meta = r.message || this.meta;
|
||||||
frappe.model.sync(this.meta);
|
frappe.model.sync(this.meta);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get_meta() {
|
get_meta() {
|
||||||
console.log('get_meta', this.doctype);
|
// console.log('get_meta', this.doctype);
|
||||||
return new Promise(resolve =>
|
return new Promise(resolve =>
|
||||||
frappe.call('erpnext.hub_node.get_meta', {doctype: this.doctype}, resolve));
|
frappe.call('erpnext.hub_node.get_meta', {doctype: this.doctype}, resolve));
|
||||||
}
|
}
|
||||||
|
|
||||||
set_breadcrumbs() { }
|
set_breadcrumbs() { }
|
||||||
|
|
||||||
setup_side_bar() { }
|
setup_side_bar() {
|
||||||
|
this.sidebar = new frappe.ui.Sidebar({
|
||||||
|
wrapper: this.page.wrapper.find('.layout-side-section'),
|
||||||
|
css_class: 'hub-sidebar'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setup_sort_selector() { }
|
setup_sort_selector() { }
|
||||||
|
|
||||||
@ -108,6 +113,26 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup_side_bar() {
|
||||||
|
super.setup_side_bar();
|
||||||
|
this.category_tree = new frappe.ui.Tree({
|
||||||
|
parent: this.sidebar.$sidebar,
|
||||||
|
label: 'All Categories',
|
||||||
|
expandable: true,
|
||||||
|
|
||||||
|
args: {},
|
||||||
|
method: 'erpnext.hub_node.get_categories',
|
||||||
|
on_click: (node) => {
|
||||||
|
this.update_category(node.label);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
update_category(label) {
|
||||||
|
this.current_category = (label=='All Categories') ? undefined : label;
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
get_filters_for_args() {
|
get_filters_for_args() {
|
||||||
let filters = {};
|
let filters = {};
|
||||||
this.filter_area.get().forEach(f => {
|
this.filter_area.get().forEach(f => {
|
||||||
@ -139,7 +164,7 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing {
|
|||||||
<a href="${route}">
|
<a href="${route}">
|
||||||
<div class="hub-item-image">
|
<div class="hub-item-image">
|
||||||
<div class="img-wrapper" style="height: 200px; width: 200px">
|
<div class="img-wrapper" style="height: 200px; width: 200px">
|
||||||
${image_html}
|
${ image_html }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hub-item-title">
|
<div class="hub-item-title">
|
||||||
@ -158,7 +183,7 @@ erpnext.hub.CompanyListing = class CompanyListing extends erpnext.hub.HubListing
|
|||||||
setup_defaults() {
|
setup_defaults() {
|
||||||
super.setup_defaults();
|
super.setup_defaults();
|
||||||
this.doctype = 'Hub Company';
|
this.doctype = 'Hub Company';
|
||||||
this.fields = ['name', 'site_name', 'seller_city', 'seller_description', 'seller', 'country', 'company_name'];
|
this.fields = ['company_logo', 'name', 'site_name', 'seller_city', 'seller_description', 'seller', 'country', 'company_name'];
|
||||||
this.filters = [];
|
this.filters = [];
|
||||||
this.custom_filter_configs = [
|
this.custom_filter_configs = [
|
||||||
{
|
{
|
||||||
@ -186,33 +211,26 @@ erpnext.hub.CompanyListing = class CompanyListing extends erpnext.hub.HubListing
|
|||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
card_html(item) {
|
card_html(company) {
|
||||||
item._name = encodeURI(item.name);
|
company._name = encodeURI(company.name);
|
||||||
const encoded_name = item._name;
|
const route = `#Hub/Company/${company.company_name}`;
|
||||||
const title = strip_html(item['item_name' || 'item_code']);
|
|
||||||
// console.log(item);
|
|
||||||
const company_name = item['company_name'];
|
|
||||||
|
|
||||||
const route = `#Hub/Item/${item.hub_item_code}`;
|
let image_html = company.company_logo ?
|
||||||
|
`<img src="${company.company_logo}"><span class="helper"></span>` :
|
||||||
const image_html = item.image ?
|
`<div class="standard-image">${frappe.get_abbr(company.company_name)}</div>`;
|
||||||
`<img src="${item.image}">
|
|
||||||
<span class="helper"></span>` :
|
|
||||||
`<div class="standard-image">${frappe.get_abbr(title)}</div>`;
|
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<div class="hub-item-wrapper margin-bottom" style="width: 200px;">
|
<div class="hub-item-wrapper margin-bottom" style="width: 200px;">
|
||||||
<a href="${route}">
|
<a href="${route}">
|
||||||
<div class="hub-item-image">
|
<div class="hub-item-image">
|
||||||
<div class="img-wrapper" style="height: 200px; width: 200px">
|
<div class="img-wrapper" style="height: 200px; width: 200px">
|
||||||
${image_html}
|
${ image_html }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hub-item-title">
|
<div class="hub-item-title">
|
||||||
<h5 class="bold">
|
<h5 class="bold">
|
||||||
${ title }
|
${ company.company_name }
|
||||||
</h5>
|
</h5>
|
||||||
<p>${ company_name }</p>
|
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user