From 61cfa343c36383a1a2e12663aec44e9c5692b854 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Tue, 7 Jun 2011 12:58:51 -0500 Subject: Added selectable option for table widget. A selectable option has been added to the table widget to show/hide the checkbox column for selecting table rows. By default it's set to true. The indirect association facet has been modified to hide the column because it is non-editable. --- install/ui/widget.js | 75 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 31 deletions(-) (limited to 'install/ui/widget.js') diff --git a/install/ui/widget.js b/install/ui/widget.js index fc73e85b..6e70cc0a 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -883,6 +883,7 @@ IPA.select_widget = function(spec) { that.create_undo(container); } }; + that.setup = function(container) { that.widget_setup(container); @@ -1056,12 +1057,14 @@ IPA.table_widget = function (spec) { var that = IPA.widget(spec); that.scrollable = spec.scrollable; - that.save_values = typeof spec.save_values == 'undefined' ? true : spec.save_values; + that.selectable = spec.selectable === undefined ? true : spec.selectable; + that.save_values = spec.save_values === undefined ? true : spec.save_values; that['class'] = spec['class']; that.current_page = 1; that.total_pages = 1; that.page_length = spec.page_length; + that.columns = $.ordered_map(); that.get_columns = function() { @@ -1121,26 +1124,30 @@ IPA.table_widget = function (spec) { var tr = $('').appendTo(that.thead); - var th = $('', { - 'style': 'width: 22px;' - }).appendTo(tr); + var th; - var select_all_checkbox = $('', { - type: 'checkbox', - name: 'select', - title: IPA.messages.search.select_all - }).appendTo(th); - - select_all_checkbox.change(function() { - var checked = select_all_checkbox.is(':checked'); - select_all_checkbox.attr('title', checked ? IPA.messages.search.unselect_all : IPA.messages.search.select_all); - var checkboxes = $('input[name=select]', that.tbody).get(); - for (var i=0; i', { + 'style': 'width: 22px;' + }).appendTo(tr); + + var select_all_checkbox = $('', { + type: 'checkbox', + name: 'select', + title: IPA.messages.search.select_all + }).appendTo(th); + + select_all_checkbox.change(function() { + var checked = select_all_checkbox.is(':checked'); + select_all_checkbox.attr('title', checked ? IPA.messages.search.unselect_all : IPA.messages.search.select_all); + var checkboxes = $('input[name=select]', that.tbody).get(); + for (var i=0; i'); - var td = $('', { - 'style': 'width: '+ IPA.checkbox_column_width +'px;' - }).appendTo(that.row); + var td; - $('', { - 'type': 'checkbox', - 'name': 'select', - 'value': 'user' - }).appendTo(td); + if (that.selectable) { + td = $('', { + 'style': 'width: '+ IPA.checkbox_column_width +'px;' + }).appendTo(that.row); + + $('', { + 'type': 'checkbox', + 'name': 'select', + 'value': 'user' + }).appendTo(td); + } for (/* var */ i=0; i').appendTo(that.tfoot); - td = $('', { colspan: columns.length+1 }).appendTo(tr); + td = $('', { + colspan: columns.length + (that.selectable ? 1 : 0) + }).appendTo(tr); that.summary = $('', { 'name': 'summary' -- cgit