Merge pull request #6010 from pratu16x7/show_alert

[alerts] add data-actions in show_alert()
This commit is contained in:
Faris Ansari 2018-08-26 11:50:41 +05:30 committed by GitHub
commit 0ad9b4b910
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -265,7 +265,7 @@ frappe.hide_progress = function() {
}
// Floating Message
frappe.show_alert = function(message, seconds=7) {
frappe.show_alert = function(message, seconds=7, actions={}) {
if(typeof message==='string') {
message = {
message: message
@ -306,6 +306,10 @@ frappe.show_alert = function(message, seconds=7) {
return false;
});
Object.keys(actions).map(key => {
div.find(`[data-action=${key}]`).on('click', actions[key]);
});
div.delay(seconds * 1000).fadeOut(300);
return div;
}