diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2011-11-17 11:25:09 -0600 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2011-12-06 22:07:44 +0000 |
commit | 6f0c16e4289dd1a68bfd673da52a511087d84b9a (patch) | |
tree | 7146fc84898d62efb30a2021689bb97bc57527f9 | |
parent | 8f642bbe0885b4e6d375b705fcead6360d98b30f (diff) | |
download | freeipa.git-6f0c16e4289dd1a68bfd673da52a511087d84b9a.tar.gz freeipa.git-6f0c16e4289dd1a68bfd673da52a511087d84b9a.tar.xz freeipa.git-6f0c16e4289dd1a68bfd673da52a511087d84b9a.zip |
Added support for radio buttons in table widget.
The table widget has been modified to support single-valued attribute
using radio buttons needed by some facets in HBAC Test. The widget now
uses 'pagination' flag to determine whether to show the pagination
control. The test data has also been updated.
Ticket #388
-rw-r--r-- | install/ui/facet.js | 3 | ||||
-rw-r--r-- | install/ui/ipa.css | 6 | ||||
-rw-r--r-- | install/ui/test/data/user_find_pkeys.json | 294 | ||||
-rw-r--r-- | install/ui/widget.js | 103 |
4 files changed, 354 insertions, 52 deletions
diff --git a/install/ui/facet.js b/install/ui/facet.js index e4377151..3a1ae92e 100644 --- a/install/ui/facet.js +++ b/install/ui/facet.js @@ -391,7 +391,6 @@ IPA.table_facet = function(spec) { var that = IPA.facet(spec); that.managed_entity_name = spec.managed_entity_name || that.entity.name; - that.page_length = spec.page_length === undefined ? 20 : spec.page_length; that.pagination = spec.pagination === undefined ? true : spec.pagination; that.search_all = spec.search_all; @@ -509,7 +508,7 @@ IPA.table_facet = function(spec) { name: entity.metadata.primary_key, label: entity.metadata.label, entity: entity, - page_length: that.page_length, + pagination: true, search_all: that.search_all, scrollable: true, selectable: that.selectable && !that.read_only diff --git a/install/ui/ipa.css b/install/ui/ipa.css index d9b54757..c1391a4e 100644 --- a/install/ui/ipa.css +++ b/install/ui/ipa.css @@ -709,15 +709,15 @@ span.main-nav-off > a:visited { margin-right: 4em; } -.search-table span[name=pagination] { +.search-table .pagination-control { float: right; } -.search-table span[name=pagination] a { +.search-table .pagination-control a { cursor:pointer; } -.search-table span[name=pagination] input[name=current_page] { +.search-table .pagination-control input[name=current_page] { width: 22px; } diff --git a/install/ui/test/data/user_find_pkeys.json b/install/ui/test/data/user_find_pkeys.json index 1669d249..00bbfb3e 100644 --- a/install/ui/test/data/user_find_pkeys.json +++ b/install/ui/test/data/user_find_pkeys.json @@ -2,7 +2,7 @@ "error": null, "id": null, "result": { - "count": 200, + "count": 248, "result": [ { "dn": "uid=abarrett,cn=users,cn=accounts,dc=example,dc=com", @@ -47,6 +47,12 @@ ] }, { + "dn": "uid=ajennings,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "ajennings" + ] + }, + { "dn": "uid=aobrien,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "aobrien" @@ -95,6 +101,12 @@ ] }, { + "dn": "uid=bbarber,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "bbarber" + ] + }, + { "dn": "uid=bbauer,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "bbauer" @@ -107,6 +119,12 @@ ] }, { + "dn": "uid=bbush,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "bbush" + ] + }, + { "dn": "uid=bgross,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "bgross" @@ -119,6 +137,12 @@ ] }, { + "dn": "uid=bmullins,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "bmullins" + ] + }, + { "dn": "uid=bnewton,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "bnewton" @@ -155,12 +179,30 @@ ] }, { + "dn": "uid=cblackwell,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "cblackwell" + ] + }, + { "dn": "uid=ccarson,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "ccarson" ] }, { + "dn": "uid=cchristian,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "cchristian" + ] + }, + { + "dn": "uid=cconner,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "cconner" + ] + }, + { "dn": "uid=cduffy,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "cduffy" @@ -233,6 +275,12 @@ ] }, { + "dn": "uid=cstout,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "cstout" + ] + }, + { "dn": "uid=ctrujillo,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "ctrujillo" @@ -269,6 +317,12 @@ ] }, { + "dn": "uid=dfrye,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "dfrye" + ] + }, + { "dn": "uid=dhood,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "dhood" @@ -323,6 +377,12 @@ ] }, { + "dn": "uid=dyoung,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "dyoung" + ] + }, + { "dn": "uid=eberry,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "eberry" @@ -341,6 +401,12 @@ ] }, { + "dn": "uid=eherrera,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "eherrera" + ] + }, + { "dn": "uid=ehunt,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "ehunt" @@ -353,6 +419,18 @@ ] }, { + "dn": "uid=elawrence,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "elawrence" + ] + }, + { + "dn": "uid=emeyer,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "emeyer" + ] + }, + { "dn": "uid=eriley,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "eriley" @@ -365,12 +443,24 @@ ] }, { + "dn": "uid=ffrazier,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "ffrazier" + ] + }, + { "dn": "uid=flam,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "flam" ] }, { + "dn": "uid=fneal,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "fneal" + ] + }, + { "dn": "uid=fstrong,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "fstrong" @@ -425,6 +515,12 @@ ] }, { + "dn": "uid=hpeck,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "hpeck" + ] + }, + { "dn": "uid=hpittman,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "hpittman" @@ -455,6 +551,12 @@ ] }, { + "dn": "uid=jbean,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "jbean" + ] + }, + { "dn": "uid=jbuckley,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "jbuckley" @@ -473,6 +575,18 @@ ] }, { + "dn": "uid=jhowe,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "jhowe" + ] + }, + { + "dn": "uid=jhuynh,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "jhuynh" + ] + }, + { "dn": "uid=jjoyce,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "jjoyce" @@ -533,6 +647,12 @@ ] }, { + "dn": "uid=jriggs,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "jriggs" + ] + }, + { "dn": "uid=jsanford,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "jsanford" @@ -557,6 +677,12 @@ ] }, { + "dn": "uid=jvillanueva,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "jvillanueva" + ] + }, + { "dn": "uid=jwu,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "jwu" @@ -569,6 +695,12 @@ ] }, { + "dn": "uid=kfernandez,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "kfernandez" + ] + }, + { "dn": "uid=kfisher,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "kfisher" @@ -593,6 +725,12 @@ ] }, { + "dn": "uid=kjohnson,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "kjohnson" + ] + }, + { "dn": "uid=kmills,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "kmills" @@ -629,6 +767,18 @@ ] }, { + "dn": "uid=ktravis,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "ktravis" + ] + }, + { + "dn": "uid=kwood,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "kwood" + ] + }, + { "dn": "uid=kzhang,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "kzhang" @@ -665,6 +815,12 @@ ] }, { + "dn": "uid=ldawson,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "ldawson" + ] + }, + { "dn": "uid=ldennis,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "ldennis" @@ -719,6 +875,18 @@ ] }, { + "dn": "uid=llee,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "llee" + ] + }, + { + "dn": "uid=lluna,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "lluna" + ] + }, + { "dn": "uid=lmorrison,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "lmorrison" @@ -755,6 +923,12 @@ ] }, { + "dn": "uid=lswanson,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "lswanson" + ] + }, + { "dn": "uid=lwalters,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "lwalters" @@ -767,6 +941,12 @@ ] }, { + "dn": "uid=mandrade,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "mandrade" + ] + }, + { "dn": "uid=marcher,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "marcher" @@ -923,6 +1103,12 @@ ] }, { + "dn": "uid=mwhitehead,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "mwhitehead" + ] + }, + { "dn": "uid=mwoodard,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "mwoodard" @@ -965,12 +1151,30 @@ ] }, { + "dn": "uid=opayne,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "opayne" + ] + }, + { + "dn": "uid=pcarpenter,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "pcarpenter" + ] + }, + { "dn": "uid=pcarroll,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "pcarroll" ] }, { + "dn": "uid=pjohnston,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "pjohnston" + ] + }, + { "dn": "uid=rcannon,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "rcannon" @@ -995,6 +1199,12 @@ ] }, { + "dn": "uid=rgregory,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "rgregory" + ] + }, + { "dn": "uid=rhale,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "rhale" @@ -1007,6 +1217,18 @@ ] }, { + "dn": "uid=rlynch,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "rlynch" + ] + }, + { + "dn": "uid=rwelch,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "rwelch" + ] + }, + { "dn": "uid=sbarron,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "sbarron" @@ -1031,6 +1253,12 @@ ] }, { + "dn": "uid=sfrost,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "sfrost" + ] + }, + { "dn": "uid=skane,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "skane" @@ -1061,6 +1289,12 @@ ] }, { + "dn": "uid=sorr,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "sorr" + ] + }, + { "dn": "uid=sparrish,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "sparrish" @@ -1091,6 +1325,12 @@ ] }, { + "dn": "uid=ssantana,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "ssantana" + ] + }, + { "dn": "uid=sserrano,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "sserrano" @@ -1103,6 +1343,18 @@ ] }, { + "dn": "uid=ssteele,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "ssteele" + ] + }, + { + "dn": "uid=stanner,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "stanner" + ] + }, + { "dn": "uid=swalter,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "swalter" @@ -1127,6 +1379,18 @@ ] }, { + "dn": "uid=tcrane,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "tcrane" + ] + }, + { + "dn": "uid=tduarte,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "tduarte" + ] + }, + { "dn": "uid=tosborn,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "tosborn" @@ -1145,12 +1409,30 @@ ] }, { + "dn": "uid=twilson,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "twilson" + ] + }, + { + "dn": "uid=ublake,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "ublake" + ] + }, + { "dn": "uid=uevans,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "uevans" ] }, { + "dn": "uid=vcannon,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "vcannon" + ] + }, + { "dn": "uid=vgill,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "vgill" @@ -1175,6 +1457,12 @@ ] }, { + "dn": "uid=wholmes,cn=users,cn=accounts,dc=example,dc=com", + "uid": [ + "wholmes" + ] + }, + { "dn": "uid=wnichols,cn=users,cn=accounts,dc=example,dc=com", "uid": [ "wnichols" @@ -1205,7 +1493,7 @@ ] } ], - "summary": "200 users matched", - "truncated": true + "summary": "248 users matched", + "truncated": false } } diff --git a/install/ui/widget.js b/install/ui/widget.js index 5b50d8f1..221adb0d 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -979,9 +979,12 @@ IPA.table_widget = function (spec) { that.save_values = spec.save_values === undefined ? true : spec.save_values; that['class'] = spec['class']; + that.pagination = spec.pagination; that.current_page = 1; that.total_pages = 1; - that.page_length = spec.page_length; + that.page_length = spec.page_length || 20; + + that.multivalued = spec.multivalued === undefined ? true : spec.multivalued; that.columns = $.ordered_map(); @@ -1043,20 +1046,22 @@ IPA.table_widget = function (spec) { 'style': 'width: 22px;' }).appendTo(tr); - var select_all_checkbox = $('<input/>', { - type: 'checkbox', - name: 'select', - title: IPA.messages.search.select_all - }).appendTo(th); + if (that.multivalued) { + var select_all_checkbox = $('<input/>', { + type: 'checkbox', + name: that.name, + title: IPA.messages.search.select_all + }).appendTo(th); - select_all_checkbox.change(function() { - if(select_all_checkbox.is(':checked')) { - that.select_all(); - } else { - that.unselect_all(); - } - return false; - }); + select_all_checkbox.change(function() { + if(select_all_checkbox.is(':checked')) { + that.select_all(); + } else { + that.unselect_all(); + } + return false; + }); + } } var columns = that.columns.values; @@ -1122,11 +1127,19 @@ IPA.table_widget = function (spec) { 'style': 'width: '+ IPA.checkbox_column_width +'px;' }).appendTo(that.row); - $('<input/>', { - 'type': 'checkbox', - 'name': 'select', - 'value': 'user' - }).appendTo(td); + if (that.multivalued) { + $('<input/>', { + type: 'checkbox', + name: that.name, + value: '' + }).appendTo(td); + } else { + $('<input/>', { + type: 'radio', + name: that.name, + value: '' + }).appendTo(td); + } } for (/* var */ i=0; i<columns.length; i++) { @@ -1156,11 +1169,11 @@ IPA.table_widget = function (spec) { 'name': 'summary' }).appendTo(td); - that.pagination = $('<span/>', { - 'name': 'pagination' + that.pagination_control = $('<span/>', { + 'class': 'pagination-control' }).appendTo(td); - if (that.page_length) { + if (that.pagination) { $('<a/>', { text: IPA.messages.widget.prev, @@ -1169,9 +1182,9 @@ IPA.table_widget = function (spec) { that.prev_page(); return false; } - }).appendTo(that.pagination); + }).appendTo(that.pagination_control); - that.pagination.append(' '); + that.pagination_control.append(' '); $('<a/>', { text: IPA.messages.widget.next, @@ -1180,11 +1193,11 @@ IPA.table_widget = function (spec) { that.next_page(); return false; } - }).appendTo(that.pagination); + }).appendTo(that.pagination_control); - that.pagination.append(' '); - that.pagination.append(IPA.messages.widget.page); - that.pagination.append(': '); + that.pagination_control.append(' '); + that.pagination_control.append(IPA.messages.widget.page); + that.pagination_control.append(': '); that.current_page_input = $('<input/>', { type: 'text', @@ -1195,13 +1208,13 @@ IPA.table_widget = function (spec) { that.set_page(page); } } - }).appendTo(that.pagination); + }).appendTo(that.pagination_control); - that.pagination.append(' / '); + that.pagination_control.append(' / '); that.total_pages_span = $('<span/>', { name: 'total_pages' - }).appendTo(that.pagination); + }).appendTo(that.pagination_control); } }; @@ -1234,16 +1247,16 @@ IPA.table_widget = function (spec) { }; that.select_all = function() { - $('input[name=select]', that.thead).attr('checked', true). + $('input[name="'+that.name+'"]', that.thead).attr('checked', true). attr('title', IPA.messages.search.unselect_all); - $('input[name=select]', that.tbody).attr('checked', true); + $('input[name="'+that.name+'"]', that.tbody).attr('checked', true); that.select_changed(); }; that.unselect_all = function() { - $('input[name=select]', that.thead).attr('checked', false). + $('input[name="'+that.name+'"]', that.thead).attr('checked', false). attr('title', IPA.messages.search.select_all); - $('input[name=select]', that.tbody).attr('checked', false); + $('input[name="'+that.name+'"]', that.tbody).attr('checked', false); that.select_changed(); }; @@ -1269,7 +1282,7 @@ IPA.table_widget = function (spec) { if (that.save_values) { var values = []; - $('input[name="select"]', that.tbody).each(function() { + $('input[name="'+that.name+'"]', that.tbody).each(function() { values.push($(this).val()); }); @@ -1283,7 +1296,7 @@ IPA.table_widget = function (spec) { that.get_selected_values = function() { var values = []; - $('input[name="select"]:checked', that.tbody).each(function() { + $('input[name="'+that.name+'"]:checked', that.tbody).each(function() { values.push($(this).val()); }); @@ -1291,7 +1304,7 @@ IPA.table_widget = function (spec) { }; that.get_selected_rows = function() { - return $('input[name="select"]:checked', that.tbody).closest('tr'); + return $('input[name="'+that.name+'"]:checked', that.tbody).closest('tr'); }; that.get_record = function(result, index) { @@ -1319,7 +1332,7 @@ IPA.table_widget = function (spec) { var tr = that.row.clone(); tr.appendTo(that.tbody); - $('input[name="select"]', tr).click(function(){ + $('input[name="'+that.name+'"]', tr).click(function(){ that.select_changed(); }); @@ -1332,7 +1345,7 @@ IPA.table_widget = function (spec) { value = value ? value.toString() : ''; if (column.primary_key) { - $('input[name="select"]', tr).val(value); + $('input[name="'+that.name+'"]', tr).val(value); } var span = $('span[name="'+column.name+'"]', tr); @@ -1343,7 +1356,9 @@ IPA.table_widget = function (spec) { that.add_rows = function(rows) { for (var i=0; i<rows.length; i++) { - that.tbody.append(rows[i]); + var tr = rows[i]; + $('input', tr).attr('name', that.name); + that.tbody.append(tr); } }; @@ -1351,7 +1366,7 @@ IPA.table_widget = function (spec) { var rows = []; that.tbody.children().each(function() { var tr = $(this); - if (!$('input[name="select"]', tr).get(0).checked) return; + if (!$('input[name="'+that.name+'"]', tr).get(0).checked) return; tr.detach(); rows.push(tr); }); @@ -1366,9 +1381,9 @@ IPA.table_widget = function (spec) { that.set_enabled = function(enabled) { if (enabled) { - $('input[name="select"]', that.table).attr('disabled', false); + $('input[name="'+that.name+'"]', that.table).attr('disabled', false); } else { - $('input[name="select"]', that.table).attr('disabled', true); + $('input[name="'+that.name+'"]', that.table).attr('disabled', true); } }; |