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/group.js | 153 +++++++++++++++------------------------------------- 1 file changed, 43 insertions(+), 110 deletions(-) (limited to 'install/ui/group.js') diff --git a/install/ui/group.js b/install/ui/group.js index 13017ac5..0188031f 100644 --- a/install/ui/group.js +++ b/install/ui/group.js @@ -2,6 +2,8 @@ /* Authors: * Pavel Zuna + * 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 -- cgit