← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18081: Dashboard. Adding items without reloading dashboard.

 

------------------------------------------------------------
revno: 18081
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-01-21 11:27:31 +0100
message:
  Dashboard. Adding items without reloading dashboard.
modified:
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js


--
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-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-01-21 10:01:14 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js	2015-01-21 10:27:31 +0000
@@ -32,6 +32,7 @@
 dhis2.db.shapeFullWidth = "full_width";
 dhis2.db.widthNormal = 408;
 dhis2.db.widthDouble = 849;
+dhis2.db.visualItemTypes = ["chart", "eventChart", "map", "reportTable", "eventReport"];
 
 dhis2.db.itemContentHeight = 308;
 dhis2.db.itemScrollbarWidth = /\bchrome\b/.test(navigator.userAgent.toLowerCase()) ? 8 : 17;
@@ -793,8 +794,24 @@
 	    		type: type,
 	    		id: id
 	    	},
-	    	success: function() {
-	    		dhis2.db.renderDashboard( dhis2.db.current() );
+	    	success: function( data, textStatus, xhr ) {
+	    		
+	    		var location = xhr.getResponseHeader( "Location" );
+	    		
+	    		if ( location ) {
+		    		$.getJSON( "../api" + location, function( item ) {
+		    			if ( item && $.inArray( item.type, dhis2.db.visualItemTypes ) != -1 ) {
+		    				$d = $( "#contentList" );
+		    				dhis2.db.renderItems( $d, item, undefined, true );
+		    			}
+		    			else {
+		    				dhis2.db.renderDashboard( dhis2.db.current() );
+		    			}
+		    		} );
+	    		}
+	    		else {
+	    			dhis2.db.renderDashboard( dhis2.db.current() );
+	    		}
 	    	},
 	    	error: function( xhr ) {
 	    		setHeaderDelayMessage( xhr.responseText );