From 9c502641b5f7bf613eb9dbd4be21fbaf92312267 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Mon, 15 Nov 2010 11:10:55 -0600 Subject: HBAC details page enhancement The HBAC details page has been enhanced to support Undo and Reset operations. The functionality is implemented in the base widget class so the behavior will be more consistent across widgets. A tag now used to define the field boundary in the HTML doc. The tag contains the visual representation of the field which include the input tag and optionally the undo link. The Update method on HBAC details page has been modified so that it executes several operations using a batch command. The operations being executed depends on the changes made to the fields. These operations may include: - removing access time if access time is changed to any time - removing memberships if member category is changed to all - modifying rule attributes if description or rule type is changed - enabling/disabling the rule if rule status is changed The behavior of the Add & Remove buttons also has been changed such that it adjust the category attribute properly in addition to adding the memberships using batch command. For example, if category is initially set to all, adding a new member will also change the category to empty. The ipa_command have been modified to store the on_success and on_error handlers as properties. When the command is executed as a part of batch operation, the result of each command will be passed to the appropriate handler. The unit tests and test data have been updated as well. --- install/static/widget.js | 307 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 213 insertions(+), 94 deletions(-) (limited to 'install/static/widget.js') diff --git a/install/static/widget.js b/install/static/widget.js index 74119550..84b1d9ae 100755 --- a/install/static/widget.js +++ b/install/static/widget.js @@ -32,6 +32,8 @@ function ipa_widget(spec) { that.read_only = spec.read_only; that._entity_name = spec.entity_name; + that.undo = typeof spec.undo == 'undefined' ? true : spec.undo; + that.init = spec.init || init; that.create = spec.create || create; that.setup = spec.setup || setup; @@ -61,6 +63,7 @@ function ipa_widget(spec) { } function setup(container) { + this.container = container; } function load(container, result) { @@ -73,6 +76,41 @@ function ipa_widget(spec) { function clear(container) { } + that.is_dirty = function(container) { + if (!that.values) return true; + var values = that.save(that.container); + if (values.length != that.values.length) return true; + for (var i=0; i', { 'type': 'text', 'name': that.name, 'size': that.size }).appendTo(container); + + if (that.undo) { + $('', { + 'name': 'undo', + 'style': 'display: none;', + 'html': 'undo' + }).appendTo(container); + } + }; + + that.setup = function(container) { + + this.widget_setup(container); + + var input = $('input[name="'+that.name+'"]', that.container); + input.keyup(function() { + that.show_undo(that.container); + }); + + var undo = that.get_undo(that.container); + undo.click(function() { + that.reset(that.container); + }); }; that.load = function(container, result) { - that.value = result[that.name] || ''; - var input = $('input[name="'+that.name+'"]', container); - var param_info = ipa_get_param_info(that.entity_name, that.name); - if (param_info.primary_key) { - input.replaceWith($('