From ef4210e6c4d93c2d2b6eebec89e030d26d9aa39c Mon Sep 17 00:00:00 2001 From: Endi S. Dewata Date: Wed, 1 Dec 2010 14:51:39 -0600 Subject: [PATCH] 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. --- install/static/associate.js | 245 ++++++++++++++++------------ install/static/entity.js | 22 +-- install/static/group.js | 13 ++ install/static/hbac.js | 2 +- install/static/hbacsvcgroup.js | 22 +++- install/static/ipa.css | 2 +- install/static/rule.js | 2 +- install/static/search.js | 2 +- install/static/service.js | 13 ++ install/static/sudocmdgroup.js | 22 +++- install/static/test/data/hbacsvc_find.json | 29 +++- install/static/widget.js | 208 ++++++++++++++++-------- 12 files changed, 388 insertions(+), 194 deletions(-) diff --git a/install/static/associate.js b/install/static/associate.js index fbd1c63c98bbff0186e9cb17de3148514fb1a02e..a6edf748f7dc9b54292f7b8b469ce624e0ad5f8e 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',{ html: header_message }) }).appendTo(container); - that.table = ipa_association_table_widget({ - 'id': that.entity_name+'-'+that.other_entity, - 'name': that.name, - 'label': label, - 'entity_name': that.entity_name, - 'other_entity': that.other_entity, - 'facet': that - }); - - if (that.columns.length) { - that.table.set_columns(that.columns); - } - var 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(); }; diff --git a/install/static/entity.js b/install/static/entity.js index 9b62ce375f58909b27aba7910ce49bdf16f38443..6e2b501b0989b4549123888bef0fcc69a7b23b0d 100644 --- a/install/static/entity.js +++ b/install/static/entity.js @@ -377,6 +377,11 @@ IPA.nested_tabs = function(entity_name){ var siblings = []; + if (!IPA.tab_set) { + siblings.push(entity_name); + return siblings; + } + for (var top_tab_index = 0; top_tab_index < IPA.tab_set.length; top_tab_index += 1){ @@ -479,20 +484,7 @@ function ipa_facet_create_action_panel(container) { for (var i=1; i', { @@ -507,7 +499,7 @@ function ipa_facet_create_action_panel(container) { return false; } }).appendTo(ul); - } + } } /*When we land on the search page, disable all facets that require a pkey until one is selected*/ diff --git a/install/static/group.js b/install/static/group.js index 0dfae2fdc8380a86c91a3e6e818b927c0d50da8c..bcac40982d1bddaec55bdb46173df0b65e2bfb68 100644 --- a/install/static/group.js +++ b/install/static/group.js @@ -193,6 +193,19 @@ function ipa_group_member_user_facet(spec) { that.create_column({name: 'telephonenumber', label: 'Phone'}); that.create_column({name: 'title', label: 'Job Title'}); + that.create_adder_column({ + name: 'cn', + label: 'Name', + width: '100px' + }); + + that.create_adder_column({ + name: 'uid', + label: 'Login', + primary_key: true, + width: '100px' + }); + that.association_facet_init(); }; diff --git a/install/static/hbac.js b/install/static/hbac.js index 0d6ed7373991a07ad663fc0a20df01f06a4b3389..e2c1266c4fcde2e5f640111b377f831666b98c35 100755 --- a/install/static/hbac.js +++ b/install/static/hbac.js @@ -884,7 +884,7 @@ function ipa_hbac_accesstime_widget(spec) { for (var i=0; values && i').appendTo(table); + if (that.scrollable) { + thead.css('display', 'block'); + } + var tr = $('').appendTo(thead); var th = $('', { - 'style': 'width: 25px;' + 'style': 'width: 22px;' }).appendTo(tr); $('', { @@ -511,8 +519,21 @@ function ipa_table_widget(spec) { for (var i=0; i').appendTo(tr); + if (that.scrollable && (i == that.columns.length-1)) { + if (column.width) { + var width = parseInt(column.width.substring(0, column.width.length-2)); + width += 16; + th.css('width', width+'px'); + } + } else { + if (column.width) { + th.css('width', column.width); + } + } + var label = column.label; $('', { @@ -530,9 +551,20 @@ function ipa_table_widget(spec) { var tbody = $('').appendTo(table); + if (that.scrollable) { + tbody.css('display', 'block'); + tbody.css('overflow', 'auto'); + } + + if (that.height) { + tbody.css('height', that.height); + } + tr = $('').appendTo(tbody); - var td = $('').appendTo(tr); + var td = $('', { + 'style': 'width: 22px;' + }).appendTo(tr); $('', { 'type': 'checkbox', @@ -541,10 +573,15 @@ function ipa_table_widget(spec) { }).appendTo(td); for (var i=0; i').appendTo(tr); + if (column.width) { + td.css('width', column.width); + } $('', { - 'name': that.columns[i].name + 'name': column.name }).appendTo(td); } @@ -591,16 +628,20 @@ function ipa_table_widget(spec) { that.row.detach(); }; - that.load = function(result) { - + that.empty = function() { that.tbody.empty(); + }; + + that.load = function(result) { + + that.empty(); var values = result[that.name]; if (!values) return; for (var i=0; i').appendTo(that.container); results_panel.css('border', '2px solid rgb(0, 0, 0)'); results_panel.css('position', 'relative'); + results_panel.css('width', '100%'); results_panel.css('height', '200px'); - var available_panel = $('
').appendTo(results_panel); - available_panel.css('float', 'left'); + var available_title = $('
', { + html: 'Available', + style: 'float: left; width: 250px;' + }).appendTo(results_panel); - $('
', { - text: 'Available' - }).appendTo(available_panel); + var buttons_title = $('
', { + html: ' ', + style: 'float: left; width: 50px;' + }).appendTo(results_panel); - that.available_list = $('', { @@ -918,36 +1018,32 @@ function ipa_adder_dialog(spec) { value: '>>' }).appendTo(p); - var selected_panel = $('
').appendTo(results_panel); - selected_panel.css('float', 'left'); + var selected_panel = $('
', { + name: 'selected', + style: 'float: left; width: 250px; height: 150px;' + }).appendTo(results_panel); - $('
', { - text: 'Prospective' - }).appendTo(selected_panel); - - that.selected_list = $('