Fixed layout problem in permission adder dialog.

In order to maintain consistent layout between details page and dialog
boxes the IPA.details_list_section has been replaced with
IPA.details_table_section which is based on table.

The IPA.target_section and other subclasses of IPA.details_list_section
have been converted to use IPA.details_table_section as well.

The unit tests have been updated accordingly.

Ticket #1648
This commit is contained in:
Endi S. Dewata
2011-08-10 20:03:02 -05:00
parent 806a40846b
commit 26ded75be9
12 changed files with 363 additions and 467 deletions

View File

@@ -33,20 +33,29 @@ IPA.entity_factories.permission = function() {
}). }).
details_facet({sections:[ details_facet({sections:[
{ {
name:'identity', name: 'identity',
fields: [{ fields: [
factory: IPA.text_widget, {
name: 'cn', factory: IPA.text_widget,
read_only: true name: 'cn',
}] read_only: true
}
]
}, },
{ {
name:'rights', name: 'rights',
factory:IPA.rights_section label: IPA.messages.objects.permission.rights,
fields: [
{
factory: IPA.rights_widget,
name: 'permissions',
join: true
}
]
}, },
{ {
name:'target', factory: IPA.target_section,
factory:IPA.target_section, name: 'target',
label: IPA.messages.objects.permission.target label: IPA.messages.objects.permission.target
}]}). }]}).
association_facet({ association_facet({
@@ -56,10 +65,10 @@ IPA.entity_factories.permission = function() {
adder_dialog({ adder_dialog({
width: 500, width: 500,
height: 400, height: 400,
fields:[ fields: [
'cn', 'cn',
{ {
factory:IPA.rights_widget, factory: IPA.rights_widget,
name: 'permissions', name: 'permissions',
join: true, undo: false join: true, undo: false
}, },
@@ -68,7 +77,8 @@ IPA.entity_factories.permission = function() {
name: 'target', name: 'target',
label: IPA.messages.objects.permission.target, label: IPA.messages.objects.permission.target,
undo: false undo: false
}] }
]
}). }).
build(); build();
}; };
@@ -380,26 +390,6 @@ IPA.rights_widget = function(spec) {
return that; return that;
}; };
IPA.rights_section = function(spec) {
spec = spec || {};
spec.name = 'rights';
spec.label = IPA.messages.objects.permission.rights;
var that = IPA.details_section(spec);
that.add_field(IPA.rights_widget({
entity: that.entity,
name: 'permissions',
join: true
}));
return that;
};
IPA.target_section = function(spec) { IPA.target_section = function(spec) {
spec = spec || {}; spec = spec || {};
@@ -408,158 +398,60 @@ IPA.target_section = function(spec) {
that.section = true; that.section = true;
that.undo = typeof spec.undo == 'undefined' ? true : spec.undo; that.undo = typeof spec.undo == 'undefined' ? true : spec.undo;
that.filter_text = IPA.text_widget({
name: 'filter',
undo: that.undo,
entity: spec.entity
});
that.subtree_textarea = IPA.textarea_widget({
entity: spec.entity,
name: 'subtree',
cols: 30, rows: 1,
undo: that.undo
});
that.group_select = IPA.entity_select_widget({
name: 'targetgroup',
other_entity: 'group',
other_field: 'cn',
undo: that.undo
});
that.type_select = IPA.select_widget({
name: 'type',
undo: that.undo
});
that.attribute_table = IPA.attributes_widget({
entity: spec.entity,
name: 'attrs',
undo: that.undo
});
that.add_field(that.filter_text);
that.add_field(that.subtree_textarea);
that.add_field(that.group_select );
that.add_field(that.type_select);
that.add_field(that.attribute_table);
/*TODO these next two functions are work arounds for missing attribute
permissions for the filter text. Remove them once that has been fixed */
that.filter_text.update = function(){
var value = that.filter_text.values && that.filter_text.values.length ?
that.filter_text.values[0] : '';
$('input[name="'+that.filter_text.name+'"]',
that.filter_text.container).val(value);
var label = $('label[name="'+that.filter_text.name+'"]',
that.filter_text.container);
var input = $('input[name="'+that.filter_text.name+'"]',
that.filter_text.container);
label.css('display', 'none');
input.css('display', 'inline');
};
that.filter_text.save = function(){
var input = $('input[name="'+that.filter_text.name+'"]',
that.filter_text.container);
var value = input.val();
return value === '' ? [] : [value];
};
var target_types = [ var target_types = [
{ {
name:'filter', name: 'filter',
create: function(dl){ label: IPA.messages.objects.permission.filter,
create: function(container) {
$('<dt/>'). that.filter_text.create(container);
append($('<label/>', {
text: IPA.messages.objects.permission.filter+':'
})).
appendTo(dl);
var dd = $('<dd/>', {
'class': 'aci_by_filter first'
}).appendTo(dl);
var span = $('<span/>', {
name: 'filter'
}).appendTo(dd);
that.filter_text.create(span);
}, },
load: function(record){ load: function(record) {
that.filter_text.load(record); that.filter_text.load(record);
}, },
save: function(record){ save: function(record) {
record.filter = that.filter_text.save()[0]; record.filter = that.filter_text.save()[0];
} }
}, },
{ {
name:'subtree', name: 'subtree',
create:function(dl) { label: IPA.messages.objects.permission.subtree,
$('<dt/>'). create: function(container) {
append($('<label/>', { that.subtree_textarea.create(container);
text: IPA.messages.objects.permission.subtree+':'
})).
appendTo(dl);
var dd = $('<dd/>', {
'class': 'aci_by_query first'
}).appendTo(dl);
var span = $('<span/>', {
name: 'subtree'
}).appendTo(dd);
that.subtree_textarea.create(span);
}, },
load: function(record){ load: function(record) {
that.subtree_textarea.load(record); that.subtree_textarea.load(record);
}, },
save: function(record){ save: function(record) {
record.subtree = that.subtree_textarea.save()[0]; record.subtree = that.subtree_textarea.save()[0];
} }
}, },
{ {
name:'targetgroup', name: 'targetgroup',
create: function (dl) { label: IPA.messages.objects.permission.targetgroup,
$('<dt/>'). create: function(container) {
append($('<label/>', { that.group_select.create(container);
text: IPA.messages.objects.permission.targetgroup+':'
})).
appendTo(dl);
var dd = $('<dd/>', {
'class': 'aci_by_group first'
}).appendTo(dl);
var span = $('<span/>', {
name: 'targetgroup'
}).appendTo(dd);
that.group_select.create(span);
}, },
load: function(record){ load: function(record) {
that.group_select.list.val(record.targetgroup); that.group_select.list.val(record.targetgroup);
}, },
save: function(record){ save: function(record) {
record.targetgroup = that.group_select.save()[0]; record.targetgroup = that.group_select.save()[0];
} }
}, },
{ {
name:'type', name: 'type',
create: function(dl) { label: IPA.messages.objects.permission.type,
$('<dt/>'). create: function(container) {
append($('<label/>', {
text: IPA.messages.objects.permission.type+':'
})).
appendTo(dl);
var dd = $('<dd/>', {
'class': 'aci_by_type first'
}).appendTo(dl);
var span = $('<span/>', { var span = $('<span/>', {
name: 'type' name: 'type'
}).appendTo(dd); }).appendTo(container);
that.type_select.create(span); that.type_select.create(span);
span = $('<span/>', {
span = $('<dd/>', { name: 'attrs'
name: 'attrs', }).appendTo(container);
'class':'other'
}).appendTo(dl);
that.attribute_table.create(span); that.attribute_table.create(span);
@@ -570,17 +462,21 @@ IPA.target_section = function(spec) {
that.type_select.save()[0]; that.type_select.save()[0];
that.attribute_table.reset(); that.attribute_table.reset();
}); });
select.append($('<option/>', { select.append($('<option/>', {
value: '', value: '',
text: '' text: ''
})); }));
var type_params = IPA.get_entity_param('permission', 'type'); var type_params = IPA.get_entity_param('permission', 'type');
for (var i=0; i<type_params.values.length; i++){
for (var i=0; i<type_params.values.length; i++) {
select.append($('<option/>', { select.append($('<option/>', {
value: type_params.values[i], value: type_params.values[i],
text: type_params.values[i] text: type_params.values[i]
})); }));
} }
that.type_select.update = function() { that.type_select.update = function() {
that.type_select.select_update(); that.type_select.select_update();
that.attribute_table.object_type = that.attribute_table.object_type =
@@ -601,11 +497,69 @@ IPA.target_section = function(spec) {
var target_type = target_types[0]; var target_type = target_types[0];
var init = function() {
that.filter_text = IPA.text_widget({
name: 'filter',
undo: that.undo,
entity: spec.entity
});
that.subtree_textarea = IPA.textarea_widget({
entity: spec.entity,
name: 'subtree',
cols: 30, rows: 1,
undo: that.undo
});
that.group_select = IPA.entity_select_widget({
name: 'targetgroup',
other_entity: 'group',
other_field: 'cn',
undo: that.undo
});
that.type_select = IPA.select_widget({
name: 'type',
undo: that.undo
});
that.attribute_table = IPA.attributes_widget({
entity: spec.entity,
name: 'attrs',
undo: that.undo
});
that.add_field(that.filter_text);
that.add_field(that.subtree_textarea);
that.add_field(that.group_select );
that.add_field(that.type_select);
that.add_field(that.attribute_table);
/*TODO these next two functions are work arounds for missing attribute
permissions for the filter text. Remove them once that has been fixed */
that.filter_text.update = function() {
var value = that.filter_text.values && that.filter_text.values.length ?
that.filter_text.values[0] : '';
$('input[name="'+that.filter_text.name+'"]',
that.filter_text.container).val(value);
var label = $('label[name="'+that.filter_text.name+'"]',
that.filter_text.container);
var input = $('input[name="'+that.filter_text.name+'"]',
that.filter_text.container);
label.css('display', 'none');
input.css('display', 'inline');
};
that.filter_text.save = function(){
var input = $('input[name="'+that.filter_text.name+'"]',
that.filter_text.container);
var value = input.val();
return value === '' ? [] : [value];
};
};
function show_target_type(type_to_show) { function show_target_type(type_to_show) {
for (var i=0; i<target_types.length; i++) { for (var i=0; i<target_types.length; i++) {
if (target_types[i].name === type_to_show) { if (target_types[i].name === type_to_show) {
target_type = target_types[i]; target_type = target_types[i];
target_type.container.css('display', 'block'); target_type.container.css('display', '');
} else { } else {
target_types[i].container.css('display', 'none'); target_types[i].container.css('display', 'none');
} }
@@ -613,38 +567,79 @@ IPA.target_section = function(spec) {
} }
that.create = function(container) { that.create = function(container) {
that.container = container;
var dl = $('<dl/>', { var table = $('<table/>', {
'class': 'aci-target' 'class': 'section-table'
}).appendTo(container); }).appendTo(that.container);
$('<dt>Target:</dt>').appendTo(dl);
if (that.undo){ var tr = $('<tr/>').appendTo(table);
dl.css('display','none');
var td = $('<td/>', {
'class': 'section-cell-label'
}).appendTo(tr);
$('<label/>', {
name: 'target',
title: IPA.messages.objects.permission.target,
'class': 'field-label',
text: IPA.messages.objects.permission.target+':'
}).appendTo(td);
if (that.undo) {
tr.css('display', 'none');
} }
that.target_type_select = $('<select></select>',{
change:function(){ td = $('<td/>', {
'class': 'section-cell-field'
}).appendTo(tr);
var field_container = $('<div/>', {
name: 'target',
'class': 'field'
}).appendTo(td);
that.target_type_select = $('<select/>', {
change: function() {
show_target_type(this.value); show_target_type(this.value);
}}); }
}).appendTo(field_container);
$('<dd/>', for (var i=0 ; i<target_types.length; i++) {
{"class":"first"}).
append(that.target_type_select).appendTo(dl);
for (var i = 0 ; i < target_types.length; i += 1){
target_type = target_types[i]; target_type = target_types[i];
dl = $('<dl/>', {
'class': 'aci-target' ,
id: target_type.name,
style: 'display:none'
}).appendTo(container);
that.target_type_select.append($('<option/>',{ $('<option/>', {
text: target_type.name, text: target_type.name,
value : target_type.name value : target_type.name
})); }).appendTo(that.target_type_select);
target_type.create(dl);
target_type.container = dl; tr = $('<tr/>', {
style: 'display: none'
}).appendTo(table);
td = $('<td/>', {
'class': 'section-cell-label'
}).appendTo(tr);
$('<label/>', {
name: target_type.name,
title: target_type.label,
'class': 'field-label',
text: target_type.label+':'
}).appendTo(td);
td = $('<td/>', {
'class': 'section-cell-field'
}).appendTo(tr);
field_container = $('<div/>', {
name: target_type.name,
title: target_type.label,
'class': 'field'
}).appendTo(td);
target_type.create(field_container);
target_type.container = tr;
} }
}; };
@@ -667,14 +662,14 @@ IPA.target_section = function(spec) {
reset_target_widgets(); reset_target_widgets();
var target_type_name ; var target_type_name ;
for (var i = 0 ; i < target_types.length; i += 1){ for (var i=0; i<target_types.length; i++) {
target_type = target_types[i]; target_type = target_types[i];
if (record[target_type.name]){ if (record[target_type.name]) {
target_type_name = target_type.name; target_type_name = target_type.name;
break; break;
} }
} }
if (!target_type_name){ if (!target_type_name) {
alert(IPA.messages.objects.permission.invalid_target); alert(IPA.messages.objects.permission.invalid_target);
return; return;
} }
@@ -698,6 +693,7 @@ IPA.target_section = function(spec) {
} else { } else {
reset_target_widgets(); reset_target_widgets();
that.target_type_select.val(target_types[0].name);
show_target_type(target_types[0].name); show_target_type(target_types[0].name);
} }
}; };
@@ -706,14 +702,7 @@ IPA.target_section = function(spec) {
target_type.save(record); target_type.save(record);
}; };
return that; init();
};
IPA.permission_details_facet = function(spec) {
spec = spec || {};
var that = IPA.details_facet(spec);
return that; return that;
}; };

View File

@@ -95,7 +95,8 @@ IPA.details_section = function(spec) {
var field = fields[i]; var field = fields[i];
var field_container = $('<div/>', { var field_container = $('<div/>', {
name: field.name, name: field.name,
'class': 'details-field' title: field.label,
'class': 'field'
}).appendTo(container); }).appendTo(container);
field.create(field_container); field.create(field_container);
} }
@@ -167,36 +168,7 @@ IPA.details_section = function(spec) {
return that; return that;
}; };
IPA.details_table_section = function(spec) {
/**
* This class creates a details section formatted as a list of
* attributes names and values. The list is defined using a <dl> tag.
* The attribute name is defined inside a <dt> tag. The attribute
* value is specified within a <span> inside a <dd> tag. If the
* attribute has multiple values the <span> will contain be
* duplicated to display each value.
*
* Example:
* <dl class="entryattrs">
*
* <dt title="givenname">First Name:</dt>
* <dd>
* <span name="givenname">
* John Smith
* </span>
* </dd>
*
* <dt title="telephonenumber">Telephone Number:</dt>
* <dd>
* <span name="telephonenumber">
* <div name="value">111-1111</div>
* <div name="value">222-2222</div>
* </span>
* </dd>
*
* </dl>
*/
IPA.details_list_section = function(spec) {
spec = spec || {}; spec = spec || {};
@@ -207,33 +179,56 @@ IPA.details_list_section = function(spec) {
// do not call section_create() here // do not call section_create() here
var dl = $('<dl/>', { var table = $('<table/>', {
'id': that.name, 'class': 'section-table'
'class': 'entryattrs' }).appendTo(that.container);
}).appendTo(container);
var fields = that.fields.values; var fields = that.fields.values;
for (var i=0; i<fields.length; i++) { for (var i=0; i<fields.length; i++) {
var field = fields[i]; var field = fields[i];
if (field.hidden) continue;
var label = field.label || ''; var tr = $('<tr/>').appendTo(table);
$('<dt/>', { var td = $('<td/>', {
html: label+':', 'class': 'section-cell-label'
title: label }).appendTo(tr);
}).appendTo(dl);
var dd = $('<dd/>').appendTo(dl); $('<label/>', {
name: field.name,
title: field.label,
'class': 'field-label',
text: field.label+':'
}).appendTo(td);
td = $('<td/>', {
'class': 'section-cell-field'
}).appendTo(tr);
var field_container = $('<div/>', { var field_container = $('<div/>', {
name: field.name, name: field.name,
'class': 'details-field' title: field.label,
}).appendTo(dd); 'class': 'field'
}).appendTo(td);
field.create(field_container); field.create(field_container);
if (field.optional){
field_container.css('display', 'none');
var link = $('<a/>', {
text: IPA.messages.widget.optional,
href: '',
click: function() {
field_container.css('display', 'inline');
link.css('display', 'none');
return false;
}
}).appendTo(td);
}
} }
}; };
that.list_section_create = that.create; that.table_section_create = that.create;
return that; return that;
}; };

View File

@@ -128,7 +128,9 @@ IPA.dialog = function(spec) {
*/ */
that.create = function() { that.create = function() {
var table = $('<table/>').appendTo(that.container); var table = $('<table/>', {
'class': 'section-table'
}).appendTo(that.container);
var fields = that.fields.values; var fields = that.fields.values;
for (var i=0; i<fields.length; i++) { for (var i=0; i<fields.length; i++) {
@@ -138,39 +140,39 @@ IPA.dialog = function(spec) {
var tr = $('<tr/>').appendTo(table); var tr = $('<tr/>').appendTo(table);
var td = $('<td/>', { var td = $('<td/>', {
style: 'vertical-align: top;', 'class': 'section-cell-label'
title: field.label
}).appendTo(tr); }).appendTo(tr);
var label_text = field.label;
if (label_text !== null){ $('<label/>', {
label_text += ': '; name: field.name,
}else{ title: field.label,
label_text = ''; 'class': 'field-label',
} text: field.label+':'
td.append($('<label />',{id: field.name+'-label', }).appendTo(td);
text: label_text}));
td = $('<td/>', { td = $('<td/>', {
style: 'vertical-align: top;' 'class': 'section-cell-field'
}).appendTo(tr); }).appendTo(tr);
var span = $('<span/>', { 'name': field.name }).appendTo(td); var field_container = $('<div/>', {
field.create(span); name: field.name,
field.field_span = span; title: field.label,
'class': 'field'
}).appendTo(td);
field.create(field_container);
if (field.optional){ if (field.optional){
span.css('display','none'); field_container.css('display','none');
td.append( var link = $('<a/>', {
$('<a/>',{ text: IPA.messages.widget.optional,
text: IPA.messages.widget.optional, href: '',
href:'', click: function(){
click: function(){ field_container.css('display', 'inline');
var span = $(this).prev(); link.css('display', 'none');
span.css('display','inline'); return false;
$(this).css('display','none'); }
return false; }).appendTo(td);
}
}));
} }
} }
@@ -181,7 +183,7 @@ IPA.dialog = function(spec) {
var div = $('<div/>', { var div = $('<div/>', {
name: section.name, name: section.name,
'class': 'details-section' 'class': 'dialog-section'
}).appendTo(that.container); }).appendTo(that.container);
section.create(div); section.create(div);

View File

@@ -882,7 +882,7 @@ IPA.entity_builder = function(){
if (spec.factory) { if (spec.factory) {
section = spec.factory(spec); section = spec.factory(spec);
} else { } else {
section = IPA.details_list_section(spec); section = IPA.details_table_section(spec);
} }
facet.add_section(section); facet.add_section(section);
var fields = spec.fields; var fields = spec.fields;

View File

@@ -141,7 +141,7 @@ IPA.hbacrule_details_facet = function(spec) {
var that = IPA.details_facet(spec); var that = IPA.details_facet(spec);
function general_section(){ function general_section(){
var section = IPA.details_list_section({ var section = IPA.details_table_section({
name: 'general', name: 'general',
entity:that.entity, entity:that.entity,
label: IPA.messages.details.general label: IPA.messages.details.general

View File

@@ -427,10 +427,10 @@ IPA.host_enrollment_section = function(spec) {
spec = spec || {}; spec = spec || {};
var that = IPA.details_list_section(spec); var that = IPA.details_table_section(spec);
that.create = function(container) { that.create = function(container) {
that.list_section_create(container); that.table_section_create(container);
var keytab_field = that.get_field('has_keytab'); var keytab_field = that.get_field('has_keytab');
var password_field = that.get_field('has_password'); var password_field = that.get_field('has_password');

View File

@@ -806,114 +806,48 @@ hr {
line-height: 25px; line-height: 25px;
} }
.dialog-section {
margin-top: 10px;
}
.section-table {
width: 100%;
}
.section-cell-label {
vertical-align: top;
width: 120px;
}
.section-cell-field {
}
.details-section { .details-section {
margin-top: 1em;
margin-left: 4.5em; margin-left: 4.5em;
margin-right: 1.5em; margin-right: 3.3em;
margin-top: 1.8em; margin-bottom: 1em;
white-space: nowrap; }
padding-bottom: 1.8em;
padding-right: 1.8em; .details-section .section-table {
width: 100%;
border-spacing: 12px;
}
.details-section .section-cell-label {
text-align: right;
vertical-align: top;
width: 120px;
}
.details-section .section-cell-field {
font-weight: bold;
} }
.undo { .undo {
cursor:pointer; cursor:pointer;
} }
dl.entryattrs {
clear: both;
margin-left: 1.5em;
margin-top: 1.8em;
white-space: nowrap;
}
dl.entryattrs dt {
clear: left;
float: left;
padding-bottom: 1.8em;
padding-right: 1.8em;
text-align: right;
width: 16em;
margin: 0.5em -0.5em 0 -6em;
}
dl.entryattrs dd {
float: left;
margin-bottom: 1em;
margin-left: 0;
margin-top: 0.5em;
font-weight: bold;
}
dl.entryattrs input.otp {
min-width: 15em;
width: 15em;
}
dl.aci-target{
clear: both;
margin-left: 2em;
margin-top: 1.8em;
white-space: nowrap;
}
dl.aci-target dt {
padding-bottom: 1.8em;
padding-left: 2.8em;
text-align: left;
width: 16em;
margin: 0.5em -0.5em 0 -6em;
}
dl.aci-target dd {
}
dl.aci-target dd.other {
margin-left: -1em;
}
dl.aci-target dd.first {
margin-left: 8.5em;
margin-top: -3.7em;
padding-bottom: 2em;
}
dl.aci-target dd.other {
padding-left: 0.7em;
}
dl.aci-target input {
}
#group_filter {
margin-right: 2em;
}
#aci_by_filter {
margin-right: 1em;
}
#aci_by_query {
margin-right: 1em;
}
#aci_by_group {
margin-right: 1em;
}
#aci_by_type {
margin-right: 1em;
margin-top: 2.2em;
}
#aci_attributes_table {
overflow-x: hidden;
width: 46em;
}
span.attrhint { span.attrhint {
font-size: 8pt; font-size: 8pt;
left: 5em; left: 5em;
@@ -1101,32 +1035,6 @@ table.kerberos-key-status {
background-color: #daa520; background-color: #daa520;
} }
dl.modal {
clear: both;
margin-left: 1em;
margin-top: 1em;
white-space: nowrap;
}
dl.modal dt {
clear: left;
float: left;
padding-bottom: 0;
padding-right: 0;
text-align: right;
width: 10em;
}
dl.modal dd {
float: left;
padding-bottom: 0;
margin-left: 0.8em;
}
/*
#dns-record-type-filter {
margin: 0 1em 0 0.5em;
}
*/
.ui-widget-content { .ui-widget-content {
border:0; border:0;
} }

View File

@@ -45,7 +45,7 @@ IPA.rule_details_section = function(spec) {
var span = $('<span/>', { var span = $('<span/>', {
name: that.field_name, name: that.field_name,
title: param_info.doc, title: param_info.doc,
'class': 'details-field' 'class': 'field'
}).appendTo(container); }).appendTo(container);
@@ -92,7 +92,7 @@ IPA.rule_details_section = function(spec) {
var table_span = $('<span/>', { var table_span = $('<span/>', {
name: table.field_name, name: table.field_name,
title: param_info ? param_info.doc : table.field_name, title: param_info ? param_info.doc : table.field_name,
'class': 'details-field' 'class': 'field'
}).appendTo(span); }).appendTo(span);
field = that.get_field(table.field_name); field = that.get_field(table.field_name);

View File

@@ -71,7 +71,7 @@ IPA.entity_factories.service = function() {
standard_association_facets(). standard_association_facets().
adder_dialog({ adder_dialog({
factory: IPA.service_add_dialog, factory: IPA.service_add_dialog,
width: 450, width: 500,
height: 300 height: 300
}). }).
build(); build();

View File

@@ -133,7 +133,7 @@ IPA.sudorule_details_facet = function(spec) {
var that = IPA.details_facet(spec); var that = IPA.details_facet(spec);
function general_section(){ function general_section(){
var section = IPA.details_list_section({ var section = IPA.details_table_section({
name: 'general', name: 'general',
label: IPA.messages.details.general, label: IPA.messages.details.general,
entity: that.entity, entity: that.entity,
@@ -746,7 +746,7 @@ IPA.sudo.rule_details_command_section = function(spec) {
var span = $('<span/>', { var span = $('<span/>', {
name: 'cmdcategory', name: 'cmdcategory',
title: param_info.doc, title: param_info.doc,
'class': 'details-field' 'class': 'field'
}).appendTo(container); }).appendTo(container);
$('<h3/>', { $('<h3/>', {
@@ -764,7 +764,7 @@ IPA.sudo.rule_details_command_section = function(spec) {
var table_span = $('<span/>', { var table_span = $('<span/>', {
name: 'memberallowcmd_sudocmd', name: 'memberallowcmd_sudocmd',
title: param_info ? param_info.doc : 'memberallowcmd_sudocmd', title: param_info ? param_info.doc : 'memberallowcmd_sudocmd',
'class': 'details-field' 'class': 'field'
}).appendTo(span); }).appendTo(span);
field = that.get_field('memberallowcmd_sudocmd'); field = that.get_field('memberallowcmd_sudocmd');
@@ -776,7 +776,7 @@ IPA.sudo.rule_details_command_section = function(spec) {
table_span = $('<span/>', { table_span = $('<span/>', {
name: 'memberallowcmd_sudocmdgroup', name: 'memberallowcmd_sudocmdgroup',
title: param_info ? param_info.doc : 'memberallowcmd_sudocmdgroup', title: param_info ? param_info.doc : 'memberallowcmd_sudocmdgroup',
'class': 'details-field' 'class': 'field'
}).appendTo(span); }).appendTo(span);
field = that.get_field('memberallowcmd_sudocmdgroup'); field = that.get_field('memberallowcmd_sudocmdgroup');
@@ -793,7 +793,7 @@ IPA.sudo.rule_details_command_section = function(spec) {
table_span = $('<span/>', { table_span = $('<span/>', {
name: 'memberdenycmd_sudocmd', name: 'memberdenycmd_sudocmd',
title: param_info ? param_info.doc : 'memberdenycmd_sudocmd', title: param_info ? param_info.doc : 'memberdenycmd_sudocmd',
'class': 'details-field' 'class': 'field'
}).appendTo(span); }).appendTo(span);
field = that.get_field('memberdenycmd_sudocmd'); field = that.get_field('memberdenycmd_sudocmd');
@@ -805,7 +805,7 @@ IPA.sudo.rule_details_command_section = function(spec) {
table_span = $('<span/>', { table_span = $('<span/>', {
name: 'memberdenycmd_sudocmdgroup', name: 'memberdenycmd_sudocmdgroup',
title: param_info ? param_info.doc : 'memberdenycmd_sudocmdgroup', title: param_info ? param_info.doc : 'memberdenycmd_sudocmdgroup',
'class': 'details-field' 'class': 'field'
}).appendTo(span); }).appendTo(span);
field = that.get_field('memberdenycmd_sudocmdgroup'); field = that.get_field('memberdenycmd_sudocmdgroup');
@@ -919,7 +919,7 @@ IPA.sudo.rule_details_runas_section = function(spec) {
var span = $('<span/>', { var span = $('<span/>', {
name: 'ipasudorunasusercategory', name: 'ipasudorunasusercategory',
title: param_info.doc, title: param_info.doc,
'class': 'details-field' 'class': 'field'
}).appendTo(container); }).appendTo(container);
span.append(param_info.doc+": "); span.append(param_info.doc+": ");
field.create(span); field.create(span);
@@ -930,7 +930,7 @@ IPA.sudo.rule_details_runas_section = function(spec) {
var table_span = $('<span/>', { var table_span = $('<span/>', {
name: 'ipasudorunas_user', name: 'ipasudorunas_user',
title: param_info ? param_info.doc : 'ipasudorunas_user', title: param_info ? param_info.doc : 'ipasudorunas_user',
'class': 'details-field' 'class': 'field'
}).appendTo(span); }).appendTo(span);
field = that.get_field('ipasudorunas_user'); field = that.get_field('ipasudorunas_user');
@@ -941,7 +941,7 @@ IPA.sudo.rule_details_runas_section = function(spec) {
table_span = $('<span/>', { table_span = $('<span/>', {
name: 'ipasudorunas_group', name: 'ipasudorunas_group',
title: param_info ? param_info.doc : 'ipasudorunas_group', title: param_info ? param_info.doc : 'ipasudorunas_group',
'class': 'details-field' 'class': 'field'
}).appendTo(span); }).appendTo(span);
field = that.get_field('ipasudorunas_group'); field = that.get_field('ipasudorunas_group');
@@ -954,7 +954,7 @@ IPA.sudo.rule_details_runas_section = function(spec) {
span = $('<span/>', { span = $('<span/>', {
name: 'ipasudorunasgroupcategory', name: 'ipasudorunasgroupcategory',
title: param_info.doc, title: param_info.doc,
'class': 'details-field' 'class': 'field'
}).appendTo(container); }).appendTo(container);
span.append(param_info.doc+": "); span.append(param_info.doc+": ");
@@ -967,7 +967,7 @@ IPA.sudo.rule_details_runas_section = function(spec) {
table_span = $('<span/>', { table_span = $('<span/>', {
name: 'ipasudorunasgroup_group', name: 'ipasudorunasgroup_group',
title: param_info ? param_info.doc : 'ipasudorunasgroup_group', title: param_info ? param_info.doc : 'ipasudorunasgroup_group',
'class': 'details-field' 'class': 'field'
}).appendTo(span); }).appendTo(span);
field = that.get_field('ipasudorunasgroup_group'); field = that.get_field('ipasudorunasgroup_group');

View File

@@ -5,16 +5,24 @@
"result": { "result": {
"attributelevelrights": { "attributelevelrights": {
"aci": "rscwo", "aci": "rscwo",
"attrs": "rscwo",
"businesscategory": "rscwo", "businesscategory": "rscwo",
"cn": "rscwo", "cn": "rscwo",
"description": "rscwo", "description": "rscwo",
"filter": "rscwo",
"group": "rscwo",
"ipapermissiontype": "rscwo",
"member": "rscwo", "member": "rscwo",
"nsaccountlock": "rscwo", "nsaccountlock": "rscwo",
"o": "rscwo", "o": "rscwo",
"objectclass": "rscwo", "objectclass": "rscwo",
"ou": "rscwo", "ou": "rscwo",
"owner": "rscwo", "owner": "rscwo",
"seealso": "rscwo" "permissions": "rscwo",
"seealso": "rscwo",
"subtree": "rscwo",
"targetgroup": "rscwo",
"type": "rscwo"
}, },
"cn": [ "cn": [
"targetgroup" "targetgroup"

View File

@@ -58,7 +58,7 @@ module('details', {
test("Testing IPA.details_section.create().", function() { test("Testing IPA.details_section.create().", function() {
var section = IPA.details_list_section({ var section = IPA.details_table_section({
entity: IPA.get_entity('user'), entity: IPA.get_entity('user'),
name:'IDIDID', label:'NAMENAMENAME'}). name:'IDIDID', label:'NAMENAMENAME'}).
text({name:'cn'}). text({name:'cn'}).
@@ -71,45 +71,38 @@ test("Testing IPA.details_section.create().", function() {
var container = $("<div/>"); var container = $("<div/>");
section.create(container); section.create(container);
var dl = $('dl', container); var table = $('table', container);
same( same(
dl.length, 1, table.length, 1,
'Checking dl tag' 'Verifying table'
); );
var rows = $('tr', table);
same( same(
dl.attr('id'), section.name, rows.length, fields.length,
'Checking section name' 'Verifying table rows'
);
var dts = $('dt', dl);
same(
dts.length, fields.length, // each field generates dt & dd
'Checking number of children'
); );
for (var i=0; i<fields.length; i++) { for (var i=0; i<fields.length; i++) {
var field = fields[i]; var field = fields[i];
var dt = dts.get(i); var field_label = $('.field-label[name='+field.name+']', container);
same( same(
dt.innerHTML, field.label+':', field_label.text(), field.label+':',
'Checking field '+field.name+'\'s label' 'Verifying label for field '+field.name
); );
var field_container = $('.details-field[name='+field.name+']', dl); var field_container = $('.field[name='+field.name+']', container);
ok( ok(
field_container.length, field_container.length,
'Checking container tag for field '+field.name 'Verifying container for field '+field.name
); );
var dd = $('dd', field_container);
ok( ok(
dd.length == 0, field_container.hasClass('widget'),
'Checking dd tag for field '+field.name 'Verifying field '+field.name+' was created'
); );
} }
}); });
@@ -210,25 +203,25 @@ test("Testing details lifecycle: create, load.", function(){
facet.load(result); facet.load(result);
var contact = facet_container.find('dl#contact.entryattrs'); var contact = $('.details-section[name=contact]', facet_container);
ok( ok(
contact, contact.length,
'dl tag for contact is created' 'Verifying section for contact is created'
); );
var identity = facet_container.find('dl#identity.entryattrs'); var identity = $('.details-section[name=identity]', facet_container);
ok( ok(
identity, identity.length,
'dl tag for identity is created' 'Verifying section for identity is created'
); );
var dts = identity.find('dt'); var rows = $('tr', identity);
same( same(
dts.length, 6, rows.length, 6,
'Checking dt tags for identity' 'Verifying rows for identity'
); );
facet_container.attr('id','user'); facet_container.attr('id','user');
@@ -253,8 +246,8 @@ test("Testing details lifecycle: create, load.", function(){
test("Testing IPA.details_section_create again()",function(){ test("Testing IPA.details_section_create again()",function(){
var section = IPA.details_list_section({ var section = IPA.details_table_section({
name: 'IDIDID', label: 'NAMENAMENAME',entity: IPA.get_entity('user'),}). name: 'IDIDID', label: 'NAMENAMENAME',entity: IPA.get_entity('user')}).
text({name:'cn', label:'Entity Name'}). text({name:'cn', label:'Entity Name'}).
text({name:'description', label:'Description'}). text({name:'description', label:'Description'}).
text({name:'number', label:'Entity ID'}); text({name:'number', label:'Entity ID'});
@@ -268,37 +261,38 @@ test("Testing IPA.details_section_create again()",function(){
section.create(container); section.create(container);
section.load(result); section.load(result);
var dl = $('dl', container); var table = $('table', container);
ok(
dl.length,
'dl is created'
);
same( same(
dl[0].id, section.name, table.length, 1,
'checking section name' 'Verifying table'
); );
var dt = $('dt', dl); var rows = $('tr', table);
same( same(
dt.length, 3, rows.length, fields.length,
'3 dt' 'Verifying table rows'
); );
same( for (var i=0; i<fields.length; i++) {
dt[0].innerHTML, fields[0].label+":", var field = fields[i];
'inner HTML matches label'
);
var dd = $('dd', dl); var field_label = $('.field-label[name='+field.name+']', container);
same( same(
dd.length, 3, field_label.text(), field.label+':',
'3 dd' 'Verifying label for field '+field.name
); );
var field_container = $('.details-field[name="cn"]', dd[0]); var field_container = $('.field[name='+field.name+']', container);
same(
field_container.length, 1, ok(
'1 field container' field_container.length,
); 'Verifying container for field '+field.name
);
ok(
field_container.hasClass('widget'),
'Verifying field '+field.name+' was created'
);
}
}); });