Skip to content

Commit

Permalink
Merge pull request #94 from shridarpatil/button
Browse files Browse the repository at this point in the history
fix: removed multiple declaration of refresh
  • Loading branch information
shridarpatil authored Aug 19, 2024
2 parents 0f56a42 + 6fd212b commit 5991a5a
Showing 1 changed file with 21 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ frappe.notification = {
frm.set_df_property("date_changed", "options", get_date_change_options());

});
},
setup_alerts_button: function (frm) {
// body...
frm.add_custom_button(__('Get Alerts for Today'), function () {
frappe.call({
method: 'frappe_whatsapp.frappe_whatsapp.doctype.whatsapp_notification.whatsapp_notification.call_trigger_notifications',
args: {
method: 'daily'
},
callback: function (response) {
if (response.message && response.message.length > 0) {
} else {
frappe.msgprint(__('No alerts for today'));
}
},
error: function (error) {
frappe.msgprint(__('Failed to trigger notifications'));
}
});
});
}
};

Expand All @@ -51,6 +71,7 @@ frappe.ui.form.on('WhatsApp Notification', {
refresh: function(frm) {
frm.trigger("load_template")
frappe.notification.setup_fieldname_select(frm);
frappe.notification.setup_alerts_button(frm);
},
template: function(frm){
frm.trigger("load_template")
Expand Down Expand Up @@ -107,32 +128,3 @@ frappe.ui.form.on('WhatsApp Notification', {
frappe.notification.setup_fieldname_select(frm);
},
});



frappe.ui.form.on('WhatsApp Notification', {
refresh: function (frm) {
frm.add_custom_button(__('Get Alerts for Today'), function () {
frappe.call({
method: 'frappe_whatsapp.frappe_whatsapp.doctype.whatsapp_notification.whatsapp_notification.call_trigger_notifications',
args: {
method: 'daily'
},
callback: function (response) {
if (response.message && response.message.length > 0) {
} else {
frappe.msgprint(__('No alerts for today'));
}
},
error: function (error) {
frappe.msgprint(__('Failed to trigger notifications'));
}
});
});
}
});





0 comments on commit 5991a5a

Please sign in to comment.