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 <span> 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.
This commit is contained in:
Endi S. Dewata
2010-11-15 11:10:55 -06:00
committed by Endi Sukma Dewata
parent 629e9520e0
commit 9c502641b5
22 changed files with 1362 additions and 712 deletions

View File

@@ -244,7 +244,6 @@ function ipa_association_widget(spec) {
that.other_entity = spec.other_entity;
that.superior_create = that.superior('create');
that.superior_setup = that.superior('setup');
that.create = function(container) {
@@ -258,25 +257,42 @@ function ipa_association_widget(spec) {
that.superior_create(container);
var div = $('#'+that.id, container);
var buttons = $('<span />').appendTo($('.action-panel')); //TODO replace with ipa_button
var ul = $('.action-panel ul');
var li = $('<li/>').appendTo(ul);
// creating generic buttons for layout
$('<input/>', {
'type': 'button',
'name': 'remove',
'value': IPA.messages.button.remove
}).appendTo(buttons);
}).appendTo(li);
$('<input/>', {
'type': 'button',
'name': 'add',
'value': IPA.messages.button.enroll
}).appendTo(buttons);
}).appendTo(li);
};
that.setup = function(container) {
that.superior_setup(container);
that.table_setup(container);
// replacing generic buttons with ipa_button and setting click handler
var action_panel = $('.action-panel');
var button = $('input[name=remove]', action_panel);
button.replaceWith(ipa_button({
'label': button.val(),
'icon': 'ui-icon-trash',
'click': function() { that.remove(that.container); }
}));
button = $('input[name=add]', action_panel);
button.replaceWith(ipa_button({
'label': button.val(),
'icon': 'ui-icon-plus',
'click': function() { that.add(that.container) }
}));
var entity = IPA.get_entity(that.entity_name);
var association = entity.get_association(that.other_entity);
@@ -308,18 +324,18 @@ function ipa_association_widget(spec) {
'associator': that.associator,
'method': that.add_method,
'on_success': function() {
that.refresh(container);
that.refresh(that.container);
dialog.close();
},
'on_error': function() {
that.refresh(container);
that.refresh(that.container);
dialog.close();
}
});
dialog.init();
dialog.open(container);
dialog.open(that.container);
};
that.remove = function(container) {
@@ -344,18 +360,18 @@ function ipa_association_widget(spec) {
'associator': that.associator,
'method': that.delete_method,
'on_success': function() {
that.refresh(container);
that.refresh(that.container);
dialog.close();
},
'on_error': function() {
that.refresh(container);
that.refresh(that.container);
dialog.close();
}
});
dialog.init();
dialog.open(container);
dialog.open(that.container);
};
that.refresh = function(container) {
@@ -374,15 +390,15 @@ function ipa_association_widget(spec) {
for (var i = 0; i<values.length; i++){
var record = that.get_record(data.result.result, i);
that.add_row(container, record);
that.add_row(that.container, record);
}
}
function on_error(xhr, text_status, error_thrown) {
var div = $('#'+that.id, container).empty();
div.append('<p>Error: '+error_thrown.name+'</p>');
div.append('<p>'+error_thrown.title+'</p>');
div.append('<p>'+error_thrown.message+'</p>');
var summary = $('span[name=summary]', that.tfoot).empty();
summary.append('<p>Error: '+error_thrown.name+'</p>');
summary.append('<p>'+error_thrown.title+'</p>');
summary.append('<p>'+error_thrown.message+'</p>');
}
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
@@ -407,10 +423,21 @@ function ipa_association_facet(spec) {
};
that.create = function(container) {
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
that.other_entity =
$.bbq.getState(that.entity_name + '-enroll', true) || '';
var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
that.table = ipa_association_widget({
'id': that.entity_name+'-'+that.other_entity,
'name': 'association',
'label': label,
'entity_name': that.entity_name,
'other_entity': that.other_entity
});
//TODO I18N
var header_message = that.other_entity + '(s) enrolled in ' +
that.entity_name + ' ' + that.pkey;
@@ -427,13 +454,17 @@ function ipa_association_facet(spec) {
'other_entity': that.other_entity
});
that.table.create(container);
var span = $('<span/>', { 'name': 'association' }).appendTo(container);
that.table.create(span);
};
that.setup = function(container, unspecified) {
that.table.setup(container);
that.table.refresh(container);
that.setup = function(container) {
var span = $('span[name=association]', container);
that.table.setup(span);
that.table.refresh();
};
return that;