[hub] emit hub call event to set category options while publishing
diff --git a/erpnext/public/js/hub/components/item_publish_dialog.js b/erpnext/public/js/hub/components/item_publish_dialog.js
index f751be0..2c21579 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 @@
"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 @@
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 d2eaab3..2ed19f2 100644
--- a/erpnext/public/js/hub/hub_call.js
+++ b/erpnext/public/js/hub/hub_call.js
@@ -32,6 +32,7 @@
}
erpnext.hub.cache[key] = r.message;
+ erpnext.hub.trigger(`response:${key}`);
resolve(r.message);
}
reject(r);