From e72a2fa9dea215aa3249719879ad6ab8ed4d6207 Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Mon, 20 Aug 2018 14:18:07 +0530 Subject: [PATCH] [hub] emit hub call event to set category options while publishing --- .../js/hub/components/item_publish_dialog.js | 15 ++++++++++----- erpnext/public/js/hub/hub_call.js | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/erpnext/public/js/hub/components/item_publish_dialog.js b/erpnext/public/js/hub/components/item_publish_dialog.js index f751be0145..2c215799a4 100644 --- a/erpnext/public/js/hub/components/item_publish_dialog.js +++ b/erpnext/public/js/hub/components/item_publish_dialog.js @@ -12,11 +12,7 @@ function ItemPublishDialog(primary_action, secondary_action) { "label": "Hub Category", "fieldname": "hub_category", "fieldtype": "Autocomplete", - "options": ["Agriculture", "Books", "Chemicals", "Clothing", - "Electrical", "Electronics", "Energy", "Fashion", "Food and Beverage", - "Health", "Home", "Industrial", "Machinery", "Packaging and Printing", - "Sports", "Transportation" - ], + "options": [], "reqd": 1 }, { @@ -31,6 +27,15 @@ function ItemPublishDialog(primary_action, secondary_action) { primary_action: primary_action.fn, secondary_action: secondary_action.fn }); + + const hub_call_key = 'get_categories{}'; + + erpnext.hub.on(`response:${hub_call_key}`, () => { + dialog.fields_dict.hub_category.set_data( + erpnext.hub.cache[hub_call_key].map(d => d.name) + ); + }); + return dialog; } diff --git a/erpnext/public/js/hub/hub_call.js b/erpnext/public/js/hub/hub_call.js index d2eaab31b4..2ed19f2739 100644 --- a/erpnext/public/js/hub/hub_call.js +++ b/erpnext/public/js/hub/hub_call.js @@ -32,6 +32,7 @@ hub.call = function call_hub_method(method, args={}, setup_cache_invalidation = } erpnext.hub.cache[key] = r.message; + erpnext.hub.trigger(`response:${key}`); resolve(r.message); } reject(r);