mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Update of confirmation of actions
This patch is changing confirmation of actions according to ticket #3035, see the ticket description. It does following changes: * Confirmation of update action was removed. * Action lists resets to first action (which is usually a NOP: '-- select action --') on change of displayed entry. * New confirmation dialog was implemented. It is used for action confirmation. It is used in IPA.action to replace the call of window.confirm(message). The old call is a modal window which blocks all JS functionality and has different style than other dialogs in Web UI. The new one has same design and doesn't block background operations. https://fedorahosted.org/freeipa/ticket/3035
This commit is contained in:
@@ -918,7 +918,7 @@ IPA.update_action = function(spec) {
|
||||
spec = spec || {};
|
||||
spec.name = spec.name || 'update';
|
||||
spec.label = spec.label || IPA.messages.buttons.update;
|
||||
spec.needs_confirm = spec.needs_confirm !== undefined ? spec.needs_confirm : true;
|
||||
spec.needs_confirm = spec.needs_confirm !== undefined ? spec.needs_confirm : false;
|
||||
spec.enable_cond = spec.enable_cond || ['dirty'];
|
||||
|
||||
var that = IPA.action(spec);
|
||||
@@ -1120,8 +1120,6 @@ IPA.object_action = function(spec) {
|
||||
var entity_name = facet.entity.name;
|
||||
var pkey = IPA.nav.get_state(entity_name+'-pkey');
|
||||
|
||||
if (that.needs_confirm && !that.confirm_object(pkey)) return;
|
||||
|
||||
IPA.command({
|
||||
entity: entity_name,
|
||||
method: that.method,
|
||||
@@ -1155,9 +1153,10 @@ IPA.object_action = function(spec) {
|
||||
};
|
||||
};
|
||||
|
||||
that.confirm_object = function(obj_name) {
|
||||
var msg = that.confirm_msg.replace('${object}', obj_name);
|
||||
return IPA.confirm(msg);
|
||||
that.get_confirm_message = function(facet) {
|
||||
var pkey = IPA.nav.get_state(facet.entity.name+'-pkey');
|
||||
var msg = that.confirm_msg.replace('${object}', pkey);
|
||||
return msg;
|
||||
};
|
||||
|
||||
that.object_execute_action = that.execute_action;
|
||||
|
||||
@@ -671,7 +671,7 @@ IPA.message_dialog = function(spec) {
|
||||
label: IPA.messages.buttons.ok,
|
||||
click: function() {
|
||||
that.close();
|
||||
if(that.on_ok) {
|
||||
if (that.on_ok) {
|
||||
that.on_ok();
|
||||
}
|
||||
}
|
||||
@@ -681,3 +681,79 @@ IPA.message_dialog = function(spec) {
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
IPA.confirm_dialog = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
spec.message = spec.message || IPA.messages.actions.confirm;
|
||||
spec.title = spec.title || IPA.messages.dialogs.confirmation;
|
||||
|
||||
var that = IPA.message_dialog(spec);
|
||||
that.on_cancel = spec.on_cancel;
|
||||
that.ok_label = spec.ok_label || IPA.messages.buttons.ok;
|
||||
that.cancel_label = spec.cancel_label || IPA.messages.buttons.cancel;
|
||||
that.confirmed = false;
|
||||
that.confirm_on_enter = spec.confirm_on_enter !== undefined ? spec.confirm_on_enter : true;
|
||||
|
||||
that.close = function() {
|
||||
|
||||
that.dialog_close();
|
||||
$(document).unbind('keyup', that.on_key_up);
|
||||
|
||||
if (that.confirmed) {
|
||||
if (that.on_ok) {
|
||||
that.on_ok();
|
||||
}
|
||||
} else {
|
||||
if (that.on_cancel) {
|
||||
that.on_cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
that.open = function(container) {
|
||||
|
||||
that.confirmed = false;
|
||||
that.dialog_open(container);
|
||||
$(document).bind('keyup', that.on_key_up);
|
||||
};
|
||||
|
||||
that.on_key_up = function(event) {
|
||||
|
||||
if (event.keyCode === $.ui.keyCode.ENTER) {
|
||||
event.preventDefault();
|
||||
that.confirmed = true;
|
||||
that.close();
|
||||
}
|
||||
};
|
||||
|
||||
that.create_buttons = function() {
|
||||
|
||||
that.buttons.empty();
|
||||
|
||||
that.create_button({
|
||||
name: 'ok',
|
||||
label: that.ok_label,
|
||||
click: function() {
|
||||
that.confirmed = true;
|
||||
that.close();
|
||||
}
|
||||
});
|
||||
|
||||
that.create_button({
|
||||
name: 'cancel',
|
||||
label: that.cancel_label,
|
||||
click: function() {
|
||||
that.confirmed = false;
|
||||
that.close();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
that.create_buttons();
|
||||
|
||||
that.confirm_dialog_close = that.close;
|
||||
that.confirm_dialog_open = that.open;
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
@@ -655,6 +655,7 @@ IPA.facet_header = function(spec) {
|
||||
|
||||
that.clear = function() {
|
||||
that.load();
|
||||
if (that.action_list) that.action_list.clear();
|
||||
};
|
||||
|
||||
return that;
|
||||
@@ -1300,6 +1301,10 @@ IPA.action = function(spec) {
|
||||
that.needs_confirm = spec.needs_confirm !== undefined ? spec.needs_confirm : false;
|
||||
that.confirm_msg = spec.confirm_msg || IPA.messages.actions.confirm;
|
||||
|
||||
that.confirm_dialog = spec.confirm_dialog !== undefined ? spec.confirm_dialog :
|
||||
IPA.confirm_dialog;
|
||||
|
||||
|
||||
|
||||
that.execute_action = function(facet, on_success, on_error) {
|
||||
|
||||
@@ -1319,9 +1324,13 @@ IPA.action = function(spec) {
|
||||
if (that.confirm_dialog) {
|
||||
|
||||
var dialog = IPA.build(that.confirm_dialog);
|
||||
confirmed = dialog.confirm(that.facet);
|
||||
dialog.message = that.get_confirm_message(facet);
|
||||
dialog.on_ok = function () {
|
||||
that.execute_action(facet, on_success, on_error);
|
||||
};
|
||||
dialog.open();
|
||||
} else {
|
||||
var msg = that.get_confirm_message();
|
||||
var msg = that.get_confirm_message(facet);
|
||||
confirmed = IPA.confirm(msg);
|
||||
}
|
||||
|
||||
@@ -1331,7 +1340,7 @@ IPA.action = function(spec) {
|
||||
that.execute_action(facet, on_success, on_error);
|
||||
};
|
||||
|
||||
that.get_confirm_message = function() {
|
||||
that.get_confirm_message = function(facet) {
|
||||
return that.confirm_msg;
|
||||
};
|
||||
|
||||
@@ -2022,5 +2031,10 @@ IPA.action_list_widget = function(spec) {
|
||||
that.action_select.update([first]);
|
||||
};
|
||||
|
||||
that.clear = function() {
|
||||
|
||||
that.select_first_enabled();
|
||||
};
|
||||
|
||||
return that;
|
||||
};
|
||||
@@ -473,6 +473,7 @@ IPA.batch_disable_action = function(spec) {
|
||||
spec.needs_confirm = spec.needs_confirm === undefined ? true : spec.needs_confirm;
|
||||
spec.enable_cond = spec.enable_cond || ['item-selected'];
|
||||
spec.success_msg = spec.success_msg || IPA.messages.search.disabled;
|
||||
spec.confirm_msg = spec.confirm_msg || IPA.messages.search.disable_confirm;
|
||||
|
||||
return IPA.batch_items_action(spec);
|
||||
};
|
||||
@@ -486,6 +487,7 @@ IPA.batch_enable_action = function(spec) {
|
||||
spec.needs_confirm = spec.needs_confirm === undefined ? true : spec.needs_confirm;
|
||||
spec.enable_cond = spec.enable_cond || ['item-selected'];
|
||||
spec.success_msg = spec.success_msg || IPA.messages.search.enabled;
|
||||
spec.confirm_msg = spec.confirm_msg || IPA.messages.search.enable_confirm;
|
||||
|
||||
return IPA.batch_items_action(spec);
|
||||
};
|
||||
@@ -487,7 +487,9 @@
|
||||
"search": {
|
||||
"delete_confirm": "Are you sure you want to delete selected entries?",
|
||||
"deleted": "Selected entries were deleted.",
|
||||
"disable_confirm": "Are you sure you want to disable selected entries?",
|
||||
"disabled": "${count} items were disabled",
|
||||
"enable_confirm": "Are you sure you want to enable selected entries?",
|
||||
"enabled": "${count} items were enabled",
|
||||
"partial_delete": "Some entries were not deleted",
|
||||
"quick_links": "Quick Links",
|
||||
|
||||
@@ -626,7 +626,9 @@ class i18n_messages(Command):
|
||||
"search": {
|
||||
"delete_confirm": _("Are you sure you want to delete selected entries?"),
|
||||
"deleted": _("Selected entries were deleted."),
|
||||
"disable_confirm": _("Are you sure you want to disable selected entries?"),
|
||||
"disabled": _("${count} items were disabled"),
|
||||
"enable_confirm": _("Are you sure you want to enable selected entries?"),
|
||||
"enabled": _("${count} items were enabled"),
|
||||
"partial_delete": _("Some entries were not deleted"),
|
||||
"quick_links": _("Quick Links"),
|
||||
|
||||
Reference in New Issue
Block a user