← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 338: Views can be loaded from url paramter, i.e. you may select views directly from dashboard.

 

------------------------------------------------------------
revno: 338
committer: Jan Henrik Overland janhenrik.overland@xxxxxxxxx
branch nick: trunk
timestamp: Wed 2009-05-27 19:21:20 +0200
message:
  Views can be loaded from url paramter, i.e. you may select views directly from dashboard.
modified:
  gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js
  gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Choropleth.js

=== modified file 'gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js'
--- gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js	2009-05-27 13:20:03 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js	2009-05-27 17:21:20 +0000
@@ -19,6 +19,34 @@
     ACTIVEPANEL = 'choropleth';
     MAPVIEW = false;
     MAPVIEWACTIVE = false;    
+    URLACTIVE = false;
+    PARAMETER = null;
+    
+    function getUrlParam(strParamName)
+    {
+        var output = "";
+        var strHref = window.location.href;
+        if ( strHref.indexOf("?") > -1 )
+        {
+            var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
+            var aQueryString = strQueryString.split("&");
+            for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
+            {
+                if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 )
+                {
+                    var aParam = aQueryString[iParam].split("=");
+                    output = aParam[1];
+                    break;
+                }
+            }
+        }
+        return unescape(output);
+    }
+    
+    if (getUrlParam('view') != '') {
+        PARAMETER = getUrlParam('view');
+        URLACTIVE = true;
+    }
 
     var jpl_wms = new OpenLayers.Layer.WMS("Satellite",
                                            "http://labs.metacarta.com/wms-c/Basic.py?";, 
@@ -1356,6 +1384,7 @@
     map.addControl(new OpenLayers.Control.OverviewMap({div: $('overviewmap')}));
     
     Ext.get('loading').fadeOut({remove: true});
+   
 });
 
 // SELECT FEATURES

=== modified file 'gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Choropleth.js'
--- gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Choropleth.js	2009-05-27 13:20:03 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Choropleth.js	2009-05-27 17:21:20 +0000
@@ -147,7 +147,46 @@
             root: 'mapViews',
             fields: ['id', 'name'],
             sortInfo: { field: 'name', direction: 'ASC' },
-            autoLoad: true
+            autoLoad: true,
+            listeners: {
+                'load': {
+                    fn: function()
+                    {
+                        if (URLACTIVE)
+                        {
+                            Ext.Ajax.request(
+                            {
+                                url: path + 'getMapView' + type,
+                                method: 'POST',
+                                params: { id: PARAMETER },
+
+                                success: function( responseObject )
+                                {
+                                    MAPVIEWACTIVE = true;
+                                    MAPVIEW = Ext.util.JSON.decode(responseObject.responseText).mapView[0];
+                                    
+                                    Ext.getCmp('mapview_cb').setValue(MAPVIEW.id);
+                                    
+                                    Ext.getCmp('numClasses').setValue(MAPVIEW.classes);
+                                    Ext.getCmp('colorA_cf').setValue(MAPVIEW.colorLow);
+                                    Ext.getCmp('colorB_cf').setValue(MAPVIEW.colorHigh);
+
+                                    Ext.getCmp('indicatorgroup_cb').setValue(MAPVIEW.indicatorGroupId);
+                                    
+                                    var igId = Ext.getCmp('indicatorgroup_cb').getValue();
+                                    indicatorStore.baseParams = { indicatorGroupId: igId, format: 'json' };
+                                    indicatorStore.reload();
+                                },
+                                failure: function()
+                                {
+                                  alert( 'Status', 'Error while retrieving data' );
+                                } 
+                            });
+                        }
+                    },
+                    scope: this
+                }
+            }
         });
     
         indicatorGroupStore = new Ext.data.JsonStore({
@@ -329,6 +368,10 @@
                 'select': {
                     fn: function()
                     {
+                        if (Ext.getCmp('mapview_cb').getValue() != '') {
+                            Ext.getCmp('mapview_cb').reset();
+                        }
+                        
                         Ext.getCmp('indicator_cb').reset();
                         var igId = Ext.getCmp('indicatorgroup_cb').getValue();
                         indicatorStore.baseParams = { indicatorGroupId: igId, format: 'json' };
@@ -358,6 +401,10 @@
                 'select': {
                     fn: function()
                     {
+                        if (Ext.getCmp('mapview_cb').getValue() != '') {
+                            Ext.getCmp('mapview_cb').reset();
+                        }
+                        
                         var iId = Ext.getCmp('indicator_cb').getValue();
                         
                         Ext.Ajax.request(
@@ -411,6 +458,10 @@
                 'select': {
                     fn: function()
                     {
+                        if (Ext.getCmp('mapview_cb').getValue() != '') {
+                            Ext.getCmp('mapview_cb').reset();
+                        }
+                        
                         var ptid = Ext.getCmp('periodtype_cb').getValue();
                         Ext.getCmp('period_cb').getStore().baseParams = { periodTypeId: ptid, format: 'json' };
                         Ext.getCmp('period_cb').getStore().reload();
@@ -439,6 +490,10 @@
                 'select': {
                     fn: function()
                     {
+                        if (Ext.getCmp('mapview_cb').getValue() != '') {
+                            Ext.getCmp('mapview_cb').reset();
+                        }
+                        
                         this.classify(false);
                     },
                     scope: this
@@ -463,9 +518,13 @@
             store: mapStore,
             listeners: {
                 'select': {
-                    fn: function() {
+                    fn: function()
+                    {
+                        if (Ext.getCmp('mapview_cb').getValue() != '') {
+                            Ext.getCmp('mapview_cb').reset();
+                        }
+                        
                         var mlp = Ext.getCmp('map_cb').getValue();
-                                     
                         this.newUrl = mlp;
                         this.classify(false);
                     },
@@ -522,6 +581,10 @@
                 'select': {
                     fn: function()
                     {
+                        if (Ext.getCmp('mapview_cb').getValue() != '') {
+                            Ext.getCmp('mapview_cb').reset();
+                        }
+                        
                         this.classify(false);
                     },
                     scope: this



--
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.