From c3e065879056d85f0a769368c82b128a58c148e1 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Wed, 26 Jan 2011 13:46:49 -0500 Subject: declarative for aci A couple of the ACI definitions were incorrect, and the end result was that fields were not getting initialized. USing the declarative approach cleaned up the cause. Also fixed a few broken unit tests --- install/ui/aci.js | 340 ++++++++++-------------------------- install/ui/hbacrule.js | 2 +- install/ui/hbacsvc.js | 2 +- install/ui/hbacsvcgroup.js | 2 +- install/ui/serverconfig.js | 34 ++-- install/ui/test/details_tests.js | 6 +- install/ui/test/entity_tests.js | 11 +- install/ui/test/navigation_tests.js | 10 +- 8 files changed, 124 insertions(+), 283 deletions(-) (limited to 'install/ui') diff --git a/install/ui/aci.js b/install/ui/aci.js index f7d7266f5..1cc1611ca 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -457,9 +457,6 @@ IPA.target_section = function () { appendTo(dl); } - - - that.create = function(container) { var dl = $('
').appendTo(container); display_filter_target(dl); @@ -563,111 +560,35 @@ IPA.target_section = function () { IPA.entity_factories.permission = function () { - var that = IPA.entity({ + return IPA.entity({ 'name': 'permission' - }); - - that.init = function() { - - var dialog = IPA.permission_add_dialog({ + }).add_dialog( + IPA.add_dialog({ name: 'add', - title: 'Add New Permission', - entity_name: 'permission' - }); - that.add_dialog(dialog); - dialog.init(); - - var facet = IPA.permission_search_facet({ - name: 'search', - label: 'Search' - }); - that.add_facet(facet); - - facet = IPA.permission_details_facet(); - that.add_facet(facet); - - that.entity_init(); - }; - - return that; -}; - - - -IPA.permission_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 - })); - - that.add_field(IPA.rights_widget({name:'permissions'})); - that.add_field(IPA.hidden_widget({name:'filter','value':'objectClass=changethisvalue'})); - that.add_dialog_init(); - }; - - - return that; -}; - - -IPA.permission_search_facet = function (spec) { - - spec = spec || {}; - var that = IPA.search_facet(spec); - that.init = function() { - that.create_column({name:'cn'}); - that.create_column({name:'description'}); - that.search_facet_init(); - }; - return that; -}; - - -IPA.permission_details_facet = function () { - - var spec = { - name: 'details' - }; - var that = IPA.details_facet(spec); - - that.init = function() { - - var section = that.add_section(IPA.details_list_section({ - name:'identity',label:'Identity' })); - section.create_field({ name: 'cn', 'read_only': true }); - section.create_field({ name: 'description'}); - - that.rights_section = IPA.rights_section(); - that.add_section(that.rights_section); - - that.target_section = IPA.target_section(); - - that.add_section(that.target_section); - that.details_facet_init(); - }; - - that.superior_load = that.load; - - that.load = function(result) { - that.superior_load(result); - }; - - that.superior_update = that.update; - that.update = function(on_win, on_fail){ - that.superior_update(on_win, on_fail); - }; + title: 'Add New Permission' + }). + field(IPA.text_widget({ + name: 'cn', + undo: false + })). + field(IPA.text_widget({ + name: 'description', + undo: false + })). + field(IPA.rights_widget({name:'permissions'})). + field(IPA.hidden_widget( + {name:'filter','value':'objectClass=changethisvalue'}))). + facet(IPA.search_facet(). + column({name:'cn'}). + column({name:'description'})). + facet(IPA.details_facet({ name: 'details' }). + section( + IPA.stanza({ + name:'identity',label:'Identity' }). + input({ name: 'cn', 'read_only': true }). + input({ name: 'description'})). + section(IPA.rights_section()). + section(IPA.target_section())); return that; }; @@ -716,156 +637,89 @@ IPA.entity_factories.privilege = function() { IPA.entity_factories.role = function() { - var that = IPA.entity({ + return IPA.entity({ 'name': 'role' - }); - that.init = function() { - var search_facet = IPA.search_facet({ - name: 'search', - label: 'Search', - entity_name: that.name - }); - search_facet.create_column({name:'cn'}); - search_facet.create_column({name:'description'}); - that.add_facet(search_facet); - - that.add_facet(function() { - var that = IPA.details_facet({name:'details'}); - that.add_section( - IPA.stanza({name:'identity', label:'Role Settings'}). - input({name:'cn'}). - input({name: 'description'})); - return that; - }()); - - var dialog = IPA.add_dialog({ - name: 'add', - title: 'Add Role' - }); - that.add_dialog(dialog); - - 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; + }). + facet(IPA.search_facet(). + column({name:'cn'}). + column({name:'description'})). + facet( + IPA.details_facet({name:'details'}). + section( + IPA.stanza({name:'identity', label:'Role Settings'}). + input({name:'cn'}). + input({name: 'description'}))). + add_dialog( + IPA.add_dialog({ + name: 'add', + title: 'Add Role' + }). + field(IPA.text_widget({ name: 'cn', undo: false})). + field(IPA.text_widget({ name: 'description', undo: false}))). + standard_associations(); }; IPA.entity_factories.selfservice = function() { - var that = IPA.entity({ + return IPA.entity({ 'name': 'selfservice' - }); - - that.add_facet(function () { - var spec = { - name: 'search', - label: 'Search' - }; - var that = IPA.search_facet(spec); - that.init = function() { - that.create_column({name:'aciname'}); - that.search_facet_init(); - }; - return that; - }()); - - - that.add_facet(function(){ - var that = IPA.details_facet({'name':'details'}); - - that.init = function() { - that.add_section( - IPA.stanza({name:'general', label:'General', - entity_name:'selfservice'}). - input({name:'aciname'}). - custom_input(IPA.attribute_table_widget({ - object_type:'user', - name:'attrs' - }))); - }; - return that; - }()); - - that.parent_init = that.init; - that.init = function(){ - that.parent_init(); - var dialog = IPA.add_dialog({ - name: 'add', - title: 'Add Self Service Definition' - }); - that.add_dialog(dialog); - dialog.add_field(IPA.text_widget({ name: 'aciname', undo: false})); - dialog.add_field(IPA.attribute_table_widget({ - object_type:'user', - name:'attrs' - })); - dialog.init(); - }; - return that; + }). + facet(IPA.search_facet(). + column({name:'aciname'})). + facet( + IPA.details_facet({'name':'details'}). + section( + IPA.stanza({name:'general', label:'General'}). + input({name:'aciname'}). + custom_input(IPA.attribute_table_widget({ + object_type:'user', + name:'attrs' + })))). + add_dialog( + IPA.add_dialog({ + name: 'add', + title: 'Add Self Service Definition' + }). + field(IPA.text_widget({ name: 'aciname', undo: false})). + field(IPA.attribute_table_widget({ + object_type:'user', + name:'attrs' + }))); }; IPA.entity_factories.delegation = function() { var that = IPA.entity({ 'name': 'delegation' - }); - - that.add_facet(function () { - var spec = { - name: 'search', - label: 'Search' - }; - var that = IPA.search_facet(spec); - that.init = function() { - that.create_column({name:'aciname'}); - that.search_facet_init(); - }; - return that; - }()); - that.add_facet(function(){ - var that = IPA.details_facet({'name':'details'}); - var section = - IPA.stanza({name:'general', label:'General'}). - input({name:'aciname'}). - custom_input(IPA.entity_select_widget( - {name:'group', entity:'group'})). - custom_input(IPA.entity_select_widget( - {name:'memberof', entity:'group'})). - custom_input( - IPA.rights_widget({ - id:'delegation_rights'})). - custom_input( - IPA.attribute_table_widget({ - name:'attrs'})); - that.add_section(section); - return that; - }()); - - that.super_init = that.init; - that.init = function(){ - that.super_init(); - var dialog = IPA.add_dialog({ + }).facet( + IPA.search_facet(). + column({name:'aciname'})). + facet( + IPA.details_facet(). + section( + IPA.stanza({name:'general', label:'General'}). + input({name:'aciname'}). + custom_input(IPA.entity_select_widget( + {name:'group', entity:'group'})). + custom_input(IPA.entity_select_widget( + {name:'memberof', entity:'group'})). + custom_input( + IPA.rights_widget({ + id:'delegation_rights'})). + custom_input( + IPA.attribute_table_widget({ + name:'attrs'})))). + add_dialog(IPA.add_dialog({ name: 'add', - title: 'Add Delegation', - entity_name: that.entity - }); - that.add_dialog(dialog); - dialog.add_field(IPA.text_widget({ name: 'aciname', undo: false})); - dialog.add_field(IPA.entity_select_widget({name:'group', - entity:'group'})); - dialog.add_field(IPA.entity_select_widget({name:'memberof', - entity:'group'})); - dialog.add_field(IPA.attribute_table_widget({ name: 'attrs'})); - - dialog.init(); - that.create_association_facets(); - }; - + title: 'Add Delegation' + }). + field(IPA.text_widget({ name: 'aciname', undo: false})). + field(IPA.entity_select_widget({name:'group', + entity:'group'})). + field(IPA.entity_select_widget({name:'memberof', + entity:'group'})). + field(IPA.attribute_table_widget({ name: 'attrs'}))). + standard_associations(); return that; }; diff --git a/install/ui/hbacrule.js b/install/ui/hbacrule.js index 6983e7923..6b6e12381 100644 --- a/install/ui/hbacrule.js +++ b/install/ui/hbacrule.js @@ -35,7 +35,7 @@ IPA.entity_factories.hbacrule = function () { 'title': 'Add New Rule' }); that.add_dialog(dialog); - + var facet = IPA.hbacrule_search_facet({ 'name': 'search', diff --git a/install/ui/hbacsvc.js b/install/ui/hbacsvc.js index c190c8cde..f5104ce27 100644 --- a/install/ui/hbacsvc.js +++ b/install/ui/hbacsvc.js @@ -35,7 +35,7 @@ IPA.entity_factories.hbacsvc = function () { 'title': 'Add New HBAC Service' }); that.add_dialog(dialog); - + var facet = IPA.hbacsvc_search_facet({ 'name': 'search', 'label': 'Search' diff --git a/install/ui/hbacsvcgroup.js b/install/ui/hbacsvcgroup.js index 381dcb0bc..057c2364a 100644 --- a/install/ui/hbacsvcgroup.js +++ b/install/ui/hbacsvcgroup.js @@ -41,7 +41,7 @@ IPA.entity_factories.hbacsvcgroup = function () { 'title': 'Add New HBAC Service Group' }); that.add_dialog(dialog); - + var facet = IPA.hbacsvcgroup_search_facet({ 'name': 'search', 'label': 'Search' diff --git a/install/ui/serverconfig.js b/install/ui/serverconfig.js index dbf46df43..46e2e4856 100644 --- a/install/ui/serverconfig.js +++ b/install/ui/serverconfig.js @@ -31,24 +31,20 @@ 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); + }).facet( + IPA.details_facet(). + 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'}))); return that; }; \ No newline at end of file diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js index 38609072f..fb33808c7 100644 --- a/install/ui/test/details_tests.js +++ b/install/ui/test/details_tests.js @@ -22,11 +22,11 @@ module('details', { setup: function() { var obj_name = 'user'; - IPA.register_entity( + IPA.entity_factories.user= function(){ return IPA.entity({name:obj_name}); - }); - IPA.start_entities(); + }; + IPA.start_entities(); }, teardown: function() { } diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js index a5878a6ce..1178b99fa 100644 --- a/install/ui/test/entity_tests.js +++ b/install/ui/test/entity_tests.js @@ -20,7 +20,8 @@ module('entity',{ setup: function() { - IPA.register_entity(function(){return IPA.entity({name:'user'})}); + IPA.entity_factories.user = function(){ + return IPA.entity({name:'user'})}; IPA.start_entities(); }, teardown: function() { @@ -87,14 +88,6 @@ test('Testing ipa_facet_setup_views().', function() { ); - IPA.register_entity(function(){ - var entity = IPA.entity({ - 'name': 'user' - }); - - return entity; - }); - IPA.start_entities(); var entity = IPA.get_entity('user'); diff --git a/install/ui/test/navigation_tests.js b/install/ui/test/navigation_tests.js index 916259b41..9db0bb1cc 100644 --- a/install/ui/test/navigation_tests.js +++ b/install/ui/test/navigation_tests.js @@ -31,7 +31,7 @@ test("Testing nav_create().", function() { var entity; - IPA.register_entity( function() { + IPA.entity_factories.user = function() { var that = IPA.entity({name: 'user'}); that.setup = function(container){ user_mock_called = true; @@ -39,10 +39,8 @@ test("Testing nav_create().", function() { same(container[0].nodeName,'DIV','user div'); } return that; - }); - - IPA.register_entity( function(){ - + }; + IPA.entity_factories.group = function(){ var that = IPA.entity({name: 'group'}); that.setup = function(container){ group_mock_called = true; @@ -50,7 +48,7 @@ test("Testing nav_create().", function() { same(container[0].nodeName,'DIV','group Div'); }; return that; - }); + }; IPA.start_entities(); -- cgit