← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6622: (DV) User orgunit children option implemented.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 6622 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-04-17 16:24:41 +0200
message:
  (DV) User orgunit children option implemented.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
  dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java
  dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/i18n.vm
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonInitialize.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2012-04-11 04:56:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2012-04-17 14:23:08 +0000
@@ -123,6 +123,8 @@
     private RelativePeriods relatives;
 
     private boolean userOrganisationUnit;
+    
+    private boolean userOrganisationUnitChildren;
 
     private User user;
 
@@ -578,12 +580,25 @@
         return userOrganisationUnit;
     }
 
-    public void setUserOrganisationUnit( boolean userOrganisationUnit )
+    public void setUserOrganisationUnit( boolean userOrganisationUnitChildren )
     {
         this.userOrganisationUnit = userOrganisationUnit;
     }
 
     @JsonProperty
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+    public boolean isUserOrganisationUnitChildren()
+    {
+        return userOrganisationUnitChildren;
+    }
+
+    public void setUserOrganisationUnitChildren( boolean userOrganisationUnitChildren )
+    {
+        this.userOrganisationUnitChildren = userOrganisationUnitChildren;
+    }
+
+    @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java	2012-03-09 02:29:32 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java	2012-04-17 14:23:08 +0000
@@ -280,6 +280,13 @@
         this.userOrganisationUnit = userOrganisationUnit;
     }
 
+    private Boolean userOrganisationUnitChildren;
+
+    public void setUserOrganisationUnitChildren( Boolean userOrganisationUnitChildren )
+    {
+        this.userOrganisationUnitChildren = userOrganisationUnitChildren;
+    }
+
     private String domainAxisLabel;
 
     public void setDomainAxisLabel( String domainAxisLabel )
@@ -457,6 +464,11 @@
             chart.setUserOrganisationUnit( userOrganisationUnit );
         }
 
