code review fixes

this version includes using spec for detail_facets
This commit is contained in:
Adam Young 2011-03-31 15:32:29 -04:00
parent ef57ee0d93
commit 6948c0813d
19 changed files with 124 additions and 142 deletions

View File

@ -38,13 +38,13 @@ IPA.entity_factories.permission = function() {
},
{
factory: IPA.target_section,
section: 'target',
name: 'target',
label: IPA.messages.objects.permission.target,
undo: false
}]}).
details_facet([
details_facet({sections:[
{
section:'identity',
name:'identity',
fields: [{
factory: IPA.text_widget,
name: 'cn',
@ -52,15 +52,15 @@ IPA.entity_factories.permission = function() {
}]
},
{
section:'rights',
name:'rights',
factory:IPA.rights_section
},
{
section:'target',
name:'target',
factory:IPA.target_section,
label: IPA.messages.objects.permission.target
}]).
standard_associations().
}]}).
standard_association_facets().
build();
};
@ -71,12 +71,13 @@ IPA.entity_factories.privilege = function() {
search_facet({
columns:['cn','description'],
add_fields:['cn', 'description']}).
details_facet([
{
section:'identity',
details_facet({
sections:
[{
name:'identity',
label: IPA.messages.details.identity,
fields:['cn','description']
}]).
}]}).
association_facet({
name: 'member_role',
add_method: 'add_privilege',
@ -88,7 +89,7 @@ IPA.entity_factories.privilege = function() {
add_method: 'add_permission',
remove_method: 'remove_permission'
}).
standard_associations().
standard_association_facets().
build();
};
@ -100,17 +101,17 @@ IPA.entity_factories.role = function() {
search_facet({
columns:['cn','description'],
add_fields:['cn', 'description']}).
details_facet([
details_facet({sections:[
{
section:'identity',
name:'identity',
label:IPA.messages.objects.role.identity,
fields:['cn','description']}]).
fields:['cn','description']}]}).
association_facet({
name: 'memberof_privilege',
add_method: 'add_privilege',
remove_method: 'remove_privilege'
}).
standard_associations().
standard_association_facets().
build();
};
@ -127,9 +128,9 @@ IPA.entity_factories.selfservice = function() {
name:'attrs',
undo: false
}]}).
details_facet([
{
section:'general',
details_facet({
sections:[{
name:'general',
label: IPA.messages.details.general,
fields: [
'aciname',
@ -137,7 +138,7 @@ IPA.entity_factories.selfservice = function() {
factory:IPA.attributes_widget,
object_type:'user',
name:'attrs'
}]}]).
}]}]}).
build();
};
@ -163,9 +164,9 @@ IPA.entity_factories.delegation = function() {
name: 'attrs', object_type: 'user',
join: true, undo: false
}]}).
details_facet([
details_facet({sections:[
{
section:'general',
name:'general',
label: IPA.messages.details.general,
fields:[
'aciname',
@ -182,8 +183,8 @@ IPA.entity_factories.delegation = function() {
factory:IPA.attributes_widget,
name: 'attrs', object_type: 'user',
join: true
}]}]).
standard_associations().
}]}]}).
standard_association_facets().
build();
};

View File

@ -33,12 +33,12 @@ IPA.entity_factories.automountlocation = function() {
columns:['cn'],
add_fields:['cn']
}).
details_facet([{
section:'identity',
details_facet({sections:[{
name:'identity',
label: IPA.messages.objects.automountlocation.identity,
fields:['cn']
}]).
standard_associations().
}]}).
standard_association_facets().
build();
};

View File

