Merge branch 'hub-redesign' of https://github.com/frappe/erpnext into hub-redesign
diff --git a/erpnext/hub_node/api.py b/erpnext/hub_node/api.py
index 8b186af..c46e6dc 100644
--- a/erpnext/hub_node/api.py
+++ b/erpnext/hub_node/api.py
@@ -1,6 +1,5 @@
from __future__ import unicode_literals
-import frappe, requests, json
-from frappe.utils import now
+import frappe, json
from frappe.frappeclient import FrappeClient
from frappe.desk.form.load import get_attachments
from six import string_types
@@ -62,7 +61,7 @@
item.attachments = get_attachments('Item', item.item_code)
return item
- valid_items = map(lambda x: prepare_item(x), valid_items)
+ valid_items = map(prepare_item, valid_items)
return valid_items
@@ -99,7 +98,7 @@
'stats': len(items)
})
except Exception as e:
- frappe.log_error(title='Hub Sync Error')
+ frappe.log_error(message=e, title='Hub Sync Error')
def item_sync_preprocess():
hub_seller = frappe.db.get_value("Hub Settings", "Hub Settings", "company_email")
diff --git a/erpnext/hub_node/data_migration_mapping/item_to_hub_item/__init__.py b/erpnext/hub_node/data_migration_mapping/item_to_hub_item/__init__.py
index eb57f3a..e69de29 100644
--- a/erpnext/hub_node/data_migration_mapping/item_to_hub_item/__init__.py
+++ b/erpnext/hub_node/data_migration_mapping/item_to_hub_item/__init__.py
@@ -1,32 +0,0 @@
-import frappe, io, base64, urllib, os, json
-from frappe.utils.file_manager import get_file_path
-
-def pre_process(doc):
-
- file_path = doc.image
- file_name = os.path.basename(file_path)
-
- if file_path.startswith('http'):
- url = file_path
- file_path = os.path.join('/tmp', file_name)
- urllib.urlretrieve(url, file_path)
- else:
- file_path = os.path.abspath(get_file_path(file_path))
-
- try:
- with io.open(file_path, 'rb') as f:
- doc.image = json.dumps({
- 'file_name': file_name,
- 'base64': base64.b64encode(f.read())
- })
- except Exception as e:
- frappe.log_error(title='Hub Sync Error')
-
- cached_details = frappe.get_doc('Hub Tracked Item', doc.item_code)
-
- if cached_details:
- doc.hub_category = cached_details.hub_category
- doc.image_list = cached_details.image_list
-
- return doc
-
diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.js b/erpnext/hub_node/doctype/hub_settings/hub_settings.js
index 4bd3333..ddd86b8 100644
--- a/erpnext/hub_node/doctype/hub_settings/hub_settings.js
+++ b/erpnext/hub_node/doctype/hub_settings/hub_settings.js
@@ -1,23 +1,12 @@
frappe.ui.form.on("Hub Settings", {
refresh: function(frm) {
frm.disable_save();
- frm.add_custom_button(__('Logs'),
- () => frappe.set_route('List', 'Data Migration Run', {
- data_migration_plan: 'Hub Sync'
- }));
-
- if (frm.doc.enabled) {
- frm.add_custom_button(__('Sync'),
- () => frm.call('sync'));
- }
},
- onload: function(frm) { },
+
onload_post_render: function(frm) {
if(frm.get_field("unregister_from_hub").$input)
frm.get_field("unregister_from_hub").$input.addClass("btn-danger");
},
- on_update: function(frm) {
- },
hub_user_email: function(frm) {
if(frm.doc.hub_user_email){
diff --git a/erpnext/hub_node/legacy.py b/erpnext/hub_node/legacy.py
index 06d20f3..7218d3f 100644
--- a/erpnext/hub_node/legacy.py
+++ b/erpnext/hub_node/legacy.py
@@ -1,6 +1,6 @@
from __future__ import unicode_literals
-import frappe, requests, json
-from frappe.utils import now, nowdate
+import frappe, json
+from frappe.utils import nowdate
from frappe.frappeclient import FrappeClient
from frappe.utils.nestedset import get_root_of
from frappe.contacts.doctype.contact.contact import get_default_contact
@@ -18,56 +18,6 @@
hub_connection = FrappeClient(frappe.conf.hub_url)
return hub_connection
-@frappe.whitelist()
-def get_item_favourites(start=0, limit=20, fields=["*"], order_by=None):
- doctype = 'Hub Item'
- hub_settings = frappe.get_doc('Hub Settings')
- item_names_str = hub_settings.get('custom_data') or '[]'
- item_names = json.loads(item_names_str)
- filters = json.dumps({
- 'hub_item_code': ['in', item_names]
- })
- return get_list(doctype, start, limit, fields, filters, order_by)
-
-@frappe.whitelist()
-def update_wishlist_item(item_name, remove=0):
- remove = int(remove)
- hub_settings = frappe.get_doc('Hub Settings')
- data = hub_settings.get('custom_data')
- if not data or not json.loads(data):
- data = '[]'
- hub_settings.custom_data = data
- hub_settings.save()
-
- item_names_str = data
- item_names = json.loads(item_names_str)
- if not remove and item_name not in item_names:
- item_names.append(item_name)
- if remove and item_name in item_names:
- item_names.remove(item_name)
-
- item_names_str = json.dumps(item_names)
-
- hub_settings.custom_data = item_names_str
- hub_settings.save()
-
-@frappe.whitelist()
-def update_category(hub_item_code, category):
- connection = get_hub_connection()
-
- # args = frappe._dict(dict(
- # doctype='Hub Category',
- # hub_category_name=category
- # ))
- # response = connection.insert('Hub Category', args)
-
- response = connection.update('Hub Item', frappe._dict(dict(
- doctype='Hub Item',
- hub_category = category
- )), hub_item_code)
-
- return response
-
def make_opportunity(buyer_name, email_id):
buyer_name = "HUB-" + buyer_name
diff --git a/erpnext/public/js/hub/components/EmptyState.vue b/erpnext/public/js/hub/components/EmptyState.vue
index 527194b..d6216c9 100644
--- a/erpnext/public/js/hub/components/EmptyState.vue
+++ b/erpnext/public/js/hub/components/EmptyState.vue
@@ -42,6 +42,9 @@
border-radius: 4px;
border: 1px solid @border-color;
border-style: dashed;
+
+ // bad, due to item card column layout, that is inner 15px margin
+ margin: 0 15px;
}
</style>
diff --git a/erpnext/public/js/hub/hub_call.js b/erpnext/public/js/hub/hub_call.js
index e461564..a8bfa2e 100644
--- a/erpnext/public/js/hub/hub_call.js
+++ b/erpnext/public/js/hub/hub_call.js
@@ -2,7 +2,7 @@
frappe.provide('erpnext.hub');
erpnext.hub.cache = {};
-hub.call = function call_hub_method(method, args={}, clear_cache_on_event) {
+hub.call = function call_hub_method(method, args={}, clear_cache_on_event) { // eslint-disable-line
return new Promise((resolve, reject) => {
// cache
@@ -18,7 +18,7 @@
invalidate_after_5_mins(clear_cache);
} else {
erpnext.hub.on(clear_cache_on_event, () => {
- clear_cache(key)
+ clear_cache(key);
});
}
@@ -28,8 +28,7 @@
method,
params: args
}
- })
- .then(r => {
+ }).then(r => {
if (r.message) {
const response = r.message;
if (response.error) {
@@ -44,10 +43,10 @@
resolve(response);
}
reject(r);
- })
- .fail(reject)
+
+ }).fail(reject);
});
-}
+};
function invalidate_after_5_mins(clear_cache) {
// cache invalidation after 5 minutes
diff --git a/erpnext/public/js/hub/hub_factory.js b/erpnext/public/js/hub/hub_factory.js
index f933600..57f27f9 100644
--- a/erpnext/public/js/hub/hub_factory.js
+++ b/erpnext/public/js/hub/hub_factory.js
@@ -21,12 +21,12 @@
});
});
}
-}
+};
$(document).on('toolbar_setup', () => {
$('#toolbar-user .navbar-reload').after(`
<li>
<a href="#marketplace/home">${__('Marketplace')}
</li>
- `)
-})
+ `);
+});
diff --git a/erpnext/public/less/hub.less b/erpnext/public/less/hub.less
index 27321e5..d40926b 100644
--- a/erpnext/public/less/hub.less
+++ b/erpnext/public/less/hub.less
@@ -3,6 +3,7 @@
body[data-route^="marketplace/"] {
.layout-side-section {
padding-top: 25px;
+ padding-left: 5px;
padding-right: 25px;
}