From 25d5a1d89006df7d760ccc72640c62be646ab0d6 Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Wed, 14 Feb 2018 19:53:18 +0530 Subject: [PATCH 1/5] add company pages --- erpnext/hub_node/__init__.py | 25 +++++--- erpnext/patches.txt | 4 +- erpnext/public/js/hub/hub_factory.js | 19 ++---- erpnext/public/js/hub/hub_form.js | 89 +++++++++++++++++++++++----- erpnext/public/js/hub/hub_page.js | 58 +++++++++++------- 5 files changed, 135 insertions(+), 60 deletions(-) diff --git a/erpnext/hub_node/__init__.py b/erpnext/hub_node/__init__.py index ea1693d377..df365528c3 100644 --- a/erpnext/hub_node/__init__.py +++ b/erpnext/hub_node/__init__.py @@ -34,22 +34,29 @@ def get_meta(doctype): def get_categories(): # get categories info with parent category and stuff 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 [ + # {'value': 'Men', 'expandable': 1}, + # {'value': 'Women', 'expandable': 0} + # ] + @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: return connection = get_client_connection() - item_details = connection.get_doc('Hub Item', hub_sync_id) - print(item_details) - return item_details + details = connection.get_doc(doctype, hub_sync_id) + return details -@frappe.whitelist() -def get_company_details(hub_sync_id): - connection = get_client_connection() - return connection.get_doc('Hub Company', hub_sync_id) +# @frappe.whitelist() +# def get_company_details(hub_sync_id): +# connection = get_client_connection() +# return connection.get_doc('Hub Company', hub_sync_id) def get_client_connection(): # frappeclient connection diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 69d8a4752c..45a5b1145a 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -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.add_guardian_role_for_parent_portal 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.update_assessment_plan 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.update_sales_order_link_to_purchase_order 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 diff --git a/erpnext/public/js/hub/hub_factory.js b/erpnext/public/js/hub/hub_factory.js index 6789b80b84..0318c99874 100644 --- a/erpnext/public/js/hub/hub_factory.js +++ b/erpnext/public/js/hub/hub_factory.js @@ -17,26 +17,19 @@ frappe.views.HubFactory = frappe.views.Factory.extend({ }; if (!erpnext.hub.pages[page_name]) { - if (page === 'Item' && !route[2]) { + if (!route[2]) { + // page === 'Item' && 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', parent: this.make_page(true, page_name) }); window.hub_page = erpnext.hub.pages[page_name]; }); - } if (page === 'Company' && !route[2]) { - 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]) { + } else { frappe.require(assets['Form'], () => { - erpnext.hub.pages[page_name] = new erpnext.hub.HubForm({ - hub_item_code: route[2], + erpnext.hub.pages[page_name] = new erpnext.hub[page+'Page']({ + unique_id: route[2], doctype: 'Hub Settings', parent: this.make_page(true, page_name) }); diff --git a/erpnext/public/js/hub/hub_form.js b/erpnext/public/js/hub/hub_form.js index 208af417ab..eb7c6b4fb0 100644 --- a/erpnext/public/js/hub/hub_form.js +++ b/erpnext/public/js/hub/hub_form.js @@ -3,22 +3,23 @@ frappe.provide('erpnext.hub'); erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList { setup_defaults() { super.setup_defaults(); - this.page_title = this.data.item_name || this.hub_item_code || __('Hub Item'); - this.method = 'erpnext.hub_node.get_item_details'; - } - - setup_fields() { - this.fields = ['hub_item_code', 'item_name', 'item_code', 'description', 'seller', 'company_name', 'country']; + this.method = 'erpnext.hub_node.get_details'; + //doctype, unique_id, } set_breadcrumbs() { + this.set_title(); frappe.breadcrumbs.add({ label: __('Hub'), - route: '#Hub/Item', + route: '#Hub/' + this.doctype, type: 'Custom' }); } + set_title() { + this.page_title = this.data.item_name || this.hub_item_code || 'Hub' + this.doctype; + } + setup_side_bar() { this.sidebar = new frappe.ui.Sidebar({ 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() { 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() { + const image_html = this.data[this.image_field_name] ? + ` + ` : + `
${frappe.get_abbr(this.page_title)}
`; + this.sidebar.add_item({ - label: `` + label: image_html }); let fields = []; @@ -73,7 +76,7 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList { } 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.$no_result.toggle(this.data.length == 0); @@ -82,3 +85,57 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList { .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']; + } +} diff --git a/erpnext/public/js/hub/hub_page.js b/erpnext/public/js/hub/hub_page.js index 6e5ab985f2..2ca5eacbbc 100644 --- a/erpnext/public/js/hub/hub_page.js +++ b/erpnext/public/js/hub/hub_page.js @@ -13,21 +13,26 @@ erpnext.hub.HubListing = class HubListing extends frappe.views.BaseList { setup_fields() { return this.get_meta() .then(r => { - console.log('fields then', this.doctype); + // console.log('fields then', this.doctype); this.meta = r.message || this.meta; frappe.model.sync(this.meta); }); } get_meta() { - console.log('get_meta', this.doctype); + // console.log('get_meta', this.doctype); return new Promise(resolve => frappe.call('erpnext.hub_node.get_meta', {doctype: this.doctype}, resolve)); } 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() { } @@ -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() { let filters = {}; this.filter_area.get().forEach(f => { @@ -139,7 +164,7 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing {
- ${image_html} + ${ image_html }
@@ -158,7 +183,7 @@ erpnext.hub.CompanyListing = class CompanyListing extends erpnext.hub.HubListing setup_defaults() { super.setup_defaults(); 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.custom_filter_configs = [ { @@ -186,33 +211,26 @@ erpnext.hub.CompanyListing = class CompanyListing extends erpnext.hub.HubListing return filters; } - card_html(item) { - item._name = encodeURI(item.name); - const encoded_name = item._name; - const title = strip_html(item['item_name' || 'item_code']); - // console.log(item); - const company_name = item['company_name']; + card_html(company) { + company._name = encodeURI(company.name); + const route = `#Hub/Company/${company.company_name}`; - const route = `#Hub/Item/${item.hub_item_code}`; - - const image_html = item.image ? - ` - ` : - `
${frappe.get_abbr(title)}
`; + let image_html = company.company_logo ? + `` : + `
${frappe.get_abbr(company.company_name)}
`; return `
From 6ee035ba5bf3518f9ae30c7af5bf1ed15c74d09c Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Thu, 15 Feb 2018 08:50:31 +0530 Subject: [PATCH 2/5] tree parent working --- erpnext/hub_node/__init__.py | 8 ++++---- erpnext/public/js/hub/hub_page.js | 8 +------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/erpnext/hub_node/__init__.py b/erpnext/hub_node/__init__.py index df365528c3..01f71c9a1e 100644 --- a/erpnext/hub_node/__init__.py +++ b/erpnext/hub_node/__init__.py @@ -31,12 +31,12 @@ def get_meta(doctype): return meta @frappe.whitelist() -def get_categories(): +def get_categories(parent='All Categories'): # get categories info with parent category and stuff connection = get_client_connection() - categories = connection.get_list('Hub Category') - print("============================================================") - print(categories) + categories = connection.get_list('Hub Category', filters={'parent_hub_category': parent}) + # print("============================================================") + # print(categories) response = [{'value': c.get('name'), 'expandable': c.get('is_group')} for c in categories] return response diff --git a/erpnext/public/js/hub/hub_page.js b/erpnext/public/js/hub/hub_page.js index 2ca5eacbbc..beea480a48 100644 --- a/erpnext/public/js/hub/hub_page.js +++ b/erpnext/public/js/hub/hub_page.js @@ -120,7 +120,7 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing { label: 'All Categories', expandable: true, - args: {}, + args: {parent: this.current_category}, method: 'erpnext.hub_node.get_categories', on_click: (node) => { this.update_category(node.label); @@ -186,12 +186,6 @@ erpnext.hub.CompanyListing = class CompanyListing extends erpnext.hub.HubListing this.fields = ['company_logo', 'name', 'site_name', 'seller_city', 'seller_description', 'seller', 'country', 'company_name']; this.filters = []; this.custom_filter_configs = [ - { - fieldtype: 'Data', - label: 'Company', - condition: 'like', - fieldname: 'company_name', - }, { fieldtype: 'Link', label: 'Country', From 2073959bb8eeb65a7ca1e3d040d8cba6b992be7b Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Thu, 15 Feb 2018 10:17:07 +0530 Subject: [PATCH 3/5] Update entity properties --- erpnext/hub_node/__init__.py | 19 +++-- erpnext/patches.txt | 4 +- erpnext/public/js/hub/hub_factory.js | 45 ++++++------ erpnext/public/js/hub/hub_form.js | 102 +++++++++++++++------------ erpnext/public/js/hub/hub_page.js | 18 ++++- 5 files changed, 109 insertions(+), 79 deletions(-) diff --git a/erpnext/hub_node/__init__.py b/erpnext/hub_node/__init__.py index 01f71c9a1e..b2a98b4968 100644 --- a/erpnext/hub_node/__init__.py +++ b/erpnext/hub_node/__init__.py @@ -35,15 +35,17 @@ def get_categories(parent='All Categories'): # get categories info with parent category and stuff connection = get_client_connection() categories = connection.get_list('Hub Category', filters={'parent_hub_category': parent}) - # print("============================================================") - # print(categories) + response = [{'value': c.get('name'), 'expandable': c.get('is_group')} for c in categories] return response - # return [ - # {'value': 'Men', 'expandable': 1}, - # {'value': 'Women', 'expandable': 0} - # ] +@frappe.whitelist() +def update_category(item_name, category): + connection = get_hub_connection() + response = connection.update('Hub Item', dict( + hub_category = category + ), item_name) + return response.ok @frappe.whitelist() def get_details(hub_sync_id=None, doctype='Hub Item'): @@ -53,11 +55,6 @@ def get_details(hub_sync_id=None, doctype='Hub Item'): details = connection.get_doc(doctype, hub_sync_id) return details -# @frappe.whitelist() -# def get_company_details(hub_sync_id): -# connection = get_client_connection() -# return connection.get_doc('Hub Company', hub_sync_id) - def get_client_connection(): # frappeclient connection hub_connection = get_hub_connection() diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 45a5b1145a..69d8a4752c 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -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.add_guardian_role_for_parent_portal 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.update_assessment_plan 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.update_sales_order_link_to_purchase_order 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 diff --git a/erpnext/public/js/hub/hub_factory.js b/erpnext/public/js/hub/hub_factory.js index 0318c99874..1578e4dc7f 100644 --- a/erpnext/public/js/hub/hub_factory.js +++ b/erpnext/public/js/hub/hub_factory.js @@ -15,30 +15,33 @@ frappe.views.HubFactory = frappe.views.Factory.extend({ '/assets/erpnext/css/hub.css', ] }; + frappe.model.with_doc('Hub Settings', 'Hub Settings', () => { + this.hub_settings = frappe.get_doc('Hub Settings'); - if (!erpnext.hub.pages[page_name]) { - if (!route[2]) { - // page === 'Item' && - frappe.require(assets['List'], () => { - erpnext.hub.pages[page_name] = new erpnext.hub[page+'Listing']({ - doctype: 'Hub Settings', - parent: this.make_page(true, page_name) + if (!erpnext.hub.pages[page_name]) { + if (!route[2]) { + frappe.require(assets['List'], () => { + erpnext.hub.pages[page_name] = new erpnext.hub[page+'Listing']({ + parent: this.make_page(true, page_name), + hub_settings: this.hub_settings + }); + window.hub_page = erpnext.hub.pages[page_name]; }); - window.hub_page = erpnext.hub.pages[page_name]; - }); + } else { + 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 + }); + window.hub_page = erpnext.hub.pages[page_name]; + }); + } } else { - frappe.require(assets['Form'], () => { - erpnext.hub.pages[page_name] = new erpnext.hub[page+'Page']({ - unique_id: route[2], - doctype: 'Hub Settings', - parent: this.make_page(true, page_name) - }); - window.hub_page = erpnext.hub.pages[page_name]; - }); + frappe.container.change_to(page_name); + window.hub_page = erpnext.hub.pages[page_name]; } - } else { - frappe.container.change_to(page_name); - window.hub_page = erpnext.hub.pages[page_name]; - } + }); } }); diff --git a/erpnext/public/js/hub/hub_form.js b/erpnext/public/js/hub/hub_form.js index eb7c6b4fb0..fe39793f15 100644 --- a/erpnext/public/js/hub/hub_form.js +++ b/erpnext/public/js/hub/hub_form.js @@ -4,11 +4,11 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList { setup_defaults() { super.setup_defaults(); this.method = 'erpnext.hub_node.get_details'; - //doctype, unique_id, + const route = frappe.get_route(); + this.page_name = route[2]; } set_breadcrumbs() { - this.set_title(); frappe.breadcrumbs.add({ label: __('Hub'), route: '#Hub/' + this.doctype, @@ -16,10 +16,6 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList { }); } - set_title() { - this.page_title = this.data.item_name || this.hub_item_code || 'Hub' + this.doctype; - } - setup_side_bar() { this.sidebar = new frappe.ui.Sidebar({ wrapper: this.$page.find('.layout-side-section'), @@ -56,15 +52,7 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList { label: image_html }); - let fields = []; - this.fields.map(fieldname => { - fields.push({ - label: toTitle(frappe.model.unscrub(fieldname)), - fieldname, - fieldtype: 'Data', - read_only: 1 - }); - }); + let fields = this.get_field_configs(); this.form = new frappe.ui.FieldGroup({ parent: this.$result, @@ -93,39 +81,51 @@ erpnext.hub.ItemPage = class ItemPage extends erpnext.hub.HubForm{ this.image_field_name = 'image'; } - setup_fields() { - this.fields = ['hub_item_code', 'item_name', 'item_code', 'description', - 'seller', 'company_name', 'country', 'hub_category']; + get_field_configs() { + let fields = []; + this.fields.map(fieldname => { + fields.push({ + label: toTitle(frappe.model.unscrub(fieldname)), + fieldname, + fieldtype: 'Data', + read_only: 1 + }); + }); + + let category_field = { + label: 'Hub Category', + fieldname: 'hub_category', + fieldtype: 'Data' + } + + if(this.data.company_name === this.hub_settings.company) { + this.page.set_primary_action(__('Update'), () => { + this.update_on_hub(); + }, 'octicon octicon-plus'); + } else { + category_field.read_only = 1; + } + + fields.push(category_field); + + return fields; } - 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(); + update_on_hub() { + return new Promise((resolve, reject) => { + frappe.call({ + method: 'erpnext.hub_node.update_category', + args: { item: this.unique_id, category: this.form.get_value('hub_category') }, + callback: resolve, + freeze: true + }).fail(reject); }); } + + setup_fields() { + this.fields = ['hub_item_code', 'item_name', 'item_code', 'description', + 'seller', 'company_name', 'country']; + } } erpnext.hub.CompanyPage = class CompanyPage extends erpnext.hub.HubForm{ @@ -135,6 +135,20 @@ erpnext.hub.CompanyPage = class CompanyPage extends erpnext.hub.HubForm{ this.image_field_name = 'company_logo'; } + get_field_configs() { + let fields = []; + this.fields.map(fieldname => { + fields.push({ + label: toTitle(frappe.model.unscrub(fieldname)), + fieldname, + fieldtype: 'Data', + read_only: 1 + }); + }); + + return fields; + } + setup_fields() { this.fields = ['company_name', 'description', 'route', 'country', 'seller', 'site_name']; } diff --git a/erpnext/public/js/hub/hub_page.js b/erpnext/public/js/hub/hub_page.js index beea480a48..f333feedb1 100644 --- a/erpnext/public/js/hub/hub_page.js +++ b/erpnext/public/js/hub/hub_page.js @@ -126,6 +126,21 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing { this.update_category(node.label); } }); + + this.sidebar.add_item({ + label: this.hub_settings.company, + on_click: () => frappe.set_route('Form', 'Company', this.hub_settings.company) + }, __("Account")); + + this.sidebar.add_item({ + label: __('Companies'), + on_click: () => frappe.set_route('Hub', 'Company') + }); + + this.sidebar.add_item({ + label: __("My Orders"), + on_click: () => frappe.set_route('List', 'Request for Quotation') + }, __("Account")); } update_category(label) { @@ -171,9 +186,10 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing {
${ title }
-

