From c0eb2b60c85dd686c96693e1a512986ba5b4306e Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 1 Dec 2010 14:51:39 -0600 Subject: 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/widget.js | 206 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 142 insertions(+), 64 deletions(-) (limited to 'install/static/widget.js') diff --git a/install/static/widget.js b/install/static/widget.js index ea6821d1..f7b857f6 100755 --- a/install/static/widget.js +++ b/install/static/widget.js @@ -32,6 +32,9 @@ function ipa_widget(spec) { that.read_only = spec.read_only; that._entity_name = spec.entity_name; + that.width = spec.width; + that.height = spec.height; + that.undo = typeof spec.undo == 'undefined' ? true : spec.undo; that.init = spec.init || init; @@ -433,6 +436,8 @@ function ipa_column(spec) { that.primary_key = spec.primary_key; that.setup = spec.setup || setup; + that.width = spec.width; + function setup(container, record) { container.empty(); @@ -452,8 +457,7 @@ function ipa_table_widget(spec) { var that = ipa_widget(spec); - that.add = spec.add; - that.remove = spec.remove; + that.scrollable = spec.scrollable; that.columns = []; that.columns_by_name = {}; @@ -498,10 +502,14 @@ function ipa_table_widget(spec) { var thead = $('').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.empty = function() { + that.tbody.empty(); + }; + that.load = function(result) { - that.tbody.empty(); + 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 = $('