diff --git a/erpnext/hub_node/api.py b/erpnext/hub_node/api.py index 86ad031b0c..0c9af1abc1 100644 --- a/erpnext/hub_node/api.py +++ b/erpnext/hub_node/api.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import frappe, requests, json from frappe.utils import now from frappe.frappeclient import FrappeClient +from frappe.desk.form.load import get_attachments @frappe.whitelist() def call_hub_method(method, params=None): @@ -31,11 +32,13 @@ def get_valid_items(search_value=''): valid_items = filter(lambda x: x.image and x.description, items) - def attach_source_type(item): + def prepare_item(item): item.source_type = "local" + item.attachments = get_attachments('Item', item.item_code) return item - valid_items = map(lambda x: attach_source_type(x), valid_items) + valid_items = map(lambda x: prepare_item(x), valid_items) + return valid_items @frappe.whitelist() @@ -52,7 +55,7 @@ def publish_selected_items(items_to_publish): 'doctype': 'Hub Tracked Item', 'item_code': item_code, 'hub_category': item.get('hub_category'), - # 'images': item.get('images') + 'image_list': item.get('image_list') }).insert() try: 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 3f1352099c..0b6b2bc8a8 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 @@ -19,6 +19,7 @@ def pre_process(doc): 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/data_migration_mapping/item_to_hub_item/item_to_hub_item.json b/erpnext/hub_node/data_migration_mapping/item_to_hub_item/item_to_hub_item.json index 3ace088a80..bcece69b38 100644 --- a/erpnext/hub_node/data_migration_mapping/item_to_hub_item/item_to_hub_item.json +++ b/erpnext/hub_node/data_migration_mapping/item_to_hub_item/item_to_hub_item.json @@ -24,10 +24,20 @@ "local_fieldname": "image", "remote_fieldname": "image" }, + { + "is_child_table": 0, + "local_fieldname": "image_list", + "remote_fieldname": "image_list" + }, { "is_child_table": 0, "local_fieldname": "item_group", "remote_fieldname": "item_group" + }, + { + "is_child_table": 0, + "local_fieldname": "hub_category", + "remote_fieldname": "hub_category" } ], "idx": 1, @@ -35,7 +45,7 @@ "mapping_name": "Item to Hub Item", "mapping_type": "Push", "migration_id_field": "hub_sync_id", - "modified": "2018-08-01 16:37:09.170546", + "modified": "2018-08-19 22:20:25.727581", "modified_by": "Administrator", "name": "Item to Hub Item", "owner": "Administrator", diff --git a/erpnext/hub_node/data_migration_plan/hub_sync/hub_sync.json b/erpnext/hub_node/data_migration_plan/hub_sync/hub_sync.json index 1f772b68f0..e90b1dd1e8 100644 --- a/erpnext/hub_node/data_migration_plan/hub_sync/hub_sync.json +++ b/erpnext/hub_node/data_migration_plan/hub_sync/hub_sync.json @@ -9,7 +9,7 @@ "mapping": "Item to Hub Item" } ], - "modified": "2018-08-01 16:37:09.027512", + "modified": "2018-08-19 22:20:25.644602", "modified_by": "Administrator", "module": "Hub Node", "name": "Hub Sync", diff --git a/erpnext/hub_node/doctype/hub_tracked_item/hub_tracked_item.json b/erpnext/hub_node/doctype/hub_tracked_item/hub_tracked_item.json index 7a0bc2a251..9384adbd1d 100644 --- a/erpnext/hub_node/doctype/hub_tracked_item/hub_tracked_item.json +++ b/erpnext/hub_node/doctype/hub_tracked_item/hub_tracked_item.json @@ -84,7 +84,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "images", + "fieldname": "image_list", "fieldtype": "Long Text", "hidden": 0, "ignore_user_permissions": 0, @@ -93,7 +93,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Images", + "label": "Image List", "length": 0, "no_copy": 0, "permlevel": 0, @@ -120,7 +120,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-08-19 19:30:01.449904", + "modified": "2018-08-19 22:24:06.207307", "modified_by": "Administrator", "module": "Hub Node", "name": "Hub Tracked Item", diff --git a/erpnext/public/js/hub/pages/publish.js b/erpnext/public/js/hub/pages/publish.js index 035278bbcd..fcbd0f8b8a 100644 --- a/erpnext/public/js/hub/pages/publish.js +++ b/erpnext/public/js/hub/pages/publish.js @@ -10,6 +10,7 @@ erpnext.hub.Publish = class Publish extends SubPage { this.items_to_publish = {}; this.unpublished_items = []; this.fetched_items = []; + this.fetched_items_dict = {}; this.cache = erpnext.hub.cache.items_to_publish; this.cache = []; @@ -132,6 +133,13 @@ erpnext.hub.Publish = class Publish extends SubPage { "Sports", "Transportation" ], "reqd": 1 + }, + { + "label": "Images", + "fieldname": "image_list", + "fieldtype": "MultiSelect", + "options": [], + "reqd": 1 } ], primary_action_label: __('Set Details'), @@ -154,9 +162,17 @@ erpnext.hub.Publish = class Publish extends SubPage { show_publishing_dialog_for_item(item_code) { let item_data = this.items_to_publish[item_code]; - if(!item_data) { item_data = { item_code }; } + if(!item_data) { item_data = { item_code }; }; this.publishing_dialog.clear(); + + const item_doc = this.fetched_items_dict[item_code]; + if(item_doc) { + this.publishing_dialog.fields_dict.image_list.set_data( + item_doc.attachments.map(attachment => attachment.file_url) + ); + } + this.publishing_dialog.set_values(item_data); this.publishing_dialog.show(); } @@ -268,6 +284,10 @@ erpnext.hub.Publish = class Publish extends SubPage { const items_container = $(get_item_card_container_html(items, '', get_local_item_card_html)); items_container.addClass('results'); wrapper.append(items_container); + + items.map(item => { + this.fetched_items_dict[item.item_code] = item; + }) } get_valid_items() {