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
This commit is contained in:
Endi Sukma Dewata 2011-11-17 11:25:09 -06:00 committed by Endi S. Dewata
parent 8f642bbe08
commit 6f0c16e428
4 changed files with 354 additions and 52 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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",
@ -46,6 +46,12 @@
"agordon"
]
},
{
"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": [
@ -94,6 +100,12 @@
"avaldez"
]
},
{
"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": [
@ -106,6 +118,12 @@
"bblair"
]
},
{
"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": [
@ -118,6 +136,12 @@
"bmcgee"
]
},
{
"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": [
@ -154,12 +178,30 @@
"cbarrera"
]
},
{
"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": [
@ -232,6 +274,12 @@
"crobles"
]
},
{
"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": [
@ -268,6 +316,12 @@
"dbriggs"
]
},
{
"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": [
@ -322,6 +376,12 @@
"dshort"
]
},
{
"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": [
@ -340,6 +400,12 @@
"ehayes"
]
},
{
"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": [
@ -352,6 +418,18 @@
"ekane"
]
},
{
"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": [
@ -364,12 +442,24 @@
"ewatkins"
]
},
{
"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": [
@ -424,6 +514,12 @@
"hcalderon"
]
},
{
"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": [
@ -454,6 +550,12 @@
"jbarron"
]
},
{
"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": [
@ -472,6 +574,18 @@
"jgould"
]
},
{
"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": [
@ -532,6 +646,12 @@
"jpreston"
]
},
{
"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": [
@ -556,6 +676,12 @@
"jvilla"
]
},
{
"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": [
@ -568,6 +694,12 @@
"jzavala"
]
},
{
"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": [
@ -592,6 +724,12 @@
"khuerta"
]
},
{
"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": [
@ -628,6 +766,18 @@
"kshaw"
]
},
{
"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": [
@ -664,6 +814,12 @@
"lcohen"
]
},
{
"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": [
@ -718,6 +874,18 @@
"llarson"
]
},
{
"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": [
@ -754,6 +922,12 @@
"lstevenson"
]
},
{
"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": [
@ -766,6 +940,12 @@
"lwilson"
]
},
{
"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": [
@ -922,6 +1102,12 @@
"mvilla"
]
},
{
"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": [
@ -964,12 +1150,30 @@
"omcdonald"
]
},
{
"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": [
@ -994,6 +1198,12 @@
"rcontreras"
]
},
{
"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": [
@ -1006,6 +1216,18 @@
"rhampton"
]
},
{
"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": [
@ -1030,6 +1252,12 @@
"scohen"
]
},
{
"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": [
@ -1060,6 +1288,12 @@
"smcfarland"
]
},
{
"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": [
@ -1090,6 +1324,12 @@
"sroy"
]
},
{
"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": [
@ -1102,6 +1342,18 @@
"sshepherd"
]
},
{
"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": [
@ -1126,6 +1378,18 @@
"tcase"
]
},
{
"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": [
@ -1144,12 +1408,30 @@
"twebster"
]
},
{
"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": [
@ -1174,6 +1456,12 @@
"vreyes"
]
},
{
"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": [
@ -1205,7 +1493,7 @@
]
}
],
"summary": "200 users matched",
"truncated": true
"summary": "248 users matched",
"truncated": false
}
}

View File

@ -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);
}
};