From f904df0f0dfd4734f978cdc3ddf5badabc067ed6 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Wed, 19 Jan 2011 21:10:18 -0500 Subject: 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 --- install/ui/aci.js | 26 +++--- install/ui/details.js | 13 ++- install/ui/entity.js | 55 +++++++------ install/ui/group.js | 153 ++++++++++-------------------------- install/ui/hbacrule.js | 5 +- install/ui/hbacsvc.js | 7 +- install/ui/hbacsvcgroup.js | 8 +- install/ui/host.js | 6 +- install/ui/hostgroup.js | 6 +- install/ui/ipa.js | 16 +++- install/ui/netgroup.js | 5 +- install/ui/policy.js | 43 +++++----- install/ui/search.js | 9 +++ install/ui/serverconfig.js | 41 ++++++---- install/ui/service.js | 6 +- install/ui/sudocmd.js | 6 +- install/ui/sudocmdgroup.js | 8 +- install/ui/sudorule.js | 6 +- install/ui/test/details_tests.js | 17 +++- install/ui/test/entity_tests.js | 35 ++++++--- install/ui/test/navigation_tests.js | 52 ++++++------ install/ui/user.js | 149 ++++++++++++++--------------------- install/ui/webui.js | 5 +- install/ui/widget.js | 7 +- 24 files changed, 313 insertions(+), 371 deletions(-) (limited to 'install') diff --git a/install/ui/aci.js b/install/ui/aci.js index b1ac1d529..f7d7266f5 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -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; -}()); + +}; diff --git a/install/ui/details.js b/install/ui/details.js index aad77a9c4..84a5c4098 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -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); diff --git a/install/ui/entity.js b/install/ui/entity.js index c5c423dba..8d39b8e79 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -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 + * Endi Dewata + * Adam Young * * 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; -}; + +}; \ No newline at end of file diff --git a/install/ui/hbacrule.js b/install/ui/hbacrule.js index 8b354312d..6983e7923 100644 --- a/install/ui/hbacrule.js +++ b/install/ui/hbacrule.js @@ -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) { diff --git a/install/ui/hbacsvc.js b/install/ui/hbacsvc.js index dc0bc3230..c190c8cde 100644 --- a/install/ui/hbacsvc.js +++ b/install/ui/hbacsvc.js @@ -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) { diff --git a/install/ui/hbacsvcgroup.js b/install/ui/hbacsvcgroup.js index 2dd049cbe..381dcb0bc 100644 --- a/install/ui/hbacsvcgroup.js +++ b/install/ui/hbacsvcgroup.js @@ -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 || {}; diff --git a/install/ui/host.js b/install/ui/host.js index 422c87a77..453b61788 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -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 || {}; diff --git a/install/ui/hostgroup.js b/install/ui/hostgroup.js index 0525c05f2..b7d3e8d3c 100644 --- a/install/ui/hostgroup.js +++ b/install/ui/hostgroup.js @@ -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; -}()); +}; diff --git a/install/ui/ipa.js b/install/ui/ipa.js index 725bf17c5..406dce6d4 100644 --- a/install/ui/ipa.js +++ b/install/ui/ipa.js @@ -49,6 +49,8 @@ var IPA = ( function () { that.entities = []; + that.entity_factories = {}; + that.entities_by_name = {}; that.error_dialog = $('
', { @@ -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) { diff --git a/install/ui/netgroup.js b/install/ui/netgroup.js index 205673514..052008439 100644 --- a/install/ui/netgroup.js +++ b/install/ui/netgroup.js @@ -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; -}()); +}; diff --git a/install/ui/policy.js b/install/ui/policy.js index fedf40726..7f078a728 100644 --- a/install/ui/policy.js +++ b/install/ui/policy.js @@ -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; +}; diff --git a/install/ui/search.js b/install/ui/search.js index 934000b9f..b88de20a7 100644 --- a/install/ui/search.js +++ b/install/ui/search.js @@ -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(); diff --git a/install/ui/serverconfig.js b/install/ui/serverconfig.js index 6c0a824b4..dbf46df43 100644 --- a/install/ui/serverconfig.js +++ b/install/ui/serverconfig.js @@ -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; +}; \ No newline at end of file diff --git a/install/ui/service.js b/install/ui/service.js index e24088848..69b4777ca 100644 --- a/install/ui/service.js +++ b/install/ui/service.js @@ -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 || {}; diff --git a/install/ui/sudocmd.js b/install/ui/sudocmd.js index e398ae8fa..335bb3e44 100644 --- a/install/ui/sudocmd.js +++ b/install/ui/sudocmd.js @@ -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 || {}; diff --git a/install/ui/sudocmdgroup.js b/install/ui/sudocmdgroup.js index 6cb2b83dc..c0ce2aa08 100644 --- a/install/ui/sudocmdgroup.js +++ b/install/ui/sudocmdgroup.js @@ -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 || {}; diff --git a/install/ui/sudorule.js b/install/ui/sudorule.js index 427a368a8..ab4d9ab4f 100644 --- a/install/ui/sudorule.js +++ b/install/ui/sudorule.js @@ -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 || {}; diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js index d832bd26d..38609072f 100644 --- a/install/ui/test/details_tests.js +++ b/install/ui/test/details_tests.js @@ -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 = $("
"); + var obj_name = 'user'; + + IPA.entity_set_details_definition(obj_name, [ IPA.stanza({name:'identity', label:'Identity Details'}). input({name:'title'}). diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js index 21fff48f8..a5878a6ce 100644 --- a/install/ui/test/entity_tests.js +++ b/install/ui/test/entity_tests.js @@ -18,7 +18,14 @@ * along with this program. If not, see . */ -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.add_entity(entity); + IPA.register_entity(function(){ + var entity = IPA.entity({ + 'name': 'user' + }); - var facet = IPA.search_facet({ - 'name': 'search', - 'label': 'Search' + return entity; }); - entity.add_facet(facet); - entity.create_association_facets(); + IPA.start_entities(); + + var entity = IPA.get_entity('user'); + var facet = IPA.search_facet({ + 'name': 'search', + 'label': 'Search' + }); + entity.add_facet(facet); + entity.create_association_facets(); + var container = $('
'); @@ -167,5 +180,3 @@ test('Testing ipa_facet_setup_views().', function() { IPA.switch_and_show_page = orig_switch_and_show_page; }); - - diff --git a/install/ui/test/navigation_tests.js b/install/ui/test/navigation_tests.js index bc198ac0c..916259b41 100644 --- a/install/ui/test/navigation_tests.js +++ b/install/ui/test/navigation_tests.js @@ -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 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); - - 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); + var mock_tabs_lists = [ + { name:'identity', label:'IDENTITY', children: [ + {name:'user', entity:'user'}, + {name:'group', entity:'group'} + ]}]; + + var 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 = $('