dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36354
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18616: GIS app integration fix.
------------------------------------------------------------
revno: 18616
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-03-17 11:03:01 +0100
message:
GIS app integration fix.
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/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-apps/src/main/webapp/dhis-web-mapping/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js 2015-03-11 11:03:46 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js 2015-03-17 10:03:01 +0000
@@ -9282,7 +9282,7 @@
layout = gis.api.layout.Layout(JSON.parse(sessionStorage.getItem('dhis2'))[session]);
if (layout) {
- GIS.core.MapLoader(gis).load([layout]);
+ GIS.core.MapLoader(gis, true).load([layout]);
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js 2015-03-10 10:06:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js 2015-03-17 10:03:01 +0000
@@ -1048,7 +1048,7 @@
return window;
};
- GIS.core.MapLoader = function(gis) {
+ GIS.core.MapLoader = function(gis, isSession) {
var getMap,
setMap,
afterLoad,
@@ -1181,7 +1181,7 @@
lat = p.y;
}
- if (gis.el) {
+ if (gis.el || isSession) {
gis.olmap.zoomToVisibleExtent();
}
else {
@@ -2388,7 +2388,11 @@
};
loadLegend = function(view) {
- var bounds,
+ var bounds = [],
+ colors = [],
+ names = [],
+ legends = [],
+
addNames,
fn;
@@ -2429,34 +2433,29 @@
view.filters[0].items[0].name = metaData.names[peIds[peIds.length - 1]];
};
- fn = function() {
- addNames(gis.response);
-
- // Classification options
- var options = {
- indicator: gis.conf.finals.widget.value,
- method: view.legendSet ? mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS : view.method,
- numClasses: view.classes,
- bounds: bounds,
- colors: layer.core.getColors(view.colorLow, view.colorHigh),
- minSize: view.radiusLow,
- maxSize: view.radiusHigh
- };
-
- layer.core.view = view;
- layer.core.colorInterpolation = colors;
- layer.core.applyClassification(options);
-
- afterLoad(view);
- };
-
- if (view.legendSet) {
- var bounds = [],
- colors = [],
- names = [],
- legends = [];
-
- Ext.Ajax.request({
+ fn = function() {
+ addNames(gis.response);
+
+ // Classification options
+ var options = {
+ indicator: gis.conf.finals.widget.value,
+ method: view.legendSet ? mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS : view.method,
+ numClasses: view.classes,
+ bounds: bounds,
+ colors: layer.core.getColors(view.colorLow, view.colorHigh),
+ minSize: view.radiusLow,
+ maxSize: view.radiusHigh
+ };
+
+ layer.core.view = view;
+ layer.core.colorInterpolation = colors;
+ layer.core.applyClassification(options);
+
+ afterLoad(view);
+ };
+
+ loadLegendSet = function(view) {
+ Ext.Ajax.request({
url: gis.init.contextPath + '/api/legendSets/' + view.legendSet.id + '.json?fields=' + gis.conf.url.legendSetFields.join(','),
scope: this,
disableCaching: false,
@@ -2484,13 +2483,42 @@
view.legendSet.names = names;
view.legendSet.bounds = bounds;
view.legendSet.colors = colors;
-
+ },
+ callback: function() {
fn();
- }
+ }
});
- }
+ };
+
+ if (view.legendSet) {
+ loadLegendSet(view);
+ }
else {
- fn();
+ var elementMap = {
+ 'in': 'indicators',
+ 'de': 'dataElements',
+ 'ds': 'dataSets'
+ },
+ elementUrl = elementMap[view.columns[0].dimension],
+ id = view.columns[0].items[0].id;
+
+ Ext.Ajax.request({
+ url: gis.init.contextPath + '/api/' + elementUrl + '.json?fields=legendSet[id,name]&paging=false&filter=id:eq:' + id,
+ success: function(r) {
+ var set = Ext.decode(r.responseText)[elementUrl][0].legendSet;
+
+ if (set) {
+ view.legendSet = set;
+ loadLegendSet(view);
+ }
+ else {
+ fn();
+ }
+ },
+ failure: function() {
+ fn();
+ }
+ });
}
};