From a5fab8bbd107f5071a66c80f7c92c0eabff418fd Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Thu, 17 Nov 2011 11:25:09 -0600 Subject: [PATCH] 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 --- install/ui/facet.js | 3 +- install/ui/ipa.css | 6 +- install/ui/test/data/user_find_pkeys.json | 294 ++++++++++++++++++++++++++++- 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 e4377151bcd5bf13adc39da4ceb6ca4f5221bc86..3a1ae92edc6b20515fc29627b32c2d1442aaa0ac 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 d9b547575510e2b54acc98b8d3c0019a7e53bcca..c1391a4ea5db0c17e968dfbd3ad0016821982ec2 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 1669d249e9d677b6bee49d47e636c48199018945..00bbfb3e971fa5a4e3d2bbee0e075765523949dd 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 e9fffaf1981552740cea41841da6e29b29c6618b..942fe9a617cd71085cd65e4997f0b2e662d53615 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -1291,9 +1291,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(); @@ -1355,20 +1358,22 @@ IPA.table_widget = function (spec) { 'style': 'width: 22px;' }).appendTo(tr); - var select_all_checkbox = $('', { - type: 'checkbox', - name: 'select', - title: IPA.messages.search.select_all - }).appendTo(th); + if (that.multivalued) { + var select_all_checkbox = $('', { + 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; @@ -1434,11 +1439,19 @@ IPA.table_widget = function (spec) { 'style': 'width: '+ IPA.checkbox_column_width +'px;' }).appendTo(that.row); - $('', { - 'type': 'checkbox', - 'name': 'select', - 'value': 'user' - }).appendTo(td); + if (that.multivalued) { + $('', { + type: 'checkbox', + name: that.name, + value: '' + }).appendTo(td); + } else { + $('', { + type: 'radio', + name: that.name, + value: '' + }).appendTo(td); + } } for (/* var */ i=0; i', { - 'name': 'pagination' + that.pagination_control = $('', { + 'class': 'pagination-control' }).appendTo(td); - if (that.page_length) { + if (that.pagination) { $('', { text: IPA.messages.widget.prev, @@ -1481,9 +1494,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(' '); $('', { text: IPA.messages.widget.next, @@ -1492,11 +1505,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 = $('', { type: 'text', @@ -1507,13 +1520,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 = $('', { name: 'total_pages' - }).appendTo(that.pagination); + }).appendTo(that.pagination_control); } }; @@ -1546,16 +1559,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(); }; @@ -1581,7 +1594,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()); }); @@ -1595,7 +1608,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()); }); @@ -1603,7 +1616,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) { @@ -1631,7 +1644,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(); }); @@ -1644,7 +1657,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); @@ -1655,7 +1668,9 @@ IPA.table_widget = function (spec) { that.add_rows = function(rows) { for (var i=0; i