← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19705: WIP, org unit filter in dashboard

 

------------------------------------------------------------
revno: 19705
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-08-03 21:32:48 +0200
message:
  WIP, org unit filter in dashboard
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/dashboard.vm
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css


--
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-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js	2014-04-03 11:02:16 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js	2015-08-03 19:32:48 +0000
@@ -136,11 +136,21 @@
 {
     this.clearSelectedOrganisationUnits = function()
     {
-    	$.ajax({ 
+    	$.ajax( { 
     		url: selectionTreePath + 'clearSelectedOrganisationUnits.action',
 			async: false
-    	});
+    	} );
     };
+    
+    this.clearSelectedOrganisationUnitsAndBuildTree = function()
+    {
+    	$.ajax( { 
+    		url: selectionTreePath + 'clearSelectedOrganisationUnits.action',
+			success: function() {
+				selectionTree.buildSelectionTree();
+			}
+    	} );
+    }
 
     this.toggle = function( unitId )
     {

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/dashboard.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/dashboard.vm	2015-01-16 09:15:07 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/dashboard.vm	2015-08-03 19:32:48 +0000
@@ -5,6 +5,7 @@
 <script type="text/javascript" src="plugin/map.js"></script>
 <script type="text/javascript" src="plugin/eventreport.js"></script>
 <script type="text/javascript" src="plugin/eventchart.js"></script>
+<script type="text/javascript" src="../dhis-web-commons/oust/oust.js"></script>
 <script type="text/javascript" src="javascript/dashboard.js"></script>
 
 <script type="text/javascript">
@@ -58,6 +59,8 @@
 
 <div id="searchButton"><a class="blueButtonLink" href="javascript:dhis2.db.search()">$i18n.getString( "search" )</a></div>
 
+<div id="cogButton"><a class="greyButtonLink" href="javascript:dhis2.db.viewOrgUnitSelector()"><i class="fa fa-cog"></i></a></div>
+
 <div id="dashboardControl" class="horizontalMenu dashboardList">
     <ul>
         <li><a class='bold' href='javascript:dhis2.db.openAddDashboardForm()'>$i18n.getString( "add" )</a></li>
@@ -116,3 +119,11 @@
     <h4>$i18n.getString( "delete_current_dashboard" )</h4>
     <div><a class="greyButtonLink" href="javascript:dhis2.db.removeDashboard()">$i18n.getString( "delete" )</a></div>
 </div>
+
+<div id="orgUnitSelectorForm" class="page">
+	<div id="selectionTree" style="width:340px; height:400px"></div>
+	<div style="padding-top:15px; float:right;">
+		<a class="greyButtonLink" href="javascript:dhis2.db.clearSelectedOrgUnits()">$i18n.getString( "clear" )</a>
+		<a class="greyButtonLink" href="javascript:dhis2.db.updateSelectedOrgUnits()">$i18n.getString( "update" )</a>
+	</div>
+</div>

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js	2015-07-09 06:22:02 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js	2015-08-03 19:32:48 +0000
@@ -25,6 +25,7 @@
 dhis2.db.currentShareType;
 dhis2.db.currentShareId;
 dhis2.db.currentMaxType = [];
+dhis2.db.currentUserOrgUnit = [];
 dhis2.db.contextPath;
 dhis2.db.maxItems = 40;
 dhis2.db.shapeNormal = "normal";
@@ -59,6 +60,10 @@
 
 	$( "#searchField" ).focus();
 	$( "#searchField" ).keyup( dhis2.db.search );
+	
+	selectionTree.clearSelectedOrganisationUnits();
+	selectionTreeSelection.setMultipleSelectionAllowed( true );
+	selectionTree.buildSelectionTree();
 
 	$.getJSON( "../api/me/user-account.json?" + dhis2.util.cacheBust(), function( json ) {
 		dhis2.db.currentKey = "dhis2.dashboard.current." + json.username;
@@ -585,6 +590,7 @@
 
 	var graphStyle = "width:" + width + "px; overflow:hidden;";
 	var tableStyle = "width:" + width + "px;";
+	var userOrgUnit = dhis2.db.currentUserOrgUnit || [];
 
 	if ( "chart" == dashboardItem.type )
 	{
@@ -602,6 +608,7 @@
             dashboard: true,
             crossDomain: false,
             skipMask: true,
+            userOrgUnit: userOrgUnit,
             domainAxisStyle: {
                 labelRotation: 45,
                 labelFont: '10px sans-serif',
@@ -639,6 +646,7 @@
             dashboard: true,
             crossDomain: false,
             skipMask: true,
+            userOrgUnit: userOrgUnit,
             domainAxisStyle: {
                 labelRotation: 45,
                 labelFont: '10px sans-serif',
@@ -674,7 +682,8 @@
             hideLegend: true,
             dashboard: true,
             crossDomain: false,
-            skipMask: true
+            skipMask: true,
+            userOrgUnit: userOrgUnit
 	    });
 	}
 	else if ( "reportTable" == dashboardItem.type )
@@ -691,7 +700,8 @@
             crossDomain: false,
             skipMask: true,
             displayDensity: 'compact',
-            fontSize: 'small'
+            fontSize: 'small',
+            userOrgUnit: userOrgUnit
 	    });
 	}
 	else if ( "eventReport" == dashboardItem.type )
@@ -708,7 +718,8 @@
             crossDomain: false,
             skipMask: true,
             displayDensity: 'compact',
-            fontSize: 'small'
+            fontSize: 'small',
+            userOrgUnit: userOrgUnit
 	    });
 	}
 	else if ( "users" == dashboardItem.type )
@@ -1214,3 +1225,34 @@
 		window.location.href = url;
 	}
 }
+
+//------------------------------------------------------------------------------
+// Org unit selector
+//------------------------------------------------------------------------------
+
+dhis2.db.viewOrgUnitSelector = function()
+{
+	$( "#orgUnitSelectorForm" ).dialog( {
+		autoOpen: true,
+		modal: true,
+		width: 370,
+		height: 500,
+		resizable: false,
+		title: "Select user organisation unit"
+	} );
+}
+
+dhis2.db.updateSelectedOrgUnits = function()
+{
+	var ous = selectionTreeSelection.getSelectedUid();
+	dhis2.db.currentUserOrgUnit = ous;	
+	dhis2.db.renderDashboard( dhis2.db.current() );
+	$( "#orgUnitSelectorForm" ).dialog( "destroy" );
+}
+
+dhis2.db.clearSelectedOrgUnits = function()
+{
+	dhis2.db.currentUserOrgUnit = [];
+	selectionTree.clearSelectedOrganisationUnitsAndBuildTree();
+	dhis2.db.updateSelectedOrgUnits();
+}

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css	2015-01-21 12:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css	2015-08-03 19:32:48 +0000
@@ -209,6 +209,13 @@
   left: 834px;
 }
 
+#cogButton
+{
+  position: absolute;
+  margin-top: 6px;
+  left: 907px;
+}
+
 #searchField
 {
   padding: 0;
@@ -333,6 +340,11 @@
   display: none;
 }
 
+#orgUnitSelectorForm
+{
+  display: none;
+}
+
 #chartView
 {
   display: none;