[IMP] web,web_kanban: Dialog.confirm api

takes now an object of options for the Dialog, containing two possible
callbacks (for confirm and cancel).
This commit is contained in:
Aaron Bohy
2015-07-01 11:36:31 +02:00
parent c128ddf827
commit 3a511aaa70
2 changed files with 11 additions and 7 deletions
+10 -6
View File
@@ -147,24 +147,28 @@ var Dialog = Widget.extend({
// static method to open simple confirm dialog
Dialog.confirm = function (owner, message, confirm_callback) {
Dialog.confirm = function (owner, message, options) {
var buttons = [
{
text: _t("Ok"),
classes: 'btn-primary',
close: true,
click: confirm_callback
click: options && options.confirm_callback
},
{text: _t("Cancel"), close: true}
{
text: _t("Cancel"),
close: true,
click: options && options.cancel_callback
}
];
return new Dialog(owner, {
return new Dialog(owner, _.extend({
size: 'medium',
buttons: buttons,
$content: $('<div>', {
text: message,
}),
}).open();
}
}, options)).open();
};
return Dialog;
@@ -448,7 +448,7 @@ var KanbanView = View.extend({
});
}
if (this.options.confirm_on_delete) {
Dialog.confirm(this, _t("Are you sure you want to delete this record ?"), do_it);
Dialog.confirm(this, _t("Are you sure you want to delete this record ?"), { confirm_callback: do_it });
} else {
do_it();
}