[hub] response data in hub call event trigger
This commit is contained in:
parent
e72a2fa9de
commit
71b41b4771
@ -28,12 +28,22 @@ function ItemPublishDialog(primary_action, secondary_action) {
|
|||||||
secondary_action: secondary_action.fn
|
secondary_action: secondary_action.fn
|
||||||
});
|
});
|
||||||
|
|
||||||
const hub_call_key = 'get_categories{}';
|
|
||||||
|
|
||||||
erpnext.hub.on(`response:${hub_call_key}`, () => {
|
function set_hub_category_options(data) {
|
||||||
dialog.fields_dict.hub_category.set_data(
|
dialog.fields_dict.hub_category.set_data(
|
||||||
erpnext.hub.cache[hub_call_key].map(d => d.name)
|
data.map(d => d.name)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const hub_call_key = 'get_categories{}';
|
||||||
|
const categories_cache = erpnext.hub.cache[hub_call_key];
|
||||||
|
|
||||||
|
if(categories_cache) {
|
||||||
|
set_hub_category_options(categories_cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
erpnext.hub.on(`response:${hub_call_key}`, (data) => {
|
||||||
|
set_hub_category_options(data.response);
|
||||||
});
|
});
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
|
@ -24,16 +24,17 @@ hub.call = function call_hub_method(method, args={}, setup_cache_invalidation =
|
|||||||
})
|
})
|
||||||
.then(r => {
|
.then(r => {
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
if (r.message.error) {
|
const response = r.message;
|
||||||
|
if (response.error) {
|
||||||
frappe.throw({
|
frappe.throw({
|
||||||
title: __('Marketplace Error'),
|
title: __('Marketplace Error'),
|
||||||
message: r.message.error
|
message: response.error
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
erpnext.hub.cache[key] = r.message;
|
erpnext.hub.cache[key] = response;
|
||||||
erpnext.hub.trigger(`response:${key}`);
|
erpnext.hub.trigger(`response:${key}`, { response });
|
||||||
resolve(r.message);
|
resolve(response);
|
||||||
}
|
}
|
||||||
reject(r);
|
reject(r);
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user