diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2012-09-03 16:43:13 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2012-09-06 17:36:29 +0200 |
commit | 835c7859c5c31807b9f46cf79462459238571f5e (patch) | |
tree | f6c338cc023d95bb80057de46b71fbddedfcd561 | |
parent | a01fbb91e88918ead456ae85e886e975f29dc1be (diff) | |
download | freeipa-835c7859c5c31807b9f46cf79462459238571f5e.tar.gz freeipa-835c7859c5c31807b9f46cf79462459238571f5e.tar.xz freeipa-835c7859c5c31807b9f46cf79462459238571f5e.zip |
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
-rw-r--r-- | install/ui/details.js | 11 | ||||
-rw-r--r-- | install/ui/dialog.js | 78 | ||||
-rw-r--r-- | install/ui/facet.js | 20 | ||||
-rw-r--r-- | install/ui/search.js | 2 | ||||
-rw-r--r-- | install/ui/test/data/ipa_init.json | 2 | ||||
-rw-r--r-- | ipalib/plugins/internal.py | 2 |
6 files changed, 105 insertions, 10 deletions
diff --git a/install/ui/details.js b/install/ui/details.js index f038daa67..c3e84e434 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -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; diff --git a/install/ui/dialog.js b/install/ui/dialog.js index 878218419..e3d3395f9 100644 --- a/install/ui/dialog.js +++ b/install/ui/dialog.js @@ -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; +}; diff --git a/install/ui/facet.js b/install/ui/facet.js index 0de08d3f7..372022dbe 100644 --- a/install/ui/facet.js +++ b/install/ui/facet.js @@ -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; };
\ No newline at end of file diff --git a/install/ui/search.js b/install/ui/search.js index 154d7ffaf..7c4939bbb 100644 --- a/install/ui/search.js +++ b/install/ui/search.js @@ -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); };
\ No newline at end of file diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json index 24364dafa..d4f2fa4a7 100644 --- a/install/ui/test/data/ipa_init.json +++ b/install/ui/test/data/ipa_init.json @@ -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", diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py index f449da4f4..98a5ceeb5 100644 --- a/ipalib/plugins/internal.py +++ b/ipalib/plugins/internal.py @@ -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"), |