declarative defintions

Delay the creation of entities until after ipa init is called
made the user and group entity definitions declarative
removed unused facet from groups
adjusted unit tests

made review changes:

factories are now in an associative array
entity init called right after factory
init dialogs in entity init
fixed type on search
This commit is contained in:
Adam Young 2011-01-19 21:10:18 -05:00
parent 442d6ad30c
commit f904df0f0d
24 changed files with 310 additions and 368 deletions

View File

@ -561,7 +561,7 @@ IPA.target_section = function () {
};
IPA.permission = function () {
IPA.entity_factories.permission = function () {
var that = IPA.entity({
'name': 'permission'
@ -593,9 +593,6 @@ IPA.permission = function () {
};
IPA.add_entity(IPA.permission());
IPA.permission_add_dialog = function (spec) {
@ -675,7 +672,7 @@ IPA.permission_details_facet = function () {
};
IPA.add_entity( function() {
IPA.entity_factories.privilege = function() {
var that = IPA.entity({
'name': 'privilege'
});
@ -715,10 +712,10 @@ IPA.add_entity( function() {
that.entity_init();
};
return that;
}());
};
IPA.add_entity( function() {
IPA.entity_factories.role = function() {
var that = IPA.entity({
'name': 'role'
});
@ -756,10 +753,10 @@ IPA.add_entity( function() {
that.entity_init();
};
return that;
}());
};
IPA.add_entity( function() {
IPA.entity_factories.selfservice = function() {
var that = IPA.entity({
'name': 'selfservice'
});
@ -783,7 +780,8 @@ IPA.add_entity( function() {
that.init = function() {
that.add_section(
IPA.stanza({name:'general', label:'General'}).
IPA.stanza({name:'general', label:'General',
entity_name:'selfservice'}).
input({name:'aciname'}).
custom_input(IPA.attribute_table_widget({
object_type:'user',
@ -793,7 +791,6 @@ IPA.add_entity( function() {
return that;
}());
that.parent_init = that.init;
that.init = function(){
that.parent_init();
@ -810,10 +807,10 @@ IPA.add_entity( function() {
dialog.init();
};
return that;
}());
};
IPA.add_entity( function() {
IPA.entity_factories.delegation = function() {
var that = IPA.entity({
'name': 'delegation'
});
@ -870,4 +867,5 @@ IPA.add_entity( function() {
};
return that;
}());
};

View File

@ -485,6 +485,7 @@ IPA.stanza = function (spec) {
IPA.details_facet = function (spec) {
spec = spec || {};
spec.name = spec.name || 'details';
var that = IPA.facet(spec);
@ -498,8 +499,6 @@ IPA.details_facet = function (spec) {
that.refresh = spec.refresh || IPA.details_refresh;
that.sections = [];
that.sections_by_name = {};
that.__defineGetter__("entity_name", function(){
return that._entity_name;
});
@ -512,17 +511,17 @@ IPA.details_facet = function (spec) {
}
});
that.get_section = function(name) {
return that.sections_by_name[name];
};
that.add_section = function(section) {
section.entity_name = that.entity_name;
that.sections.push(section);
that.sections_by_name[section.name] = section;
return section;
};
that.section = function(section) {
that.add_section(section);
return that;
};
that.create_section = function(spec) {
var section = IPA.details_section(spec);
that.add_section(section);

View File

@ -110,8 +110,17 @@ IPA.entity = function (spec) {
dialog.entity_name = that.name;
that.dialogs.push(dialog);
that.dialogs_by_name[dialog.name] = dialog;
return that;
};
function init_dialogs (){
var i;
for (i = 0; i < that.dialogs.length; i += 1){
that.dialogs[i].init();
}
return that;
}
that.get_facet = function(name) {
return that.facets_by_name[name];
};
@ -120,6 +129,14 @@ IPA.entity = function (spec) {
facet.entity_name = that.name;
that.facets.push(facet);
that.facets_by_name[facet.name] = facet;
return that;
};
that.facet = function(facet) {
facet.entity_name = that.name;
that.facets.push(facet);
that.facets_by_name[facet.name] = facet;
return that;
};
that.get_associations = function() {
@ -141,6 +158,13 @@ IPA.entity = function (spec) {
return config;
};
that.association = function(spec) {
var config = IPA.association_config(spec);
that.add_association(config);
return that;
};
that.create_association_facet = function(attribute_member, other_entity, label, facet_group) {
if (!attribute_member) {
@ -190,8 +214,12 @@ IPA.entity = function (spec) {
that.add_facet(facet);
}
}
return that;
};
that.standard_associations = that.create_association_facets;
that.init = function() {
if (!that.label) {
@ -206,6 +234,7 @@ IPA.entity = function (spec) {
var facet = that.facets[i];
facet.init();
}
init_dialogs();
};
that.entity_init = that.init;
@ -221,6 +250,7 @@ var window_hash_cache = {};
IPA.fetch_entity = function (entity_name) {
var entity = IPA.get_entity(entity_name);
/*
if (entity) return entity;
entity = IPA.entity({
@ -228,6 +258,7 @@ IPA.fetch_entity = function (entity_name) {
});
IPA.add_entity(entity);
*/
return entity;
};
@ -264,30 +295,6 @@ IPA.entity_set_search_definition = function (entity_name, data) {
};
IPA.entity_set_add_definition = function (entity_name, data) {
var entity = IPA.fetch_entity(entity_name);
var dialog = IPA.add_dialog({
'name': 'add',
'title': data[1]
});
entity.add_dialog(dialog);
for (var i=0; i<data[2].length; i++) {
var field = data[2][i];
dialog.add_field(IPA.text_widget({
name: field[0],
label: field[1],
setup: field[2],
undo: false
}));
}
dialog.init();
};
IPA.entity_get_add_dialog = function (entity_name) {
var entity = IPA.fetch_entity(entity_name);

View File

@ -2,6 +2,8 @@
/* Authors:
* Pavel Zuna <pzuna@redhat.com>
* Endi Dewata <edewata@redhat.com>
* Adam Young <ayoung@redhat.com>
*
* Copyright (C) 2010 Red Hat
* see file 'COPYING' for use and warranty information
@ -22,123 +24,53 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
IPA.group = function () {
IPA.entity_factories.group = function () {
var that = IPA.entity({
return IPA.entity({
'name': 'group'
});
that.init = function() {
that.create_association({
}).
facet(IPA.search_facet().
column({name:'cn'}).
column({name:'gidnumber'}).
column({name:'description'})).
facet(
IPA.details_facet().section(
IPA.stanza({label: 'Group Settings' }).
input({name: 'cn' }).
input({name: 'description'}).
input({name: 'gidnumber' }))).
facet( IPA.group_member_user_facet({
'name': 'member_user',
'label': 'Users',
'other_entity': 'user'
})).
association({
name: 'netgroup',
associator: 'serial'
});
that.create_association({
}).
association({
name: 'rolegroup',
associator: 'serial'
});
that.create_association({
}).
association({
name: 'taskgroup',
associator: 'serial'
});
var dialog = IPA.group_add_dialog({
'name': 'add',
'title': 'Add New Group'
});
that.add_dialog(dialog);
dialog.init();
var facet = IPA.group_search_facet({
'name': 'search',
'label': 'Search'
});
that.add_facet(facet);
facet = IPA.group_details_facet({
'name': 'details'
});
that.add_facet(facet);
that.create_association_facets();
that.entity_init();
};
return that;
};
IPA.add_entity(IPA.group());
IPA.group_add_dialog = function (spec) {
spec = spec || {};
var that = IPA.add_dialog(spec);
that.init = function() {
that.add_field(IPA.text_widget({name:'cn', undo: false}));
that.add_field(IPA.text_widget({name:'description', undo: false}));
// TODO: Replace with i18n label
that.add_field(IPA.checkbox_widget({
name:'posix',
label:'Is this a POSIX group?',
undo: false,
checked:'checked'}));
that.add_field(IPA.text_widget({name:'gidnumber', undo: false}));
that.add_dialog_init();
};
return that;
};
IPA.group_search_facet = function (spec) {
spec = spec || {};
var that = IPA.search_facet(spec);
that.init = function() {
that.create_column({name:'cn'});
that.create_column({name:'gidnumber'});
that.create_column({name:'description'});
that.search_facet_init();
};
return that;
};
IPA.group_details_facet = function (spec) {
spec = spec || {};
var that = IPA.details_facet(spec);
that.init = function() {
var section = IPA.details_list_section({
name: 'details',
label: 'Group Settings'
});
that.add_section(section);
section.create_field({name: 'cn' });
section.create_field({name: 'description'});
section.create_field({name: 'gidnumber' });
that.details_facet_init();
};
return that;
}).
add_dialog(
IPA.add_dialog({
'name': 'add',
'title': 'Add New Group'
}).
field(IPA.text_widget({name:'cn', undo: false})).
field(IPA.text_widget({name:'description', undo: false})).
// TODO: Replace with i18n label
field(IPA.checkbox_widget({
name:'posix',
label:'Is this a POSIX group?',
undo: false,
checked:'checked'})).
field(IPA.text_widget({name:'gidnumber', undo: false}))).
standard_associations();
};
@ -198,4 +130,5 @@ IPA.group_member_user_facet = function (spec) {
};
return that;
};
};

View File

@ -22,7 +22,7 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
IPA.hbacrule = function () {
IPA.entity_factories.hbacrule = function () {
var that = IPA.entity({
'name': 'hbacrule'
@ -35,7 +35,7 @@ IPA.hbacrule = function () {
'title': 'Add New Rule'
});
that.add_dialog(dialog);
dialog.init();
var facet = IPA.hbacrule_search_facet({
'name': 'search',
@ -55,7 +55,6 @@ IPA.hbacrule = function () {
};
IPA.add_entity(IPA.hbacrule());
IPA.hbacrule_add_dialog = function (spec) {

View File

@ -22,7 +22,7 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
IPA.hbacsvc = function () {
IPA.entity_factories.hbacsvc = function () {
var that = IPA.entity({
'name': 'hbacsvc'
@ -35,8 +35,7 @@ IPA.hbacsvc = function () {
'title': 'Add New HBAC Service'
});
that.add_dialog(dialog);
dialog.init();
var facet = IPA.hbacsvc_search_facet({
'name': 'search',
'label': 'Search'
@ -55,8 +54,6 @@ IPA.hbacsvc = function () {
};
IPA.add_entity(IPA.hbacsvc());
IPA.hbacsvc_add_dialog = function (spec) {

View File

@ -22,7 +22,7 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
IPA.hbacsvcgroup = function () {
IPA.entity_factories.hbacsvcgroup = function () {
var that = IPA.entity({
'name': 'hbacsvcgroup'
@ -41,8 +41,7 @@ IPA.hbacsvcgroup = function () {
'title': 'Add New HBAC Service Group'
});
that.add_dialog(dialog);
dialog.init();
var facet = IPA.hbacsvcgroup_search_facet({
'name': 'search',
'label': 'Search'
@ -61,9 +60,6 @@ IPA.hbacsvcgroup = function () {
};
IPA.add_entity(IPA.hbacsvcgroup());
IPA.hbacsvcgroup_add_dialog = function (spec) {
spec = spec || {};

View File

@ -24,7 +24,7 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
IPA.host = function () {
IPA.entity_factories.host = function () {
var that = IPA.entity({
'name': 'host'
@ -47,7 +47,6 @@ IPA.host = function () {
'title': 'Add New Host'
});
that.add_dialog(dialog);
dialog.init();
var facet = IPA.host_search_facet({
'name': 'search',
@ -76,9 +75,6 @@ IPA.host = function () {
};
IPA.add_entity(IPA.host());
IPA.host_add_dialog = function (spec) {
spec = spec || {};

View File

@ -23,7 +23,7 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
IPA.add_entity( function() {
IPA.entity_factories.hostgroup = function() {
var that = IPA.entity({
'name': 'hostgroup'
});
@ -55,13 +55,11 @@ IPA.add_entity( function() {
dialog.add_field(IPA.text_widget({name: 'cn', undo: false}));
dialog.add_field(IPA.text_widget({name: 'description', undo: false}));
dialog.init();
that.create_association_facets();
that.entity_init();
};
return that;
}());
};

View File

@ -49,6 +49,8 @@ var IPA = ( function () {
that.entities = [];
that.entity_factories = {};
that.entities_by_name = {};
that.error_dialog = $('<div/>', {
@ -113,11 +115,21 @@ var IPA = ( function () {
return that.entities_by_name[name];
};
that.add_entity = function (entity) {
function add_entity(entity) {
that.entities.push(entity);
that.entities_by_name[entity.name] = entity;
};
}
that.start_entities = function(){
var factory;
var name ;
for (name in that.entity_factories){
factory = that.entity_factories[name];
var entity = factory();
add_entity(entity);
entity.init();
}
};
that.show_page = function (entity_name, facet_name) {

View File

@ -22,7 +22,7 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
IPA.add_entity( function() {
IPA.entity_factories.netgroup = function() {
var that = IPA.entity({
'name': 'netgroup'
});
@ -55,13 +55,12 @@ IPA.add_entity( function() {
dialog.add_field(IPA.text_widget({ name: 'cn', undo: false}));
dialog.add_field(IPA.text_widget({ name: 'description', undo: false}));
dialog.init();
that.create_association_facets();
that.entity_init();
};
return that;
}());
};

View File

@ -24,8 +24,7 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
/* DNS */
IPA.add_entity(function (){
IPA.entity_factories.dnszone = function() {
var that = IPA.entity({
name: 'dnszone'
});
@ -74,15 +73,14 @@ IPA.add_entity(function (){
dialog.add_field(IPA.text_widget({ name: 'idnsname', undo: false}));
dialog.add_field(IPA.text_widget({ name: 'idnssoamname', undo: false}));
dialog.add_field(IPA.text_widget({ name: 'idnssoarname', undo: false}));
dialog.init();
that.create_association_facets();
that.entity_init();
};
return that;
}());
};
IPA.records_facet = function (spec){
@ -418,7 +416,6 @@ IPA.records_facet = function (spec){
options.data = data_filter;
}
var pkey = $.bbq.getState(that.entity_name + '-pkey', true);
IPA.cmd('dnsrecord_find',[pkey],options,load_on_win, load_on_fail);
@ -499,7 +496,7 @@ IPA.records_facet = function (spec){
/**Automount*/
IPA.add_entity(function (){
IPA.entity_factories.automountlocation = function (){
var that = IPA.entity({
name: 'automountlocation'
});
@ -530,20 +527,19 @@ IPA.add_entity(function (){
that.add_dialog(dialog);
dialog.add_field(IPA.text_widget({ name: 'cn', undo: false}));
dialog.init();
that.create_association_facets();
that.entity_init();
};
return that;
}());
};
/**pwpolicy*/
IPA.add_entity(function (){
IPA.entity_factories.pwpolicy = function() {
var that = IPA.entity({
name: 'pwpolicy'
});
@ -580,14 +576,13 @@ IPA.add_entity(function (){
that.add_dialog(dialog);
dialog.add_field(IPA.text_widget({ name: 'cn', undo: false}));
dialog.init();
that.create_association_facets();
that.entity_init();
};
return that;
}());
};
@ -595,13 +590,19 @@ IPA.add_entity(function (){
krbtpolicy
Does not have search
*/
IPA.entity_factories.krbtpolicy = function() {
var that = IPA.entity({
name: 'krbtpolicy'
});
IPA.entity_set_details_definition('krbtpolicy', [
IPA.stanza({name:'identity', label:'Kerberos ticket policy'}).
//input({name:'uid',label:' '}).
input({name:'krbmaxrenewableage'}).
input({name:'krbmaxticketlife'})
]);
IPA.entity_set_association_definition('krbtpolicy', {
});
var details = IPA.details_facet({
'name': 'details'
});
details.add_section(
IPA.stanza({name:'identity', label:'Kerberos ticket policy'}).
//input({name:'uid',label:' '}).
input({name:'krbmaxrenewableage'}).
input({name:'krbmaxticketlife'}));
that.add_facet(details);
return that;
};

View File

@ -254,6 +254,10 @@ IPA.search_facet = function (spec) {
spec = spec || {};
spec.name = spec.name || 'search';
spec.label = spec.label || IPA.messages.facets.search;
spec.display_class = 'search-facet';
var that = IPA.facet(spec);
@ -298,6 +302,11 @@ IPA.search_facet = function (spec) {
return column;
};
that.column = function(spec){
that.create_column(spec);
return that;
};
that.setup_column = function(column) {
column.setup = function(container, record) {
container.empty();

View File

@ -26,18 +26,29 @@
/* Configuration */
IPA.entity_set_details_definition('config',[
IPA.stanza({name:'ipaserver', label:'Configuration'}).
input({name:'cn', label:'Name'}).
input({name:'ipacertificatesubjectbase'}).
input({name:'ipadefaultloginshell'}).
input({name:'ipadefaultprimarygroup'}).
input({name:'ipagroupsearchfields'}).
input({name:'ipahomesrootdir'}).
input({name:'ipamaxusernamelength'}).
input({name:'ipamigrationenabled'}).
input({name:'ipasearchrecordslimit'}).
input({name:'ipasearchtimelimit'}).
input({name:'ipausersearchfields'})
]);
IPA.entity_factories.config = function(){
var that = IPA.entity({
name: 'config'
});
var details = IPA.details_facet();
details.add_section(
IPA.stanza({name:'ipaserver', label:'Configuration'}).
input({name:'cn', label:'Name'}).
input({name:'ipacertificatesubjectbase'}).
input({name:'ipadefaultloginshell'}).
input({name:'ipadefaultprimarygroup'}).
input({name:'ipagroupsearchfields'}).
input({name:'ipahomesrootdir'}).
input({name:'ipamaxusernamelength'}).
input({name:'ipamigrationenabled'}).
input({name:'ipasearchrecordslimit'}).
input({name:'ipasearchtimelimit'}).
input({name:'ipausersearchfields'}));
that.add_facet(details);
return that;
};

View File

@ -23,7 +23,7 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
IPA.service = function () {
IPA.entity_factories.service = function () {
var that = IPA.entity({
'name': 'service'
@ -42,7 +42,6 @@ IPA.service = function () {
'title': 'Add New Service'
});
that.add_dialog(dialog);
dialog.init();
var facet = IPA.service_search_facet({
'name': 'search',
@ -69,9 +68,6 @@ IPA.service = function () {
};
IPA.add_entity(IPA.service());
IPA.service_add_dialog = function (spec) {
spec = spec || {};

View File

@ -22,7 +22,7 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
IPA.sudocmd = function () {
IPA.entity_factories.sudocmd = function () {
var that = IPA.entity({
'name': 'sudocmd'
@ -35,7 +35,6 @@ IPA.sudocmd = function () {
'title': 'Add New SUDO Command'
});
that.add_dialog(dialog);
dialog.init();
var facet = IPA.sudocmd_search_facet({
'name': 'search',
@ -55,9 +54,6 @@ IPA.sudocmd = function () {
};
IPA.add_entity(IPA.sudocmd());
IPA.sudocmd_add_dialog = function (spec) {
spec = spec || {};

View File

@ -22,7 +22,7 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
IPA.sudocmdgroup = function () {
IPA.entity_factories.sudocmdgroup = function () {
var that = IPA.entity({
'name': 'sudocmdgroup'
@ -41,8 +41,7 @@ IPA.sudocmdgroup = function () {
'title': 'Add New SUDO Command Group'
});
that.add_dialog(dialog);
dialog.init();
var facet = IPA.sudocmdgroup_search_facet({
'name': 'search',
'label': 'Search'
@ -61,9 +60,6 @@ IPA.sudocmdgroup = function () {
};
IPA.add_entity(IPA.sudocmdgroup());
IPA.sudocmdgroup_add_dialog = function (spec) {
spec = spec || {};

View File

@ -22,7 +22,7 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
IPA.sudorule = function () {
IPA.entity_factories.sudorule = function () {
var that = IPA.entity({
'name': 'sudorule'
@ -35,7 +35,6 @@ IPA.sudorule = function () {
'title': 'Add New Rule'
});
that.add_dialog(dialog);
dialog.init();
var facet = IPA.sudorule_search_facet({
'name': 'search',
@ -55,9 +54,6 @@ IPA.sudorule = function () {
};
IPA.add_entity(IPA.sudorule());
IPA.sudorule_add_dialog = function (spec) {
spec = spec || {};

View File

@ -19,7 +19,19 @@
*/
module('details');
module('details', {
setup: function() {
var obj_name = 'user';
IPA.register_entity(
function(){
return IPA.entity({name:obj_name});
});
IPA.start_entities();
},
teardown: function() {
}
});
test("Testing IPA.details_section.create().", function() {
@ -146,7 +158,10 @@ test("Testing details lifecycle: create, setup, load.", function(){
}
var container = $("<div/>");
var obj_name = 'user';
IPA.entity_set_details_definition(obj_name, [
IPA.stanza({name:'identity', label:'Identity Details'}).
input({name:'title'}).

View File

@ -18,7 +18,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
module('entity');
module('entity',{
setup: function() {
IPA.register_entity(function(){return IPA.entity({name:'user'})});
IPA.start_entities();
},
teardown: function() {
}
});
test('Testing IPA.entity_set_search_definition().', function() {
@ -79,19 +86,25 @@ test('Testing ipa_facet_setup_views().', function() {
}
);
var entity = IPA.entity({
'name': 'user'
IPA.register_entity(function(){
var entity = IPA.entity({
'name': 'user'
});
return entity;
});
IPA.add_entity(entity);
IPA.start_entities();
var facet = IPA.search_facet({
'name': 'search',
'label': 'Search'
});
entity.add_facet(facet);
var entity = IPA.get_entity('user');
var facet = IPA.search_facet({
'name': 'search',
'label': 'Search'
});
entity.add_facet(facet);
entity.create_association_facets();
entity.create_association_facets();
var container = $('<div/>');
@ -167,5 +180,3 @@ test('Testing ipa_facet_setup_views().', function() {
IPA.switch_and_show_page = orig_switch_and_show_page;
});

View File

@ -23,28 +23,36 @@ module('navigation');
test("Testing nav_create().", function() {
var mock_tabs_lists =
[
{ name:'identity', label:'IDENTITY', children: [
{name:'user', entity:'user'},
{name:'group', entity:'group'}
]}];
var mock_tabs_lists = [
{ name:'identity', label:'IDENTITY', children: [
{name:'user', entity:'user'},
{name:'group', entity:'group'}
]}];
var entity = IPA.entity({name: 'user'});
entity.setup = function(container){
user_mock_called = true;
same(container[0].id,'user','user id');
same(container[0].nodeName,'DIV','user div');
};
IPA.add_entity(entity);
var entity;
entity = IPA.entity({name: 'group'});
entity.setup = function(container){
group_mock_called = true;
same(container[0].id,'group','group id');
same(container[0].nodeName,'DIV','group Div');
};
IPA.add_entity(entity);
IPA.register_entity( function() {
var that = IPA.entity({name: 'user'});
that.setup = function(container){
user_mock_called = true;
same(container[0].id,'user','user id');
same(container[0].nodeName,'DIV','user div');
}
return that;
});
IPA.register_entity( function(){
var that = IPA.entity({name: 'group'});
that.setup = function(container){
group_mock_called = true;
same(container[0].id,'group','group id');
same(container[0].nodeName,'DIV','group Div');
};
return that;
});
IPA.start_entities();
IPA.metadata = {};
var navigation = $('<div id="navigation"/>').appendTo(document.body);

View File

@ -2,6 +2,7 @@
/* Authors:
* Pavel Zuna <pzuna@redhat.com>
* Adam Young <ayoung@redhat.com>
*
* Copyright (C) 2010 Red Hat
* see file 'COPYING' for use and warranty information
@ -22,108 +23,76 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
IPA.user = function (){
IPA.entity_factories.user = function (){
var that = IPA.entity({
return IPA.entity({
name: 'user'
});
that.init = function() {
that.create_association({
}).
association({
'name': 'group',
'associator': 'serial'
});
that.create_association({
}).
association({
'name': 'netgroup',
'associator': 'serial'
});
var search_facet = IPA.search_facet({
'name': 'search',
'label': 'Search',
entity_name: that.name
});
that.add_facet(search_facet);
search_facet.create_column({name:'cn'});
search_facet.create_column({name:'uid'});
search_facet.create_column({name:'uidnumber'});
search_facet.create_column({name:'mail'});
search_facet.create_column({name:'telephonenumber'});
search_facet.create_column({name:'title'});
that.add_facet(details_facet({name:'details'}));
var dialog = IPA.add_dialog({
'name': 'add',
'title': 'Add User'
});
that.add_dialog(dialog);
dialog.add_field(IPA.text_widget({ name: 'uid', undo: false }));
dialog.add_field(IPA.text_widget({ name: 'givenname', undo: false }));
dialog.add_field(IPA.text_widget({ name: 'sn', undo: false }));
dialog.init();
/*eventually, we need to call
entity.create_association_facets();
but we are currently defining the associator using the global
function after the registration of the entity */
that.create_association_facets();
that.entity_init();
};
function details_facet(spec) {
spec = spec || {};
var that = IPA.details_facet(spec);
var sections =[
IPA.stanza({name:'identity', label:IPA.messages.details.identity}).
}).
facet(
IPA.search_facet().
column({name:'cn'}).
column({name:'uid'}).
column({name:'uidnumber'}).
column({name:'mail'}).
column({name:'telephonenumber'}).
column({name:'title'})).
facet(IPA.details_facet().
section(
IPA.stanza({label:IPA.messages.details.identity}).
input({name:'title'}).
input({name:'givenname'}).
input({name:'sn'}).
input({name:'cn'}).
input({name:'displayname'}).
input({name:'initials'}),
IPA.stanza({name:'account', label:IPA.messages.details.account}).
custom_input(user_status_widget({name:'nsaccountlock'})).
input({name:'uid'}).
input({name:'userpassword', load: user_password_load}).
input({name:'uidnumber'}).
input({name:'gidnumber'}).
input({name:'loginshell'}).
input({name:'homedirectory'}),
IPA.stanza({name:'contact', label:IPA.messages.details.contact}).
input({name:'mail'}).
input({name:'telephonenumber'}).
input({name:'pager'}).
input({name:'mobile'}).
input({name:'facsimiletelephonenumber'}),
IPA.stanza({name:'address', label: IPA.messages.details.mailing}).
input({name:'street'}).
input({name:'location'}).
input({name:'state', load:user_state_load}).
input({name:'postalcode'}),
IPA.stanza({name:'employee', label:IPA.messages.details.employee}).
input({name:'ou', label:'Org. Unit'}).
input({name:'manager'}),
IPA.stanza({name:'misc', label:IPA.messages.details.misc}).
input({name:'carlicense'})
];
for (var i = 0; i < sections.length; i += 1){
that.add_section(sections[i]);
}
return that;
}
return that;
input({name:'initials'})).
section(
IPA.stanza({label:IPA.messages.details.account}).
custom_input(user_status_widget({name:'nsaccountlock'})).
input({name:'uid'}).
input({name:'userpassword', load: user_password_load}).
input({name:'uidnumber'}).
input({name:'gidnumber'}).
input({name:'loginshell'}).
input({name:'homedirectory'})).
section(
IPA.stanza({label:IPA.messages.details.contact}).
input({name:'mail'}).
input({name:'telephonenumber'}).
input({name:'pager'}).
input({name:'mobile'}).
input({name:'facsimiletelephonenumber'})).
section(
IPA.stanza({label: IPA.messages.details.mailing}).
input({name:'street'}).
input({name:'location'}).
input({name:'state', load:user_state_load}).
input({name:'postalcode'})).
section(
IPA.stanza({label:IPA.messages.details.employee}).
input({name:'ou', label:'Org. Unit'}).
input({name:'manager'})).
section(
IPA.stanza({label:IPA.messages.details.misc}).
input({name:'carlicense'}))).
standard_associations().
add_dialog(
IPA.add_dialog({
'name': 'add',
'title': 'Add User'
}).
field(IPA.text_widget({ name: 'uid', undo: false })).
field(IPA.text_widget({ name: 'givenname', undo: false })).
field(IPA.text_widget({ name: 'sn', undo: false })));
};
IPA.add_entity(IPA.user());
/* ATTRIBUTE CALLBACKS */
@ -294,5 +263,3 @@ function user_state_load(result) {
else
sel.val('');
}

View File

@ -135,10 +135,7 @@ $(function() {
$('#loggedinas a').fragment(
{'user-facet':'details', 'user-pkey':IPA.whoami_pkey},2);
for (var i=0; i<IPA.entities.length; i++) {
var entity = IPA.entities[i];
entity.init();
}
IPA.start_entities();
var navigation = $('#navigation');

View File

@ -58,7 +58,7 @@ IPA.widget = function(spec) {
});
/*returns true and clears the error message if the field value passes
the validation pattern. If the field value does not pass validation,
the validation pattern. If the field value does not pass validation,
displays the error message and returns false. */
function validate_input(text) {
if (!(that.param_info && that.param_info.pattern)) {
@ -898,6 +898,11 @@ IPA.dialog = function(spec) {
that.fields_by_name[field.name] = field;
};
that.field = function(field){
that.add_field(field);
return that;
};
that.init = function() {
for (var i=0; i<that.fields.length; i++) {
var field = that.fields[i];