summaryrefslogtreecommitdiffstats
path: root/install/static/associate.js
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2010-12-01 14:51:39 -0600
committerAdam Young <ayoung@redhat.com>2010-12-02 12:14:07 -0500
commitc0eb2b60c85dd686c96693e1a512986ba5b4306e (patch)
treea43a9cd445c0f14f6b30f7048fc93b5420dcebea /install/static/associate.js
parent620c085ebf96ba93a83c249e874060d669edbf28 (diff)
downloadfreeipa-c0eb2b60c85dd686c96693e1a512986ba5b4306e.tar.gz
freeipa-c0eb2b60c85dd686c96693e1a512986ba5b4306e.tar.xz
freeipa-c0eb2b60c85dd686c96693e1a512986ba5b4306e.zip
Multicolumn enrollment dialog
The enrollment dialog has been modified to use scrollable tables that supports multiple columns to display the search results and selected entries. The columns are specified by calling create_adder_column() on the association facet. By default the tables will use only one column which is to display the primary keys. The following enrollment dialogs have been modified to use multiple columns: - Group's member_user - Service's managedby_host - HBAC Service Group's member_hbacsvc - SUDO Command Group's member_sudocmd The ipa_association_table_widget's add() and remove() have been moved into ipa_association_facet so they can be customized by facet's subclass. The ipa_table's add_row() has been renamed to add_record(). Some old code has been removed from ipa_facet_create_action_panel(). The code was used to generate association links from a single facet. It's no longer needed because now each association has its own facet. The test data has been updated. The IPA.nested_tabs() has been fixed to return the entity itself if IPA.tab_set is not defined. This is needed to pass unit test.
Diffstat (limited to 'install/static/associate.js')
-rw-r--r--install/static/associate.js235
1 files changed, 135 insertions, 100 deletions
diff --git a/install/static/associate.js b/install/static/associate.js
index fbd1c63c9..a6edf748f 100644
--- a/install/static/associate.js
+++ b/install/static/associate.js
@@ -152,9 +152,13 @@ function ipa_association_adder_dialog(spec) {
var pkey_name = IPA.metadata[that.other_entity].primary_key;
that.create_column({
name: pkey_name,
- primary_key: true
+ label: IPA.metadata[that.other_entity].label,
+ primary_key: true,
+ width: '200px'
});
}
+
+ that.adder_dialog_init();
};
that.search = function() {
@@ -170,7 +174,7 @@ function ipa_association_adder_dialog(spec) {
}
var filter = that.get_filter();
- ipa_cmd('find', [filter], {}, on_success, null, that.other_entity);
+ ipa_cmd('find', [filter], {'all': true}, on_success, null, that.other_entity);
};
that.add = function() {
@@ -252,13 +256,11 @@ function ipa_association_table_widget(spec) {
that.facet = spec.facet;
that.other_entity = spec.other_entity;
- that.superior_create = that.superior('create');
+ that.add = spec.add;
+ that.remove = spec.remove;
that.create = function(container) {
- that.member_attribute = ipa_get_member_attribute(
- that.entity_name, that.other_entity);
-
if (!that.columns.length) {
var pkey_name = IPA.metadata[that.other_entity].primary_key;
@@ -290,7 +292,7 @@ function ipa_association_table_widget(spec) {
};
}
- that.superior_create(container);
+ that.table_create(container);
var action_panel = that.facet.get_action_panel();
var li = $('.action-controls', action_panel);
@@ -320,94 +322,15 @@ function ipa_association_table_widget(spec) {
button.replaceWith(ipa_button({
'label': button.val(),
'icon': 'ui-icon-trash',
- 'click': function() { that.remove(that.container); }
+ 'click': function() { that.remove(); }
}));
button = $('input[name=add]', action_panel);
button.replaceWith(ipa_button({
'label': button.val(),
'icon': 'ui-icon-plus',
- 'click': function() { that.add(that.container) }
+ 'click': function() { that.add() }
}));
-
- var entity = IPA.get_entity(that.entity_name);
- var association = entity.get_association(that.other_entity);
-
- if (association && association.associator == 'serial') {
- that.associator = serial_associator;
- } else {
- that.associator = bulk_associator;
- }
-
- that.add_method = association ? association.add_method : null;
- that.delete_method = association ? association.delete_method : null;
-
- that.add_method = that.add_method || "add_member";
- that.delete_method = that.delete_method || "remove_member";
- };
-
- that.add = function(container) {
-
- var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
- var label = IPA.metadata[that.other_entity].label;
- var title = 'Enroll '+that.entity_name+' '+pkey+' in '+label;
-
- var dialog = ipa_association_adder_dialog({
- 'title': title,
- 'entity_name': that.entity_name,
- 'pkey': pkey,
- 'other_entity': that.other_entity,
- 'associator': that.associator,
- 'method': that.add_method,
- 'on_success': function() {
- that.refresh();
- dialog.close();
- },
- 'on_error': function() {
- that.refresh();
- dialog.close();
- }
- });
-
- dialog.init();
-
- dialog.open(that.container);
- };
-
- that.remove = function(container) {
-
- var values = that.get_selected_values();
-
- if (!values.length) {
- alert('Select '+that.label+' to be removed.');
- return;
- }
-
- var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
- var label = IPA.metadata[that.other_entity].label;
- var title = 'Remove '+label+' from '+that.entity_name+' '+pkey;
-
- var dialog = ipa_association_deleter_dialog({
- 'title': title,
- 'entity_name': that.entity_name,
- 'pkey': pkey,
- 'other_entity': that.other_entity,
- 'values': values,
- 'associator': that.associator,
- 'method': that.delete_method,
- 'on_success': function() {
- that.refresh();
- dialog.close();
- },
- 'on_error': function() {
- that.refresh();
- dialog.close();
- }
- });
-
- dialog.init();
-
- dialog.open(that.container);
};
that.get_records = function(pkeys, on_success, on_error) {
@@ -443,13 +366,14 @@ function ipa_association_table_widget(spec) {
that.tbody.empty();
var pkeys = data.result.result[that.name];
+ if (!pkeys) return;
if (that.columns.length == 1) { // show pkey only
var name = that.columns[0].name;
for (var i=0; i<pkeys.length; i++) {
var record = {};
record[name] = pkeys[i];
- that.add_row(record);
+ that.add_record(record);
}
} else { // get and show additional fields
@@ -459,7 +383,7 @@ function ipa_association_table_widget(spec) {
var results = data.result.results;
for (var i=0; i<results.length; i++) {
var record = results[i].result;
- that.add_row(record);
+ that.add_record(record);
}
}
);
@@ -488,9 +412,16 @@ function ipa_association_facet(spec) {
that.other_entity = spec.other_entity;
+ that.associator = spec.associator || bulk_associator;
+ that.add_method = spec.add_method || 'add_member';
+ that.delete_method = spec.delete_method || 'remove_member';
+
that.columns = [];
that.columns_by_name = {};
+ that.adder_columns = [];
+ that.adder_columns_by_name = {};
+
that.get_column = function(name) {
return that.columns_by_name[name];
};
@@ -507,25 +438,42 @@ function ipa_association_facet(spec) {
return column;
};
+ that.get_adder_column = function(name) {
+ return that.adder_columns_by_name[name];
+ };
+
+ that.add_adder_column = function(column) {
+ column.entity_name = that.entity_name;
+ that.adder_columns.push(column);
+ that.adder_columns_by_name[column.name] = column;
+ };
+
+ that.create_adder_column = function(spec) {
+ var column = ipa_column(spec);
+ that.add_adder_column(column);
+ return column;
+ };
+
that.is_dirty = function() {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
return pkey != that.pkey || other_entity != that.other_entity;
};
- that.create = function(container) {
+ that.init = function() {
- that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+ var entity = IPA.get_entity(that.entity_name);
+ var association = entity.get_association(that.other_entity);
- var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
+ if (association) {
+ if (association.associator) {
+ that.associator = association.associator == 'serial' ? serial_associator : bulk_associator;
+ }
- //TODO I18N
- var header_message = that.other_entity + '(s) enrolled in ' +
- that.entity_name + ' ' + that.pkey;
+ if (association.add_method) that.add_method = association.add_method;
+ if (association.delete_method) that.delete_method = association.delete_method;
+ }
- $('<div/>', {
- 'id': that.entity_name+'-'+that.other_entity,
- html: $('<h2/>',{ html: header_message })
- }).appendTo(container);
+ var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
that.table = ipa_association_table_widget({
'id': that.entity_name+'-'+that.other_entity,
@@ -540,6 +488,25 @@ function ipa_association_facet(spec) {
that.table.set_columns(that.columns);
}
+ that.table.add = function() { that.add(); };
+ that.table.remove = function() { that.remove() };
+
+ that.facet_init();
+ };
+
+ that.create = function(container) {
+
+ that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+
+ //TODO I18N
+ var header_message = that.other_entity + '(s) enrolled in ' +
+ that.entity_name + ' ' + that.pkey;
+
+ $('<div/>', {
+ 'id': that.entity_name+'-'+that.other_entity,
+ html: $('<h2/>',{ html: header_message })
+ }).appendTo(container);
+
var span = $('<span/>', { 'name': 'association' }).appendTo(container);
that.table.create(span);
@@ -554,6 +521,74 @@ function ipa_association_facet(spec) {
that.table.setup(span);
};
+ that.add = function() {
+
+ var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+ var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
+ var title = 'Enroll '+that.entity_name+' '+pkey+' in '+label;
+
+ var dialog = ipa_association_adder_dialog({
+ 'title': title,
+ 'entity_name': that.entity_name,
+ 'pkey': pkey,
+ 'other_entity': that.other_entity,
+ 'associator': that.associator,
+ 'method': that.add_method,
+ 'on_success': function() {
+ that.refresh();
+ dialog.close();
+ },
+ 'on_error': function() {
+ that.refresh();
+ dialog.close();
+ }
+ });
+
+ if (that.adder_columns.length) {
+ dialog.set_columns(that.adder_columns);
+ }
+
+ dialog.init();
+
+ dialog.open(that.container);
+ };
+
+ that.remove = function() {
+
+ var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
+ var values = that.table.get_selected_values();
+
+ if (!values.length) {
+ alert('Select '+label+' to be removed.');
+ return;
+ }
+
+ var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+ var title = 'Remove '+label+' from '+that.entity_name+' '+pkey;
+
+ var dialog = ipa_association_deleter_dialog({
+ 'title': title,
+ 'entity_name': that.entity_name,
+ 'pkey': pkey,
+ 'other_entity': that.other_entity,
+ 'values': values,
+ 'associator': that.associator,
+ 'method': that.delete_method,
+ 'on_success': function() {
+ that.refresh();
+ dialog.close();
+ },
+ 'on_error': function() {
+ that.refresh();
+ dialog.close();
+ }
+ });
+
+ dialog.init();
+
+ dialog.open(that.container);
+ };
+
that.refresh = function(){
that.table.refresh();
};