${ company_name }

+
+

${ company_name }

`; } From 1ad072f2a9e5ad415475c258341364e7cd7184bf Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Thu, 15 Feb 2018 10:47:59 +0530 Subject: [PATCH 4/5] [hub] cleanups --- erpnext/public/js/hub/hub_form.js | 2 +- erpnext/public/js/hub/hub_page.js | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/erpnext/public/js/hub/hub_form.js b/erpnext/public/js/hub/hub_form.js index fe39793f15..130a0db45c 100644 --- a/erpnext/public/js/hub/hub_form.js +++ b/erpnext/public/js/hub/hub_form.js @@ -106,7 +106,7 @@ erpnext.hub.ItemPage = class ItemPage extends erpnext.hub.HubForm{ category_field.read_only = 1; } - fields.push(category_field); + fields.unshift(category_field); return fields; } diff --git a/erpnext/public/js/hub/hub_page.js b/erpnext/public/js/hub/hub_page.js index f333feedb1..46e5ce4493 100644 --- a/erpnext/public/js/hub/hub_page.js +++ b/erpnext/public/js/hub/hub_page.js @@ -13,14 +13,12 @@ erpnext.hub.HubListing = class HubListing extends frappe.views.BaseList { setup_fields() { return this.get_meta() .then(r => { - // console.log('fields then', this.doctype); this.meta = r.message || this.meta; frappe.model.sync(this.meta); }); } get_meta() { - // console.log('get_meta', this.doctype); return new Promise(resolve => frappe.call('erpnext.hub_node.get_meta', {doctype: this.doctype}, resolve)); } @@ -51,7 +49,6 @@ erpnext.hub.HubListing = class HubListing extends frappe.views.BaseList { update_data(r) { const data = r.message; - console.log('update data', data); if (this.start === 0) { this.data = data; @@ -79,7 +76,6 @@ erpnext.hub.HubListing = class HubListing extends frappe.views.BaseList { render_image_view() { let data = this.data; - // console.log('this.data render', this.data); if (this.start === 0) { this.$result.html('
'); data = this.data.slice(this.start); @@ -164,7 +160,6 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing { item._name = encodeURI(item.name); const encoded_name = item._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}`; From 988989960364077e244b1ed069993d3651dd4f09 Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Thu, 15 Feb 2018 10:54:23 +0530 Subject: [PATCH 5/5] [hub] cleanups --- erpnext/public/js/hub/hub_page.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/public/js/hub/hub_page.js b/erpnext/public/js/hub/hub_page.js index 46e5ce4493..27986de563 100644 --- a/erpnext/public/js/hub/hub_page.js +++ b/erpnext/public/js/hub/hub_page.js @@ -123,16 +123,16 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing { } }); - this.sidebar.add_item({ - label: this.hub_settings.company, - on_click: () => frappe.set_route('Form', 'Company', this.hub_settings.company) - }, __("Account")); - this.sidebar.add_item({ label: __('Companies'), on_click: () => frappe.set_route('Hub', 'Company') }); + this.sidebar.add_item({ + label: this.hub_settings.company, + on_click: () => frappe.set_route('Form', 'Company', this.hub_settings.company) + }, __("Account")); + this.sidebar.add_item({ label: __("My Orders"), on_click: () => frappe.set_route('List', 'Request for Quotation')