[hub] sync multiple image urls
- using a simple multiselect currently
This commit is contained in:
parent
0a60d1cd96
commit
a525d12f69
@ -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:
|
||||
|
@ -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
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user