+        if ( userOrganisationUnitChildren != null )
+        {
+            chart.setUserOrganisationUnitChildren( userOrganisationUnitChildren );
+        }
+
         if ( domainAxisLabel != null )
         {
             chart.setDomainAxisLabel( domainAxisLabel );

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties	2012-04-13 14:09:59 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties	2012-04-17 14:23:08 +0000
@@ -40,7 +40,7 @@
 trend_line=Trend line
 hide_subtitle=Hide subtitle
 hide_legend=Hide legend
-user_orgunit=User org unit
+user_orgunit=User orgunit
 domain_axis_label=Domain axis label
 range_axis_label=Range axis label
 target=Target
@@ -120,4 +120,5 @@
 wm_multiple_filter_groups=Multiple organisation unit groups selected as filter.
 wm_first_filter_used=The first one is being used.
 available_attribute = Available attribute 
-selected_attribute = Selected attribute
\ No newline at end of file
+selected_attribute = Selected attribute
+user_orgunit_children = User orgunit children
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js	2012-04-16 12:13:58 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js	2012-04-17 14:23:08 +0000
@@ -63,13 +63,35 @@
 		ajax: {
 			jsonfy: function(r) {
 				r = Ext.JSON.decode(r.responseText);
-				var obj = {system: {rootnode: {id: r.rn[0], name: r.rn[1], level: 1}, periods: {}, user: {id: r.user.id, isadmin: r.user.isAdmin, organisationunit: {id: r.user.ou[0], name: r.user.ou[1]}},organisationunitgroupsets:r.ougs}};
+				var obj = {
+					system: {
+						rootnode: {
+							id: r.rn[0],
+							name: r.rn[1],
+							level: 1
+						},
+						periods: {},
+						organisationunitgroupsets: r.ougs
+					},
+					user: {
+						id: r.user.id,
+						isadmin: r.user.isAdmin,
+						organisationunit: {
+							id: r.user.ou[0],
+							name: r.user.ou[1]
+						},
+						organisationunitchildren: []							
+					}
+				};
 				for (var relative in r.p) {
 					obj.system.periods[relative] = [];
 					for (var i = 0; i < r.p[relative].length; i++) {
 						obj.system.periods[relative].push({id: r.p[relative][i][0], name: r.p[relative][i][1]});
 					}
 				}
+				for (var i = 0; i < r.user.ouc.length; i++) {
+					obj.user.organisationunitchildren.push({id: r.user.ouc[i][0], name: r.user.ouc[i][1]});
+				}
 				return obj;
 			}
 		}
@@ -195,7 +217,7 @@
         west_maxheight_accordion_dataset: 450,
         west_maxheight_accordion_period: 340,
         west_maxheight_accordion_organisationunit: 700,
-        west_maxheight_accordion_options: 367,
+        west_maxheight_accordion_options: 393,
         center_tbar_height: 31,
         east_tbar_height: 31,
         east_gridcolumn_height: 30,
@@ -605,8 +627,16 @@
 						}
 					}
 					else {
-						if (DV.c.userorganisationunit) {
-							a.push(DV.init.system.user.organisationunit.name);
+						if (DV.c.userorganisationunit || DV.c.userorganisationunitchildren) {
+							if (DV.c.userorganisationunit) {
+								a.push(DV.init.user.organisationunit.name);
+							}
+							if (DV.c.userorganisationunitchildren) {
+								var c = DV.init.user.organisationunitchildren;
+								for (var i = 0; i < c.length; i++) {
+									a.push(c[i].name);
+								}
+							}
 						}
 						else {
 							for (var i = 0; i < ou.objects.length; i++) {
@@ -622,8 +652,16 @@
                 getUrl: function(isFilter) {
 					var ou = DV.c.organisationunit,
 						a = [];
-					if (DV.c.userorganisationunit) {
-						a.push('organisationUnitIds=' + DV.init.system.user.organisationunit.id);
+					if (DV.c.userorganisationunit || DV.c.userorganisationunitchildren) {
+						if (DV.c.userorganisationunit) {
+							a.push('organisationUnitIds=' + DV.init.user.organisationunit.id);
+						}
+						if (DV.c.userorganisationunitchildren) {
+							var c = DV.init.user.organisationunitchildren;
+							for (var i = 0; i < c.length; i++) {
+								a.push('organisationUnitIds=' + c[i].id);
+							}
+						}
 					}
 					else {
 						for (var i = 0; i < ou.objects.length; i++) {
@@ -1506,6 +1544,7 @@
                         DV.c.hidelegend = f.hideLegend;
                         DV.c.trendline = f.regression;
                         DV.c.userorganisationunit = f.userOrganisationUnit;
+                        DV.c.userorganisationunitchildren = f.userOrganisationUnitChildren;
                         DV.c.domainaxislabel = f.domainAxisLabel;
                         DV.c.rangeaxislabel = f.rangeAxisLabel;
                         DV.c.targetlinevalue = f.targetLineValue ? parseFloat(f.targetLineValue) : null;
@@ -1603,6 +1642,7 @@
             DV.c.hidelegend = DV.cmp.favorite.hidelegend.getValue();
             DV.c.trendline = DV.cmp.favorite.trendline.getValue();
             DV.c.userorganisationunit = DV.cmp.favorite.userorganisationunit.getValue();
+            DV.c.userorganisationunitchildren = DV.cmp.favorite.userorganisationunitchildren.getValue();
             DV.c.domainaxislabel = DV.cmp.favorite.domainaxislabel.getValue();
             DV.c.rangeaxislabel = DV.cmp.favorite.rangeaxislabel.getValue();
             DV.c.targetlinevalue = parseFloat(DV.cmp.favorite.targetlinevalue.getValue());
@@ -1620,6 +1660,7 @@
 			p.hideLegend = DV.c.hidelegend;
 			p.trendLine = DV.c.trendline;
 			p.userOrganisationUnit = DV.c.userorganisationunit;
+			p.userOrganisationUnitChildren = DV.c.userorganisationunitChildren;
 			if (DV.c.domainaxislabel) {
 				p.domainAxisLabel = DV.c.domainaxislabel;
 			}
@@ -1654,6 +1695,7 @@
 			DV.cmp.favorite.hidelegend.setValue(DV.c.hidelegend);
 			DV.cmp.favorite.trendline.setValue(DV.c.trendline);
 			DV.cmp.favorite.userorganisationunit.setValue(DV.c.userorganisationunit);
+			DV.cmp.favorite.userorganisationunitchildren.setValue(DV.c.userorganisationunitchildren);
 			DV.cmp.favorite.domainaxislabel.setValue(DV.c.domainaxislabel);
 			DV.cmp.favorite.rangeaxislabel.setValue(DV.c.rangeaxislabel);
 			DV.cmp.favorite.targetlinevalue.setValue(DV.c.targetlinevalue);
@@ -1914,6 +1956,7 @@
 			hidelegend: false,
 			trendline: false,
 			userorganisationunit: false,
+			userorganisationunitchildren: false,
 			domainaxislabel: null,
 			rangeaxislabel: null,
 			targetlinevalue: null,
@@ -1937,6 +1980,7 @@
 			this.model.hidelegend = false;
 			this.model.trendline = false;
 			this.model.userorganisationunit = false;
+			this.model.userorganisationunitchildren = false;			
 			this.model.domainaxislabel = null;
 			this.model.rangeaxislabel = null;
 			this.model.targetlinevalue = null;
@@ -3205,12 +3249,11 @@
 													{
 														xtype: 'panel',
 														layout: 'column',
-														bodyStyle: 'border-style:none; background-color:transparent; padding-bottom:15px',
+														bodyStyle: 'border-style:none; background-color:transparent; padding-bottom:3px',
 														items: [
 															{
 																xtype: 'checkbox',
-																cls: 'dv-checkbox-alt1',
-																style: 'margin-right:23px',
+																width: 124,
 																boxLabel: DV.i18n.hide_subtitle,
 																labelWidth: DV.conf.layout.form_label_width,
 																listeners: {
@@ -3221,8 +3264,36 @@
 															},
 															{
 																xtype: 'checkbox',
-																cls: 'dv-checkbox-alt1',
-																style: 'margin-right:23px',
+																width: 130,
+																boxLabel: DV.i18n.user_orgunit,
+																labelWidth: DV.conf.layout.form_label_width,
+																listeners: {
+																	added: function() {
+																		DV.cmp.favorite.userorganisationunit = this;
+																	}
+																}
+															},
+															{
+																xtype: 'checkbox',
+																width: 124,
+																boxLabel: DV.i18n.trend_line,
+																labelWidth: DV.conf.layout.form_label_width,
+																listeners: {
+																	added: function() {
+																		DV.cmp.favorite.trendline = this;
+																	}
+																}
+															}
+														]
+													},
+													{
+														xtype: 'panel',
+														layout: 'column',
+														bodyStyle: 'border-style:none; background-color:transparent; padding-bottom:15px',
+														items: [
+															{
+																xtype: 'checkbox',
+																width: 124,
 																boxLabel: DV.i18n.hide_legend,
 																labelWidth: DV.conf.layout.form_label_width,
 																listeners: {
@@ -3233,24 +3304,12 @@
 															},
 															{
 																xtype: 'checkbox',
-																cls: 'dv-checkbox-alt1',
-																style: 'margin-right:23px',
-																boxLabel: DV.i18n.trend_line,
-																labelWidth: DV.conf.layout.form_label_width,
-																listeners: {
-																	added: function() {
-																		DV.cmp.favorite.trendline = this;
-																	}
-																}
-															},
-															{
-																xtype: 'checkbox',
-																cls: 'dv-checkbox-alt1',
-																boxLabel: DV.i18n.user_orgunit,
-																labelWidth: DV.conf.layout.form_label_width,
-																listeners: {
-																	added: function() {
-																		DV.cmp.favorite.userorganisationunit = this;
+																width: 130,
+																boxLabel: DV.i18n.user_orgunit_children,
+																labelWidth: DV.conf.layout.form_label_width,
+																listeners: {
+																	added: function() {
+																		DV.cmp.favorite.userorganisationunitchildren = this;
 																	}
 																}
 															}
@@ -3540,9 +3599,9 @@
                                                                             style: 'padding-bottom:2px',
                                                                             fieldLabel: DV.i18n.system,
                                                                             labelWidth: DV.conf.layout.form_label_width,
-                                                                            disabled: !DV.init.system.user.isadmin,
+                                                                            disabled: !DV.init.user.isadmin,
                                                                             check: function() {
-                                                                                if (!DV.init.system.user.isadmin) {
+                                                                                if (!DV.init.user.isadmin) {
                                                                                     if (DV.store.favorite.findExact('name', DV.cmp.favorite.name.getValue()) === -1) {
                                                                                         this.setValue(false);
                                                                                     }
@@ -3862,7 +3921,7 @@
                                                                             if (DV.cmp.favorite.name.getValue()) {
                                                                                 var index = DV.store.favorite.findExact('name', DV.cmp.favorite.name.getValue());
                                                                                 if (index != -1) {
-                                                                                    if (DV.store.favorite.getAt(index).data.userId || DV.init.system.user.isadmin) {
+                                                                                    if (DV.store.favorite.getAt(index).data.userId || DV.init.user.isadmin) {
                                                                                         this.enable();
                                                                                         DV.cmp.favorite.label.setText('');
                                                                                         return true;

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/i18n.vm'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/i18n.vm	2012-03-07 14:33:51 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/i18n.vm	2012-04-17 14:23:08 +0000
@@ -119,6 +119,7 @@
 wm_multiple_filter_period:'$encoder.jsEscape($i18n.getString( 'wm_multiple_filter_period' ) , "'")',
 wm_multiple_filter_orgunit:'$encoder.jsEscape($i18n.getString( 'wm_multiple_filter_orgunit' ) , "'")',
 wm_multiple_filter_groups:'$encoder.jsEscape($i18n.getString( 'wm_multiple_filter_groups' ) , "'")',
-wm_first_filter_used:'$encoder.jsEscape($i18n.getString( 'wm_first_filter_used' ) , "'")'
+wm_first_filter_used:'$encoder.jsEscape($i18n.getString( 'wm_first_filter_used' ) , "'")',
+user_orgunit_children:'$encoder.jsEscape($i18n.getString( 'user_orgunit_children' ) , "'")'
 
 };
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonInitialize.vm'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonInitialize.vm	2012-03-06 11:11:02 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonInitialize.vm	2012-04-17 14:23:08 +0000
@@ -1,1 +1,1 @@
-{"user":{"id":"$!currentUser.id","isAdmin":$auth.hasAccess( "dhis-web-visualizer", "addOrUpdateSystemChart" ),"ou":["$!currentUser.organisationUnit.id","$!encoder.jsonEncode(${currentUser.organisationUnit.name})"]},"rn":["$!{rootNode.id}","$!encoder.jsonEncode(${rootNode.name})"],"p":{"lastMonth":[#foreach($p in $lastMonth)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastMonth.size()),#end#end],"last12Months":[#foreach($p in $last12Months)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last12Months.size()),#end#end],"lastQuarter":[#foreach($p in $lastQuarter)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastQuarter.size()),#end#end],"last4Quarters":[#foreach($p in $last4Quarters)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last4Quarters.size()),#end#end],"lastSixMonth":[#foreach($p in $lastSixMonth)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastSixMonth.size()),#end#end],"last2SixMonths":[#foreach($p in $last2SixMonths)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last2SixMonths.size()),#end#end],"lastYear":[#foreach($p in $lastYear)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastYear.size()),#end#end],"thisYear":[#foreach($p in $thisYear)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$thisYear.size()),#end#end],"last5Years":[#foreach($p in $last5Years)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last5Years.size()),#end#end]},"ougs":{#foreach($ougs in $organisationUnitGroupSets)"$!{ougs.id}":[#foreach($oug in $ougs.getSortedGroups()){"id":"$!{oug.id}","name":"$!encoder.jsonEncode($!{oug.name})"}#if($velocityCount<$ougs.getSortedGroups().size()),#end#end]#if($velocityCount<$organisationUnitGroupSets.size()),#end#end}}
\ No newline at end of file
+{"user":{"id":"$!currentUser.id","isAdmin":$auth.hasAccess( "dhis-web-visualizer", "addOrUpdateSystemChart" ),"ou":["$!currentUser.organisationUnit.id","$!encoder.jsonEncode(${currentUser.organisationUnit.name})"],ouc:[#foreach($ou in $!currentUser.organisationUnit.getSortedChildren())["$!{ou.id}","$!encoder.jsonEncode(${ou.name})"]#if($velocityCount<$currentUser.organisationUnit.getSortedChildren().size()),#end#end]},"rn":["$!{rootNode.id}","$!encoder.jsonEncode(${rootNode.name})"],"p":{"lastMonth":[#foreach($p in $lastMonth)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastMonth.size()),#end#end],"last12Months":[#foreach($p in $last12Months)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last12Months.size()),#end#end],"lastQuarter":[#foreach($p in $lastQuarter)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastQuarter.size()),#end#end],"last4Quarters":[#foreach($p in $last4Quarters)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last4Quarters.size()),#end#end],"lastSixMonth":[#foreach($p in $lastSixMonth)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastSixMonth.size()),#end#end],"last2SixMonths":[#foreach($p in $last2SixMonths)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last2SixMonths.size()),#end#end],"lastYear":[#foreach($p in $lastYear)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$lastYear.size()),#end#end],"thisYear":[#foreach($p in $thisYear)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$thisYear.size()),#end#end],"last5Years":[#foreach($p in $last5Years)["$!{p.id}","$!encoder.jsonEncode(${p.name})"]#if($velocityCount<$last5Years.size()),#end#end]},"ougs":{#foreach($ougs in $organisationUnitGroupSets)"$!{ougs.id}":[#foreach($oug in $ougs.getSortedGroups()){"id":"$!{oug.id}","name":"$!encoder.jsonEncode($!{oug.name})"}#if($velocityCount<$ougs.getSortedGroups().size()),#end#end]#if($velocityCount<$organisationUnitGroupSets.size()),#end#end}}
\ No newline at end of file