← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16140: GIS api logic bug fixed, json/jsonp separated, event popup bug fixed.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 16140 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-07-15 21:29:24 +0200
message:
  GIS api logic bug fixed, json/jsonp separated, event popup bug fixed.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.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-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2014-07-10 08:48:08 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2014-07-15 19:13:41 +0000
@@ -4269,7 +4269,7 @@
                 var attributes = attributeStorage[programId],
                     data = Ext.Array.clean([].concat(attributes || [], dataElements || []));
 
-				dataElementsByStageStore.loadData(dataElements);
+				dataElementsByStageStore.loadData(data);
 
                 if (layout) {
                     var dataDimensions = gis.util.layout.getDataDimensionsFromLayout(layout),

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js	2014-07-13 10:09:36 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js	2014-07-15 19:23:23 +0000
@@ -641,7 +641,7 @@
 
 		if (isEvent) {
 			options.onClickSelect = function fn(feature) {
-                var ignoreKeys = ['label', 'value', 'nameColumnMap', 'psi', 'ps', 'longitude', 'latitude', 'eventdate', 'ou', 'oucode', 'ouname'],
+                var ignoreKeys = ['label', 'value', 'nameColumnMap', 'psi', 'ps', 'longitude', 'latitude', 'eventdate', 'ou', 'oucode', 'ouname', 'popupText'],
                     attributes = feature.attributes,
                     map = attributes.nameColumnMap,
                     html = '<table class="padding1">',
@@ -1043,10 +1043,11 @@
 		};
 
 		loadData = function(view) {
-			view = view || layer.core.view;
-
             var paramString = '?',
-                features = [];
+                features = [],
+                success;
+
+			view = view || layer.core.view;
 
             // stage
             paramString += 'stage=' + view.stage.id;
@@ -1080,86 +1081,105 @@
                 //}
             }
 
-			Ext.data.JsonP.request({
-				url: gis.init.contextPath + '/api/analytics/events/query/' + view.program.id + '.jsonp' + paramString,
-				disableCaching: false,
-				scope: this,
-				success: function(r) {
-                    var events = [],
-                        features = [],
-                        rows = [],
-                        lonIndex,
-                        latIndex,
-                        map = Ext.clone(r.metaData.names);
-
-                    // name-column map, lonIndex, latIndex
-                    for (var i = 0; i < r.headers.length; i++) {
-                        map[r.headers[i].name] = r.headers[i].column;
-
-                        if (r.headers[i].name === 'longitude') {
-							lonIndex = i;
-						}
-
-						if (r.headers[i].name === 'latitude') {
-							latIndex = i;
-						}
-                    }
-
-					// get events with coordinates
-                    if (Ext.isArray(r.rows) && r.rows.length) {
-						for (var i = 0, row; i < r.rows.length; i++) {
-							row = r.rows[i];
-
-							if (row[lonIndex] && row[latIndex]) {
-								rows.push(row);
-							}
-						}
-					}
-
-                    if (!rows.length) {
-                        alert('No coordinates found');
-                        olmap.mask.hide();
-                        return;
-                    }
-
-                    // name-column map
-                    map = r.metaData.names;
-
-                    for (var i = 0; i < r.headers.length; i++) {
-                        map[r.headers[i].name] = r.headers[i].column;
-                    }
-
-                    // events
-                    for (var i = 0, row, obj; i < rows.length; i++) {
-                        row = rows[i];
-                        obj = {};
-
-                        for (var j = 0; j < row.length; j++) {
-                            obj[r.headers[j].name] = row[j];
+            success = function(r) {
+                var events = [],
+                    features = [],
+                    rows = [],
+                    lonIndex,
+                    latIndex,
+                    map = Ext.clone(r.metaData.names);
+
+                // name-column map, lonIndex, latIndex
+                for (var i = 0; i < r.headers.length; i++) {
+                    map[r.headers[i].name] = r.headers[i].column;
+
+                    if (r.headers[i].name === 'longitude') {
+                        lonIndex = i;
+                    }
+
+                    if (r.headers[i].name === 'latitude') {
+                        latIndex = i;
+                    }
+                }
+
+                // get events with coordinates
+                if (Ext.isArray(r.rows) && r.rows.length) {
+                    for (var i = 0, row; i < r.rows.length; i++) {
+                        row = r.rows[i];
+
+                        if (row[lonIndex] && row[latIndex]) {
+                            rows.push(row);
                         }
-
-                        obj[gis.conf.finals.widget.value] = 0;
-                        obj.label = obj.ouname;
-                        obj.nameColumnMap = map;
-
-                        events.push(obj);
-                    }
-
-                    // features
-                    for (var i = 0, event, point; i < events.length; i++) {
-                        event = events[i];
-
-                        point = gis.util.map.getTransformedPointByXY(event.longitude, event.latitude);
-
-                        features.push(new OpenLayers.Feature.Vector(point, event));
-                    }
-
-                    layer.removeFeatures(layer.features);
-                    layer.addFeatures(features);
-
-                    loadLegend(view);
-                }
-            });
+                    }
+                }
+
+                if (!rows.length) {
+                    alert('No event coordinates found');
+                    olmap.mask.hide();
+                    return;
+                }
+
+                // name-column map
+                map = r.metaData.names;
+
+                for (var i = 0; i < r.headers.length; i++) {
+                    map[r.headers[i].name] = r.headers[i].column;
+                }
+
+                // events
+                for (var i = 0, row, obj; i < rows.length; i++) {
+                    row = rows[i];
+                    obj = {};
+
+                    for (var j = 0; j < row.length; j++) {
+                        obj[r.headers[j].name] = row[j];
+                    }
+
+                    obj[gis.conf.finals.widget.value] = 0;
+                    obj.label = obj.ouname;
+                    obj.popupText = obj.ouname;
+                    obj.nameColumnMap = map;
+
+                    events.push(obj);
+                }
+
+                // features
+                for (var i = 0, event, point; i < events.length; i++) {
+                    event = events[i];
+
+                    point = gis.util.map.getTransformedPointByXY(event.longitude, event.latitude);
+
+                    features.push(new OpenLayers.Feature.Vector(point, event));
+                }
+
+                layer.removeFeatures(layer.features);
+                layer.addFeatures(features);
+
+                loadLegend(view);
+            };
+
+			if (Ext.isObject(GIS.app)) {
+				Ext.Ajax.request({
+					url: gis.init.contextPath + '/api/analytics/events/query/' + view.program.id + '.json' + paramString,
+					disableCaching: false,
+					failure: function(r) {
+						alert(r.responseText);
+					},
+					success: function(r) {
+						success(Ext.decode(r.responseText));
+					}
+				});
+			}
+			else if (Ext.isObject(GIS.plugin)) {
+				Ext.data.JsonP.request({
+					url: gis.init.contextPath + '/api/analytics/events/query/' + view.program.id + '.jsonp' + paramString,
+					disableCaching: false,
+					scope: this,
+					success: function(r) {
+						success(r);
+					}
+				});
+			}
 		};
 
 		loadLegend = function(view) {
@@ -3037,7 +3057,7 @@
                     layout.labelFontStyle = Ext.Array.contains(['normal', 'italic', 'oblique'], config.labelFontStyle) ? config.labelFontStyle : 'normal';
 
                     layout.labelFontColor = Ext.isString(config.labelFontColor) || Ext.isNumber(config.labelFontColor) ? config.labelFontColor : 'normal';
-                    layout.labelFontColor = Ext.isNumber(config.labelFontColor) ? config.labelFontColor.toString() : config.labelFontColor;
+                    layout.labelFontColor = Ext.isNumber(layout.labelFontColor) ? layout.labelFontColor.toString() : layout.labelFontColor;
                     layout.labelFontColor = layout.labelFontColor.charAt(0) !== '#' ? '#' + layout.labelFontColor : layout.labelFontColor;
 
                     layout.hidden = !!config.hidden;