diff --git a/erpnext/hub_node/__init__.py b/erpnext/hub_node/__init__.py index 31f30f86c36..93129d9f43d 100644 --- a/erpnext/hub_node/__init__.py +++ b/erpnext/hub_node/__init__.py @@ -15,7 +15,7 @@ def enable_hub(): return hub_settings @frappe.whitelist() -def get_items(start=0, limit=20, category=None, order_by=None, company=None, text=None): +def get_items(start=0, limit=20, fields=["*"], category=None, order_by=None, company=None, text=None): connection = get_client_connection() filters = {} @@ -29,9 +29,23 @@ def get_items(start=0, limit=20, category=None, order_by=None, company=None, tex response = connection.get_list('Hub Item', limit_start=start, limit_page_length=limit, - filters=filters) + filters=filters, fields=fields) return response +# + +@frappe.whitelist() +def get_hub_item_meta(): + connection = get_client_connection() + meta = connection.get_doc('DocType', 'Hub Item') + return meta + +@frappe.whitelist() +def get_hub_company_meta(): + connection = get_client_connection() + meta = connection.get_doc('DocType', 'Hub Company') + return meta + @frappe.whitelist() def get_categories(): connection = get_client_connection() @@ -43,7 +57,10 @@ def get_item_details(hub_sync_id=None): if not hub_sync_id: return connection = get_client_connection() - return connection.get_doc('Hub Item', hub_sync_id) + item_details = connection.get_doc('Hub Item', hub_sync_id) + print("============details=============") + print(item_details) + return item_details @frappe.whitelist() def get_company_details(hub_sync_id): diff --git a/erpnext/hub_node/doctype/hub_category/__init__.py b/erpnext/hub_node/doctype/hub_category/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/erpnext/hub_node/doctype/hub_category/hub_category.js b/erpnext/hub_node/doctype/hub_category/hub_category.js deleted file mode 100644 index 9f54166e143..00000000000 --- a/erpnext/hub_node/doctype/hub_category/hub_category.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors -// For license information, please see license.txt - -frappe.ui.form.on('Hub Category', { - refresh: function(frm) { - - } -}); diff --git a/erpnext/hub_node/doctype/hub_category/hub_category.json b/erpnext/hub_node/doctype/hub_category/hub_category.json deleted file mode 100644 index 4f8d66ace03..00000000000 --- a/erpnext/hub_node/doctype/hub_category/hub_category.json +++ /dev/null @@ -1,275 +0,0 @@ -{ - "allow_copy": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, - "autoname": "field:hub_category_name", - "beta": 0, - "creation": "2017-08-22 11:31:10.410322", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, - "engine": "InnoDB", - "fields": [ - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "hub_category_name", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Category Name", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "parent_hub_category", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Parent Category", - "length": 0, - "no_copy": 0, - "options": "Hub Category", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "is_group", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Is Group", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "description", - "fieldtype": "Text Editor", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Description", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "lft", - "fieldtype": "Int", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Left", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "rgt", - "fieldtype": "Int", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Right", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "old_parent", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Old Parent", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2017-09-03 22:04:22.958831", - "modified_by": "Administrator", - "module": "Hub Node", - "name": "Hub Category", - "name_case": "", - "owner": "Administrator", - "permissions": [ - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, - "write": 1 - } - ], - "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, - "sort_field": "modified", - "sort_order": "DESC", - "title_field": "hub_category_name", - "track_changes": 1, - "track_seen": 0 -} \ No newline at end of file diff --git a/erpnext/hub_node/doctype/hub_category/hub_category.py b/erpnext/hub_node/doctype/hub_category/hub_category.py deleted file mode 100644 index 5d19082324f..00000000000 --- a/erpnext/hub_node/doctype/hub_category/hub_category.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors -# For license information, please see license.txt - -from __future__ import unicode_literals -import frappe -from frappe.utils.nestedset import NestedSet -from frappe.model.document import Document - -class HubCategory(NestedSet): - pass diff --git a/erpnext/hub_node/doctype/hub_category/hub_category_tree.js b/erpnext/hub_node/doctype/hub_category/hub_category_tree.js deleted file mode 100644 index d0309e3d983..00000000000 --- a/erpnext/hub_node/doctype/hub_category/hub_category_tree.js +++ /dev/null @@ -1,4 +0,0 @@ -frappe.treeview_settings["Hub Category"] = { - title: __("Hub Category"), - breadcrumb: "Hub" -} \ No newline at end of file diff --git a/erpnext/hub_node/doctype/hub_category/test_hub_category.js b/erpnext/hub_node/doctype/hub_category/test_hub_category.js deleted file mode 100644 index 73c06d5a92a..00000000000 --- a/erpnext/hub_node/doctype/hub_category/test_hub_category.js +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable */ -// rename this file from _test_[name] to test_[name] to activate -// and remove above this line - -QUnit.test("test: Hub Category", function (assert) { - let done = assert.async(); - - // number of asserts - assert.expect(1); - - frappe.run_serially([ - // insert a new Hub Category - () => frappe.tests.make('Hub Category', [ - // values to be set - {key: 'value'} - ]), - () => { - assert.equal(cur_frm.doc.key, 'value'); - }, - () => done() - ]); - -}); diff --git a/erpnext/hub_node/doctype/hub_category/test_hub_category.py b/erpnext/hub_node/doctype/hub_category/test_hub_category.py deleted file mode 100644 index 7df20889a72..00000000000 --- a/erpnext/hub_node/doctype/hub_category/test_hub_category.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors -# See license.txt -from __future__ import unicode_literals - -import frappe -import unittest - -class TestHubCategory(unittest.TestCase): - pass diff --git a/erpnext/hub_node/page/hub/hub.js b/erpnext/hub_node/page/hub/hub.js index 15bd97ddee4..6926191a90a 100644 --- a/erpnext/hub_node/page/hub/hub.js +++ b/erpnext/hub_node/page/hub/hub.js @@ -9,7 +9,7 @@ frappe.pages['hub'].on_page_load = function(wrapper) { single_col: false }); - wrapper.hub_page = new erpnext.hub.Hub({ page }); + // wrapper.hub_page = new erpnext.hub.Hub({ page }); }; frappe.pages['hub'].on_page_show = function(wrapper) { @@ -776,7 +776,7 @@ erpnext.hub.HubList = class HubList { limit: this.page_length + 1 }; Object.assign(args, this.filters); - console.log("filters: ", args); + // console.log("filters: ", args); args.order_by = this.order_by; args.by_item_codes = this.by_item_codes; @@ -785,7 +785,7 @@ erpnext.hub.HubList = class HubList { args: args, callback: (r) => { let items = r.message; - console.log("items: ", items); + // console.log("items: ", items); this.render_items(items); } }); @@ -796,7 +796,6 @@ erpnext.hub.HubList = class HubList { // clear any filler divs this.$list.find('.filler').remove(); let done = 0; - console.log("items length", items.length); if(items.length && items.length > this.page_length) { // remove the extra queried items.pop(); diff --git a/erpnext/public/css/hub.css b/erpnext/public/css/hub.css index 559c2039793..5f86cf4869b 100644 --- a/erpnext/public/css/hub.css +++ b/erpnext/public/css/hub.css @@ -1,3 +1,29 @@ +body[data-route^="Hub/"] .freeze .image-view-container .list-row-col { + background-color: #fafbfc; + color: #fafbfc; +} +body[data-route^="Hub/"] .freeze .image-view-container .placeholder-text { + color: #fafbfc; +} +body[data-route^="Hub/"] .freeze { + display: none; +} +body[data-route^="Hub/"] .image-view-container { + justify-content: space-around; +} +.img-wrapper { + border: 1px solid #d1d8dd; + border-radius: 3px; + padding: 12px; + overflow: hidden; + text-align: center; + white-space: nowrap; +} +.img-wrapper .helper { + height: 100%; + display: inline-block; + vertical-align: middle; +} /* hub */ div[data-page-route="hub"] .page-head { height: 80px; diff --git a/erpnext/public/css/pos.css b/erpnext/public/css/pos.css index e2d301df0da..bc81182f32c 100644 --- a/erpnext/public/css/pos.css +++ b/erpnext/public/css/pos.css @@ -169,8 +169,5 @@ input[type=number]::-webkit-outer-spin-button { height: 60px; } .grand-total .grand-total-value { - font-size: 18px; -} -.rounded-total-value { - font-size: 18px; + font-size: 24px; } diff --git a/erpnext/public/js/hub/hub_factory.js b/erpnext/public/js/hub/hub_factory.js index f260fcc1bb4..a341c228392 100644 --- a/erpnext/public/js/hub/hub_factory.js +++ b/erpnext/public/js/hub/hub_factory.js @@ -5,9 +5,22 @@ frappe.views.HubFactory = frappe.views.Factory.extend({ const page_name = frappe.get_route_str(); const page = route[1]; + 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?"); + if (!erpnext.hub.pages[page_name]) { + console.log("pages?"); if (page === 'Item' && !route[2]) { - frappe.require('/assets/erpnext/js/hub/hub_page.js', () => { + frappe.require(assets['List'], () => { erpnext.hub.pages[page_name] = new erpnext.hub.HubPage({ doctype: 'Hub Settings', parent: this.make_page(true, page_name) @@ -15,7 +28,8 @@ frappe.views.HubFactory = frappe.views.Factory.extend({ window.hub_page = erpnext.hub.pages[page_name]; }); } else if(route[2]) { - frappe.require('/assets/erpnext/js/hub/hub_form.js', () => { + console.log("form?"); + frappe.require(assets['Form'], () => { erpnext.hub.pages[page_name] = new erpnext.hub.HubForm({ hub_item_code: route[2], doctype: 'Hub Settings', @@ -25,6 +39,7 @@ frappe.views.HubFactory = frappe.views.Factory.extend({ }); } } else { + console.log("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 0a8b5b02fb7..208af417ab8 100644 --- a/erpnext/public/js/hub/hub_form.js +++ b/erpnext/public/js/hub/hub_form.js @@ -8,7 +8,7 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList { } setup_fields() { - + this.fields = ['hub_item_code', 'item_name', 'item_code', 'description', 'seller', 'company_name', 'country']; } set_breadcrumbs() { @@ -40,9 +40,12 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList { }; } + prepare_data(r) { + this.data = r.message; + } + update_data(r) { - const data = r.message; - this.data = data; + this.data = r.message; } render() { @@ -51,13 +54,14 @@ erpnext.hub.HubForm = class HubForm extends frappe.views.BaseList { }); let fields = []; - for (let fieldname in this.data) { + this.fields.map(fieldname => { fields.push({ - label: toTitle(fieldname), + label: toTitle(frappe.model.unscrub(fieldname)), fieldname, - fieldtype: 'Data' + fieldtype: 'Data', + read_only: 1 }); - } + }); this.form = new frappe.ui.FieldGroup({ parent: this.$result, diff --git a/erpnext/public/js/hub/hub_page.js b/erpnext/public/js/hub/hub_page.js index 8ecd28ba119..9b6c4f4f475 100644 --- a/erpnext/public/js/hub/hub_page.js +++ b/erpnext/public/js/hub/hub_page.js @@ -8,10 +8,22 @@ erpnext.hub.HubPage = class HubPage extends frappe.views.BaseList { const route = frappe.get_route(); this.page_name = route[1]; + + return this.get_hub_item_meta() + .then(r => { + this.meta = r.message || this.meta; + this.doctype = 'Hub Item'; + frappe.model.sync(this.meta); + }); + } + + get_hub_item_meta() { + return new Promise(resolve => + frappe.call('erpnext.hub_node.get_hub_item_meta', {}, resolve)); } setup_fields() { - + this.fields = ['name', 'hub_item_code', 'image', 'item_name', 'item_code']; } set_breadcrumbs() { @@ -23,13 +35,32 @@ erpnext.hub.HubPage = class HubPage extends frappe.views.BaseList { } setup_filter_area() { - + this.custom_filter_configs = [ + { + fieldtype: 'Data', + label: 'Company', + condition: 'like', + fieldname: 'company_name', + }, + { + fieldtype: 'Link', + label: 'Country', + options: 'Country', + condition: 'like', + fieldname: 'country' + } + ]; + this.filter_area = new FilterArea(this); } setup_sort_selector() { } + setup_view() { + + } + get_args() { return { start: this.start, @@ -37,18 +68,33 @@ erpnext.hub.HubPage = class HubPage extends frappe.views.BaseList { category: this.category || '', order_by: this.order_by, company: this.company || '', - text: this.search_text || '' + text: this.search_text || '', + fields: this.fields }; } update_data(r) { const data = r.message; + console.log('update data', data); if (this.start === 0) { this.data = data; } else { this.data = this.data.concat(data); } + + } + + freeze(toggle) { + this.$freeze.toggle(toggle); + if (this.$freeze.find('.image-view-container').length) return; + + const html = Array.from(new Array(4)).map(d => this.card_html({ + name: 'freeze', + item_name: 'freeze' + })).join(''); + + this.$freeze.html(`