[hub] emit hub call event to set category options while publishing

This commit is contained in:
Prateeksha Singh 2018-08-20 14:18:07 +05:30
parent 6faffa5007
commit e72a2fa9de
2 changed files with 11 additions and 5 deletions

View File

@ -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;
}

View File

@ -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);