=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/TabularInitializeAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/TabularInitializeAction.java 2012-11-07 04:00:25 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/TabularInitializeAction.java 2012-11-07 14:21:44 +0000 @@ -33,6 +33,7 @@ import java.util.List; import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; import org.hisp.dhis.organisationunit.OrganisationUnitLevel; @@ -100,6 +101,13 @@ return orgunitGroups; } + private OrganisationUnit rootNode; + + public OrganisationUnit getRootNode() + { + return rootNode; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -107,9 +115,15 @@ public String execute() throws Exception { - orgunitGroups = new ArrayList( organisationUnitGroupService.getAllOrganisationUnitGroups() ); + orgunitGroups = new ArrayList( + organisationUnitGroupService.getAllOrganisationUnitGroups() ); Collections.sort( orgunitGroups, IdentifiableObjectNameComparator.INSTANCE ); + Collection rootUnits = new ArrayList( + organisationUnitService.getOrganisationUnitsAtLevel( 1 ) ); + + rootNode = rootUnits.size() > 0 ? rootUnits.iterator().next() : new OrganisationUnit(); + programs = programService.getAllPrograms(); levels = organisationUnitService.getOrganisationUnitLevels(); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2012-11-07 03:53:08 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2012-11-07 14:21:44 +0000 @@ -5,13 +5,10 @@ r = Ext.JSON.decode(r.responseText); var obj = { system: { + rootnode: {id: r.rn[0], name: r.rn[1], level: 1}, maxLevels: r.levels.length } }; - obj.system.rootnodes = []; - for (var i = 0; i < r.user.ous.length; i++) { - obj.system.rootnodes.push({id: r.user.ous[i].id, text: r.user.ous[i].name, leaf: r.user.ous[i].leaf}); - } obj.system.program = []; for (var i = 0; i < r.programs.length; i++) { @@ -1688,13 +1685,11 @@ url: TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.organisationunitchildren_get }, root: { - id: 0, - text: "/", - expanded: true, - children: TR.init.system.rootnodes + id: TR.init.system.rootnode.id, + text: TR.init.system.rootnode.name, + expanded: false } }), - rootVisible: false, listeners: { added: function() { TR.cmp.params.organisationunit.treepanel = this; @@ -1703,15 +1698,7 @@ { treePanel.getSelectionModel().select( treePanel.getRootNode() ); TR.state.orgunitIds = []; - var orgunitid = treePanel.getSelectionModel().getSelection()[0].data.id; - if(orgunitid==0){ - for( var i in TR.init.system.rootnodes){ - TR.state.orgunitIds.push( TR.init.system.rootnodes[i].id ); - } - } - else{ - TR.state.orgunitIds.push( orgunitid ); - } + TR.state.orgunitIds.push( treePanel.getSelectionModel().getSelection() ); }, itemclick : function(view,rec,item,index,eventObj){ TR.state.orgunitIds = []; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm 2012-11-07 04:00:25 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm 2012-11-07 14:21:44 +0000 @@ -2,17 +2,12 @@ "user": { "id":"$!currentUser.id", - "isAdmin":$!currentUser.userCredentials.isSuper(), - "ous":[ - #foreach( $orgunit in $currentUser.organisationUnits ) - { - "id": "${orgunit.id}" , - "name": "$!encoder.jsonEncode( ${orgunit.name} )", - "leaf": !$orgunit.hasChild() - }#if( $velocityCount < $programs.size() ),#end - #end - ] + "isAdmin":$!currentUser.userCredentials.isSuper() }, + "rn":[ + "$!{rootNode.id}", + "$!encoder.jsonEncode(${rootNode.name})" + ], "programs": [ #foreach( $program in $programs ) {