From dde15772700da41ec931bb55087fbec6f30fab55 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Tue, 7 Sep 2010 10:08:19 -0400 Subject: associations -Refactored the associations code into a set of objects that are configured by the entities -Added support for associations that can be done in a single rpc -hostgroup to host and group to user associations working -Restructed sampledata so that the file is matched automatically by the RPC method name -The new ipa_cmd/sampledata scheme insists on there being sample data for any commands or the ipa_command fails. -Added sampledata files for all the calls we make -renamed several of the sampledata files to match their rpc calls -Started a pattern of refactoring where all the forms for the entity fall under a single object --- install/static/group.js | 59 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 19 deletions(-) (limited to 'install/static/group.js') diff --git a/install/static/group.js b/install/static/group.js index 981e048b..8c5491ae 100644 --- a/install/static/group.js +++ b/install/static/group.js @@ -1,10 +1,13 @@ function setupGroup(facet){ - if (facet == "details"){ - setupGroupDetails(); - }else if (facet == "add"){ - setupAddGroup(); + + if (groupForms[facet]){ + groupForms[facet].setup(); + }else if (facet == "details"){ + setupGroupDetails(); + }else if (facet == "add"){ + setupAddGroup(); }else{ - groupSearchForm.setup(); + groupForms.search.setup(); } } @@ -74,33 +77,26 @@ var group_details_list = ['description', 'Description'], ['gidnumber', 'Group ID']]]]; +var groupFacets=['details','users']; + function setupGroupDetails(group){ //re initialize global parse of parameters qs = ipa_parse_qs(); showDetails(); - + setupFacetNavigation('group',qs['pkey'],qs['facet'],groupFacets); ipa_details_init('group'); ipa_details_create(group_details_list, $('#details')); - ipa_details_load(qs['pkey'], on_win, null, "sampledata/groupshow.json"); + ipa_details_load(qs['pkey'], on_win, null); $('h1').text('Managing group: ' + group); } - - -function renderGroupDetails(group) -{ - -} - - function renderGroupDetailColumn(current,cell){ $("",{ - href:"#tab=group&facet=details&pkey="+current.cn, - html: ""+ current[this.column], - //click: function(){ setupGroupDetails(current.cn)}, + href:"#tab=group&facet=details&pkey="+current.cn, + html: ""+ current[this.column], }).appendTo(cell); } @@ -112,7 +108,32 @@ var groupSearchColumns = [ {title:"Description", column:"description",render: renderSimpleColumn} ]; -var groupSearchForm = new SearchForm("group", "find", groupSearchColumns ,"sampledata/grouplist.json"); +var groupForms = new GroupForms(); + +function GroupForms(){ + + this.userListColumns = [ {title:"user",column:"member_user" }]; + this.obj="group"; + this.users = new AssociationList( + this.obj, + "users", + "assignusers", + this.userListColumns, groupFacets ); + + this.assignusers = new AssociationForm( + this.obj, + "user", + "assignusers", + groupFacets, + "uid", + function(){ + return 'Add Users to group : ' + qs['pkey'] ; + }, + BulkAssociator); + this.search = new SearchForm("group", "find", groupSearchColumns ); + + +} -- cgit