@ -579,8 +579,8 @@ IPA.details_refresh = function() {
options: { 'all': true, 'rights': true }
});
if (IPA.refresh_devel_hook){
IPA.refresh_devel_hook(that.entity_name,command,that.pkey);
if (IPA.details_refresh_devel_hook){
IPA.details_refresh_devel_hook(that.entity_name,command,that.pkey);
}

View File

@ -4,7 +4,7 @@ if (window.location.protocol == 'file:') {
IPA.json_url = "test/data";
IPA.use_static_files = true;
IPA.refresh_devel_hook = function(entity_name,command,pkey){
IPA.details_refresh_devel_hook = function(entity_name,command,pkey){
if ((entity_name === 'host')||(entity_name === 'permission')){
command.name = entity_name+'_show_'+pkey;
command.method = entity_name+'_show';

View File

@ -32,8 +32,8 @@ IPA.entity_factories.dnszone = function() {
columns:['idnsname'],
add_fields: ['idnsname','idnssoamname','idnssoarname']
}).
details_facet([{
section:'identity',
details_facet({sections:[{
name:'identity',
fields:[
'idnsname',
'idnszoneactive',
@ -47,12 +47,12 @@ IPA.entity_factories.dnszone = function() {
'dnsttl',
'dnsclass',
'idnsallowdynupdate',
'idnsupdatepolicy']}]).
'idnsupdatepolicy']}]}).
facet(IPA.records_facet({
'name': 'records',
'label': IPA.metadata.objects.dnsrecord.label
})).
standard_associations().
standard_association_facets().
build();
};

View File

@ -530,22 +530,16 @@ IPA. facet_create_action_panel = function(container) {
IPA.entity_builder = function(){
var that = {};
var entity_name ;
var entity = null;
var current_facet = null;
function section(spec){
var current_section = null;
spec.entity_name = entity_name;
spec.entity_name = entity.name;
if (spec.section){
spec.name = spec.section;
if (!spec.label){
var obj_messages = IPA.messages.objects[entity_name];
spec.label = obj_messages[spec.section];
}
if (!spec.label){
var obj_messages = IPA.messages.objects[entity.name];
spec.label = obj_messages[spec.name];
}
if (spec.factory){
@ -553,7 +547,7 @@ IPA.entity_builder = function(){
}else{
current_section = IPA.details_list_section(spec);
}
current_facet.add_section(current_section);
var fields = spec.fields;
if (fields){
var i;
@ -561,23 +555,20 @@ IPA.entity_builder = function(){
for (i =0; i < fields.length; i += 1){
field = fields[i];
if (field instanceof Object){
field.entity_name = entity_name;
field.entity_name = entity.name;
current_section.add_field(field.factory(field));
}else{
field = IPA.text_widget({
name:field,
entity_name:entity_name
entity_name:entity.name
});
current_section.add_field(field);
}
}
}
current_facet.add_section(current_section);
}
that.entity = function(name){
entity_name = name;
that.entity_name = name;
entity = IPA.entity({name: name});
return that;
};
@ -587,8 +578,11 @@ IPA.entity_builder = function(){
return that;
};
that.details_facet = function (sections){
current_facet =IPA.details_facet({entity_name:entity_name});
that.details_facet = function (spec){
var sections = spec.sections;
spec.sections = null;
spec.entity_name = entity.name;
current_facet =IPA.details_facet(spec);
entity.facet(current_facet);
var i;
@ -599,10 +593,6 @@ IPA.entity_builder = function(){
return that;
};
that.get_current_facet = function(){
return current_facet;
};
that.facet = function (facet){
current_facet = facet;
entity.facet(facet);
@ -611,11 +601,9 @@ IPA.entity_builder = function(){
that.search_facet = function (spec){
current_facet = IPA.search_facet({
entity_name:that.entity_name,
entity_name:entity.name,
search_all: spec.search_all || false
});
//once everything usese this mechanism, inline the init code
current_facet.init();
var columns = spec.columns;
var i;
@ -630,7 +618,7 @@ IPA.entity_builder = function(){
IPA.add_dialog({
'name': 'add',
'title': IPA.messages.objects.user.add,
entity_name: entity_name
entity_name: entity.name
});
current_facet.dialog(current_dialog);
@ -653,7 +641,7 @@ IPA.entity_builder = function(){
field.section = null;
current_dialog.add_section(factory(field));
}else{
field.entity_name = entity_name;
field.entity_name = entity.name;
factory = field.factory;
current_dialog.field(factory(field));
}
@ -661,19 +649,18 @@ IPA.entity_builder = function(){
current_dialog.text(add_fields[i]);
}
}
entity.facet(current_facet);
return that;
};
that.association_facet = function(spec){
spec.entity_name = entity_name;
spec.entity_name = entity.name;
entity.facet(IPA.association_facet(spec));
return that;
};
that.standard_associations = function(){
that.standard_association_facets = function(){
entity.standard_associations();
return that;
};

View File

@ -42,11 +42,11 @@ IPA.entity_factories.group = function () {
},
'gidnumber']
}).
details_facet(
details_facet({sections:
[{
section:'details',
name:'details',
fields:['cn','description','gidnumber']
}]).
}]}).
facet( IPA.association_facet({
'name': 'member_user',
columns:[
@ -85,6 +85,6 @@ IPA.entity_factories.group = function () {
name: 'memberof_role',
associator: IPA.serial_associator
}).
standard_associations().
standard_association_facets().
build();
};

View File

@ -54,10 +54,10 @@ IPA.entity_factories.hbacsvc = function () {
search_facet({
columns:['cn','description'],
add_fields:['cn','description']}).
details_facet([{
section : 'general',
details_facet({sections:[{
name: 'general',
label: IPA.messages.details.general,
fields:[ 'cn', 'description']}]).
fields:[ 'cn', 'description']}]}).
build();
};
@ -68,14 +68,14 @@ IPA.entity_factories.hbacsvcgroup = function () {
search_facet({
columns:['cn', 'description'],
add_fields:['cn', 'description']}).
details_facet([
details_facet({sections:[
{
section: 'general',
name: 'general',
label: IPA.messages.details.general,
fields:['cn','description']
},
{
section: 'services',
name: 'services',
label: IPA.messages.objects.hbacsvcgroup.services,
fields:[{
factory: IPA.hbacsvcgroup_member_hbacsvc_table_widget,
@ -84,7 +84,7 @@ IPA.entity_factories.hbacsvcgroup = function () {
other_entity: 'hbacsvc',
save_values: false
}]
}]).
}]}).
build();
};

View File

@ -36,9 +36,9 @@ IPA.entity_factories.host = function () {
}],
add_fields: ['fqdn', {factory:IPA.force_host_add_checkbox_widget}]
}).
details_facet([
details_facet({sections:[
{
section:'details',
name:'details',
fields: [
'fqdn',
'krbprincipalname',
@ -51,7 +51,7 @@ IPA.entity_factories.host = function () {
'description' ]
},
{
section:'enrollment',
name:'enrollment',
fields:[
{
factory: IPA.host_provisioning_status_widget,
@ -61,7 +61,7 @@ IPA.entity_factories.host = function () {
]
},
{
section :'certificate',
name:'certificate',
fields:[
{
factory: IPA.host_certificate_status_widget,
@ -69,7 +69,7 @@ IPA.entity_factories.host = function () {
label: IPA.messages.objects.host.status
}
]
}]).
}]}).
facet(IPA.host_managedby_host_facet({
name: 'managedby_host'
})).
@ -85,7 +85,7 @@ IPA.entity_factories.host = function () {
name: 'memberof_role',
associator: IPA.serial_associator
}).
standard_associations().
standard_association_facets().
build();
};

View File

@ -29,16 +29,16 @@ IPA.entity_factories.hostgroup = function() {
entity('hostgroup').
search_facet({columns:['cn','description'],
add_fields:['cn','description']}).
details_facet([{
section:'identity',
details_facet({sections:[{
name:'identity',
label: IPA.messages.objects.hostgroup.identity,
fields:['cn','description']
}]).
}]}).
association_facet({
name: 'memberof_hostgroup',
associator: IPA.serial_associator
}).
standard_associations().
standard_association_facets().
build();
};

View File

@ -124,7 +124,6 @@
# To add a set of files, use "+process FileName", "+process Folder\Path\*.js",
# or "+process Folder\Path\*.htm".
#
+process core.js
+process ipa.js
+process widget.js
+process dialog.js

View File

@ -28,13 +28,13 @@ IPA.entity_factories.netgroup = function() {
search_facet({
columns:['cn','description'],
add_fields:['cn', 'description']}).
details_facet([{
section:'identity',
fields:['cn','description','nisdomainname']}]).
details_facet({sections:[{
name:'identity',
fields:['cn','description','nisdomainname']}]}).
association_facet({
name: 'memberof_netgroup',
associator: IPA.serial_associator
}).
standard_associations().
standard_association_facets().
build();
};

View File

@ -30,13 +30,14 @@ IPA.entity_factories.pwpolicy = function() {
search_facet({
columns:['cn'],
add_fields:['cn', 'cospriority']}).
details_facet([
{
section : 'identity',
fields:['krbmaxpwdlife','krbminpwdlife','krbpwdhistorylength',
'krbpwdmindiffchars','krbpwdminlength']
}]).
standard_associations().
details_facet({
sections:[
{
name : 'identity',
fields:['krbmaxpwdlife','krbminpwdlife','krbpwdhistorylength',
'krbpwdmindiffchars','krbpwdminlength']
}]}).
standard_association_facets().
build();
};
@ -47,9 +48,10 @@ IPA.entity_factories.pwpolicy = function() {
IPA.entity_factories.krbtpolicy = function() {
return IPA.entity_builder().
entity('krbtpolicy').
details_facet([{
section: 'identity',
fields:[ 'krbmaxrenewableage','krbmaxticketlife' ]
}]).
details_facet({
sections:[{
name: 'identity',
fields:[ 'krbmaxrenewableage','krbmaxticketlife' ]
}]}).
build();
};

View File

@ -30,8 +30,10 @@
IPA.entity_factories.config = function(){
return IPA.entity_builder().
entity('config').
details_facet([{
section: 'ipaserver',
details_facet({
sections:
[{
name: 'ipaserver',
label: IPA.messages.objects.config.ipaserver,
fields:
[{
@ -43,6 +45,6 @@ IPA.entity_factories.config = function(){
'ipadefaultprimarygroup','ipagroupsearchfields',
'ipahomesrootdir','ipamaxusernamelength',
'ipamigrationenabled','ipasearchrecordslimit',
'ipasearchtimelimit','ipausersearchfields']}]).
'ipasearchtimelimit','ipausersearchfields']}]}).
build();
};

View File

@ -36,9 +36,9 @@ IPA.entity_factories.service = function() {
title: IPA.messages.objects.service.add,
width: '450px'
}))).
details_facet([
details_facet({sections:[
{
section: 'details',
name: 'details',
fields:['krbprincipalname',
{
factory:IPA.service_name_widget,
@ -54,7 +54,7 @@ IPA.entity_factories.service = function() {
}]
},
{
section : 'provisioning',
name: 'provisioning',
fields:[{
factory:IPA.service_provisioning_status_widget,
name: 'provisioning_status',
@ -62,19 +62,20 @@ IPA.entity_factories.service = function() {
}]
},
{
section: 'certificate',
name: 'certificate',
fields:[{
factory:IPA.service_certificate_status_widget,
name: 'certificate_status',
label: IPA.messages.objects.service.status
}]
}]).
}]}).
facet(IPA.service_managedby_host_facet({
name: 'managedby_host',
add_method: 'add_host',
remove_method: 'remove_host'
})).
standard_associations().build();
standard_association_facets().
build();
};

View File

@ -44,14 +44,14 @@ IPA.entity_factories.sudocmd = function () {
search_facet({
columns:['sudocmd','description'],
add_fields:['sudocmd','description']}).
details_facet([
details_facet({sections:[
{
section : 'general',
name: 'general',
label: IPA.messages.details.general,
fields:['sudocmd','description']
},
{
section: 'groups',
name: 'groups',
label: IPA.messages.objects.sudocmd.groups,
factory: IPA.details_section,
fields:[{
@ -84,7 +84,7 @@ IPA.entity_factories.sudocmd = function () {
}
]
}]
}]).
}]}).
build();
};
@ -96,15 +96,15 @@ IPA.entity_factories.sudocmdgroup = function () {
columns:['cn','description'],
add_fields:['cn','description']
}).
details_facet([
details_facet({sections:[
{
section: 'general',
name: 'general',
label: IPA.messages.dialogs.general,
fields:['cn','description']
},
{
section: 'commands',
name: 'commands',
factory: IPA.details_section,
fields: [{
factory: IPA.association_table_widget,
@ -136,7 +136,7 @@ IPA.entity_factories.sudocmdgroup = function () {
}
]
}]
}]).
}]}).
build();
};

View File

@ -29,11 +29,6 @@ module('details', {
"data",
true,
function(data, text_status, xhr) {
IPA.metadata = data.result.results[0];
IPA.messages = data.result.results[1].messages;
IPA.whoami = data.result.results[2].result[0];
IPA.env = data.result.results[3].result;
IPA.dns_enabled = data.result.results[4].result;
},
function(xhr, text_status, error_thrown) {
ok(false, "ipa_init() failed: "+error_thrown);
@ -181,14 +176,14 @@ test("Testing details lifecycle: create, setup, load.", function(){
var entity = IPA.
entity_builder().
entity('user').
details_facet([
details_facet({sections:[
{
section: 'identity',
name: 'identity',
label: IPA.messages.details.identity,
fields:['title','givenname','sn','cn','displayname', 'initials']
},
{
section: 'contact',
name: 'contact',
label:'contact',
fields:
[ {factory: test_widget,name:'test'},
@ -200,7 +195,7 @@ test("Testing details lifecycle: create, setup, load.", function(){
{factory: IPA.multivalued_text_widget,
name:'facsimiletelephonenumber'}]
},
]).build();
]}).build();
entity.init();
var facet = entity.get_facet('details');

View File

@ -30,11 +30,6 @@ module('entity',{
"data",
true,
function(data, text_status, xhr) {
IPA.metadata = data.result.results[0];
IPA.messages = data.result.results[1].messages;
IPA.whoami = data.result.results[2].result[0];
IPA.env = data.result.results[3].result;
IPA.dns_enabled = data.result.results[4].result;
IPA.entity_factories.user = function(){
return IPA.

View File

@ -33,21 +33,21 @@ IPA.entity_factories.user = function() {
add_fields: ['uid','givenname','sn'],
search_all: true
}).
details_facet([
details_facet({sections:[
{
section: 'identity',
name: 'identity',
label: IPA.messages.details.identity,
fields:['title','givenname','sn','cn','displayname', 'initials']
},
{
section: 'account',
name: 'account',
fields:[{factory:IPA.user_status_widget,name:'nsaccountlock'},
'uid',
{factory: IPA.user_password_widget,name:'userpassword'},
'uidnumber','gidnumber','loginshell','homedirectory']
},
{
section: 'contact',
name: 'contact',
fields:
[ {factory: IPA.multivalued_text_widget, name:'mail'},
{factory: IPA.multivalued_text_widget, name:'telephonenumber'},
@ -56,17 +56,17 @@ IPA.entity_factories.user = function() {
{factory: IPA.multivalued_text_widget, name:'facsimiletelephonenumber'}]
},
{
section: 'mailing',
name: 'mailing',
fields: ['street','l','st','postalcode']
},
{
section: 'employee',
name: 'employee',
fields: ['ou','manager']
},
{
section: 'misc',
name: 'misc',
fields:['carlicense']
}]).
}]}).
association_facet({
name: 'memberof_group',
associator: IPA.serial_associator
@ -79,7 +79,7 @@ IPA.entity_factories.user = function() {
name: 'memberof_role',
associator: IPA.serial_associator
}).
standard_associations();
standard_association_facets();
var entity = builder.build();