dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25285
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12502: (PT, DV, GIS) Analysis integration.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 12502 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-10-08 15:27:18 +0200
message:
(PT,DV,GIS) Analysis integration.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
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
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/geojsonmin.vm
dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js
dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/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-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2013-10-04 12:27:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2013-10-08 13:23:38 +0000
@@ -349,7 +349,15 @@
public boolean hasCoordinatesUp()
{
- return parent != null && parent.parent != null && parent.parent.hasChildrenWithCoordinates();
+ if ( parent != null )
+ {
+ if ( parent.getParent() != null )
+ {
+ return parent.getParent().hasChildrenWithCoordinates();
+ }
+ }
+
+ return false;
}
public boolean hasCoordinates()
=== 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 2013-10-02 13:24:33 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js 2013-10-08 11:41:57 +0000
@@ -295,7 +295,7 @@
w.hasDestroyOnBlurHandler = true;
};
-
+
util.gui.window.setAnchorPosition = function(w, target) {
var vpw = gis.viewport.getWidth(),
targetx = target ? target.getPosition()[0] : 4,
@@ -309,41 +309,48 @@
w.setPosition(targetx, y);
}
};
-
+
util.layout = {};
-
+
util.layout.getAnalytical = function(map) {
var layout,
- id;
-
- map = map || gis.map;
-
- if (!(Ext.isObject(map) && Ext.isArray(map.mapViews) && map.mapViews.length)) {
- return;
+ layer;
+
+ if (Ext.isObject(map) && Ext.isArray(map.mapViews) && map.mapViews.length) {
+ for (var i = 0, view, id; i < map.mapViews.length; i++) {
+ view = map.mapViews[i];
+ id = view.layer;
+
+ if (gis.layer.hasOwnProperty(id) && gis.layer[id].layerCategory === gis.conf.finals.layer.category_thematic) {
+ layout = gis.api.layout.Layout(Ext.clone(view));
+
+ if (layout) {
+ return layout;
+ }
+ }
+ }
}
-
- for (var key in gis.layer) {
- if (gis.layer.hasOwnProperty(key) && gis.layer[key].layerCategory === gis.conf.finals.layer.category_thematic) {
- id = gis.layer[key].id;
-
- for (var j = 0, view; j < map.mapViews.length; j++) {
- view = map.mapViews[j];
-
- if (view.layer === id) {
- layout = gis.api.layout.Layout(Ext.clone(view));
-
- if (layout) {
- return layout;
+ else {
+ for (var key in gis.layer) {
+ if (gis.layer.hasOwnProperty(key) && gis.layer[key].layerCategory === gis.conf.finals.layer.category_thematic && gis.layer[key].core.view) {
+ layer = gis.layer[key];
+ layout = gis.api.layout.Layout(Ext.clone(layer.core.view));
+
+ if (layout) {
+ if (!layout.parentGraphMap && layer.widget) {
+ layout.parentGraphMap = layer.widget.getParentGraphMap();
}
+
+ return layout;
}
}
}
}
-
+
return;
};
-
- util.layout.setSessionStorage = function(obj, session, url) {
+
+ util.layout.setSessionStorage = function(session, obj, url) {
if (GIS.isSessionStorage) {
var dhis2 = JSON.parse(sessionStorage.getItem('dhis2')) || {};
dhis2[session] = obj;
@@ -358,17 +365,17 @@
// init
(function() {
-
+
// root nodes
for (var i = 0; i < init.rootNodes.length; i++) {
init.rootNodes[i].path = '/root/' + init.rootNodes[i].id;
}
-
+
// sort indicator groups
gis.util.object.sortObjectsByString(init.indicatorGroups);
-
+
// sort data element groups
- gis.util.object.sortObjectsByString(init.dataElementGroups);
+ gis.util.object.sortObjectsByString(init.dataElementGroups);
}());
// store
@@ -606,11 +613,11 @@
getValue: function() {
return this.checkbox.getValue();
},
- setValue: function(value, opacity) {
+ setValue: function(value, opacity) {
this.checkbox.setValue(value);
this.numberField.setDisabled(!value);
this.layer.setVisibility(value);
-
+
if (value) {
opacity = Ext.isNumber(parseFloat(opacity)) ? parseFloat(opacity) : this.opacity;
@@ -630,7 +637,7 @@
setOpacity: function(opacity) {
this.opacity = opacity === 0 ? 0.01 : opacity;
this.layer.setLayerOpacity(this.opacity);
-
+
if (this.layer.circleLayer) {
this.layer.circleLayer.setOpacity(this.opacity);
}
@@ -1034,12 +1041,12 @@
show: function() {
if (!this.isRendered) {
this.isRendered = true;
-
- if (this.view) {
- this.widget.setGui(this.view);
+
+ if (layer.core.view) {
+ this.widget.setGui(layer.core.view);
}
}
-
+
gis.util.gui.window.setPositionTopLeft(this);
}
}
@@ -1742,7 +1749,7 @@
userGroupRowContainer = Ext.create('Ext.container.Container', {
bodyStyle: 'border:0 none'
});
-
+
if (sharing.meta.allowExternalAccess) {
externalAccess = userGroupRowContainer.add({
xtype: 'checkbox',
@@ -1864,7 +1871,7 @@
// Vars
windowWidth = 500,
windowCmpWidth = windowWidth - 22,
-
+
dimConf = gis.conf.finals.dimension;
gis.store.maps.on('load', function(store, records) {
@@ -1924,7 +1931,7 @@
for (var j = 0; j < view.columns.length; j++) {
for (var k = 0, item; k < view.columns[j].items.length; k++) {
item = view.columns[j].items[k];
-
+
if (item.id.indexOf('-') !== -1) {
item.id = item.id.replace('-', '.');
}
@@ -3201,10 +3208,10 @@
var moduleUrl = gis.init.contextPath + '/dhis-web-mapping/app/index.html?id=' + gis.map.id,
apiUrl = gis.init.contextPath + '/api/maps/' + gis.map.id + '/data.html',
html = '';
-
+
html += '<div><b>GIS link: </b><span class="user-select"><a href="' + moduleUrl + '" target="_blank">' + moduleUrl + '</a></span></div>';
html += '<div style="padding-top:3px"><b>API link: </b><span class="user-select"><a href="' + apiUrl + '" target="_blank">' + apiUrl + '</a></span></div>';
-
+
return html;
}(),
style: 'padding-top: 8px; padding-bottom: 5px'
@@ -3311,7 +3318,7 @@
var infrastructuralDataElementValuesStore,
// Components
-
+
treePanel,
userOrganisationUnit,
userOrganisationUnitChildren,
@@ -3418,31 +3425,18 @@
}
});
},
- selectByGroup: function(id) {
- if (id) {
- var url = gis.init.contextPath + gis.conf.finals.url.path_module + gis.conf.finals.url.organisationunit_getbygroup,
- params = {id: id};
- this.select(url, params);
- }
- },
- selectByLevel: function(level) {
- if (level) {
- var url = gis.init.contextPath + gis.conf.finals.url.path_module + gis.conf.finals.url.organisationunit_getbylevel,
- params = {level: level};
- this.select(url, params);
- }
- },
- selectByIds: function(ids) {
- if (ids) {
- var url = gis.init.contextPath + gis.conf.finals.url.path_module + gis.conf.finals.url.organisationunit_getbyids;
- Ext.Array.each(ids, function(item) {
- url = Ext.String.urlAppend(url, 'ids=' + item);
- });
- if (!this.rendered) {
- gis.cmp.dimension.organisationUnit.panel.expand();
+ getParentGraphMap: function() {
+ var selection = this.getSelectionModel().getSelection(),
+ map = {};
+
+ if (Ext.isArray(selection) && selection.length) {
+ for (var i = 0, pathArray, key; i < selection.length; i++) {
+ pathArray = selection[i].getPath().split('/');
+ map[pathArray.pop()] = pathArray.join('/');
}
- this.select(url);
}
+
+ return map;
},
store: Ext.create('Ext.data.TreeStore', {
proxy: {
@@ -3646,7 +3640,7 @@
if (!param) {
return;
}
-
+
var items = this.items.items;
this.menuValue = param;
@@ -3744,22 +3738,22 @@
// Item
layer.item.setValue(false);
-
+
if (!layer.window.isRendered) {
return;
}
// Components
toolMenu.clickHandler(toolMenu.menuValue);
-
+
if (!skipTree) {
treePanel.reset();
}
-
+
userOrganisationUnit.setValue(false);
userOrganisationUnitChildren.setValue(false);
userOrganisationUnitGrandChildren.setValue(false);
-
+
organisationUnitLevel.clearValue();
organisationUnitGroup.clearValue();
@@ -3783,21 +3777,20 @@
groups = [],
setWidgetGui,
setLayerGui;
-
+
setWidgetGui = function() {
-
- // Components
+
+ // Components
if (!layer.window.isRendered) {
- layer.window.view = view;
return;
}
-
+
reset(true);
// Organisation units
for (var i = 0, item; i < ouDim.items.length; i++) {
item = ouDim.items[i];
-
+
if (item.id === 'USER_ORGUNIT') {
isOu = true;
}
@@ -3829,16 +3822,16 @@
userOrganisationUnitChildren.setValue(isOuc);
userOrganisationUnitGrandChildren.setValue(isOugc);
}
-
+
treePanel.numberOfRecords = gis.util.object.getLength(view.parentGraphMap);
-
+
for (var key in view.parentGraphMap) {
if (view.parentGraphMap.hasOwnProperty(key)) {
treePanel.multipleExpand(key, view.parentGraphMap[key], false);
}
}
}();
-
+
setLayerGui = function() {
// Layer item
@@ -3851,13 +3844,13 @@
getView = function(config) {
var view = {};
-
+
view.rows = [treePanel.getDimension()];
-
+
return validateView(view);
};
- validateView = function(view) {
+ validateView = function(view) {
if (!(Ext.isArray(view.rows) && view.rows.length && Ext.isString(view.rows[0].dimension) && Ext.isArray(view.rows[0].items) && view.rows[0].items.length)) {
GIS.logg.push([view.rows, layer.id + '.rows: dimension array']);
alert('No organisation units selected');
@@ -3875,6 +3868,9 @@
reset: reset,
setGui: setGui,
getView: getView,
+ getParentGraphMap: function() {
+ return treePanel.getParentGraphMap();
+ },
infrastructuralDataElementValuesStore: infrastructuralDataElementValuesStore,
@@ -3960,7 +3956,7 @@
colorHigh,
radiusLow,
radiusHigh,
-
+
treePanel,
userOrganisationUnit,
userOrganisationUnitChildren,
@@ -4298,7 +4294,7 @@
listeners: {
select: function() {
indicator.clearValue();
-
+
indicator.store.proxy.url = gis.init.contextPath + gis.conf.finals.url.path_api + 'indicatorGroups/' + this.getValue() + '.json?links=false&paging=false';
indicator.store.load();
}
@@ -4724,31 +4720,18 @@
}
});
},
- selectByGroup: function(id) {
- if (id) {
- var url = gis.init.contextPath + gis.conf.finals.url.path_module + gis.conf.finals.url.organisationunit_getbygroup,
- params = {id: id};
- this.select(url, params);
- }
- },
- selectByLevel: function(level) {
- if (level) {
- var url = gis.init.contextPath + gis.conf.finals.url.path_module + gis.conf.finals.url.organisationunit_getbylevel,
- params = {level: level};
- this.select(url, params);
- }
- },
- selectByIds: function(ids) {
- if (ids) {
- var url = gis.init.contextPath + gis.conf.finals.url.path_module + gis.conf.finals.url.organisationunit_getbyids;
- Ext.Array.each(ids, function(item) {
- url = Ext.String.urlAppend(url, 'ids=' + item);
- });
- if (!this.rendered) {
- gis.cmp.dimension.organisationUnit.panel.expand();
+ getParentGraphMap: function() {
+ var selection = this.getSelectionModel().getSelection(),
+ map = {};
+
+ if (Ext.isArray(selection) && selection.length) {
+ for (var i = 0, pathArray, key; i < selection.length; i++) {
+ pathArray = selection[i].getPath().split('/');
+ map[pathArray.pop()] = pathArray.join('/');
}
- this.select(url);
}
+
+ return map;
},
store: Ext.create('Ext.data.TreeStore', {
proxy: {
@@ -4950,7 +4933,7 @@
if (!param) {
return;
}
-
+
var items = this.items.items;
this.menuValue = param;
@@ -5120,22 +5103,22 @@
layer.labelWindow = null;
}
- // Components
+ // Components
if (!layer.window.isRendered) {
return;
}
-
+
valueType.reset();
valueTypeToggler(dimConf.indicator.objectName);
indicatorGroup.clearValue();
indicator.clearValue();
indicator.store.removeAll();
-
+
dataElementGroup.clearValue();
dataElement.clearValue();
dataElement.store.removeAll();
-
+
dataSet.clearValue();
dataSet.store.removeAll();
@@ -5147,24 +5130,24 @@
legendTypeToggler(gis.conf.finals.widget.legendtype_automatic);
legendSet.clearValue();
legendSet.store.removeAll();
-
+
classes.reset();
method.reset();
colorLow.reset();
colorHigh.reset();
radiusLow.reset();
radiusHigh.reset();
-
+
toolMenu.clickHandler(toolMenu.menuValue);
-
+
if (!skipTree) {
treePanel.reset();
}
-
+
userOrganisationUnit.setValue(false);
userOrganisationUnitChildren.setValue(false);
userOrganisationUnitGrandChildren.setValue(false);
-
+
organisationUnitLevel.clearValue();
organisationUnitGroup.clearValue();
};
@@ -5183,43 +5166,42 @@
groups = [],
setLayerGui,
setWidgetGui;
-
+
objectNameCmpMap[dimConf.indicator.objectName] = indicator;
objectNameCmpMap[dimConf.dataElement.objectName] = dataElement;
objectNameCmpMap[dimConf.operand.objectName] = dataElement;
objectNameCmpMap[dimConf.dataSet.objectName] = dataSet;
-
+
setWidgetGui = function() {
-
- // Components
+
+ // Components
if (!layer.window.isRendered) {
- layer.window.view = view;
return;
}
-
+
// Reset
reset(true);
// Value type
valueType.setValue(vType);
- valueTypeToggler(vType);
-
+ valueTypeToggler(vType);
+
if (vType === dimConf.dataElement.objectName) {
dataElementDetailLevel.setValue(dxDim.dimension);
}
-
+
// Data
objectNameCmpMap[dxDim.dimension].store.add(dxDim.items[0]);
objectNameCmpMap[dxDim.dimension].setValue(dxDim.items[0].id);
-
+
// Period
period.store.add(peDim.items[0])
period.setValue(peDim.items[0].id);
-
+
// Legend
legendType.setValue(lType);
legendTypeToggler(lType);
-
+
if (lType === gis.conf.finals.widget.legendtype_automatic) {
classes.setValue(view.classes);
method.setValue(view.method);
@@ -5236,7 +5218,7 @@
// Organisation units
for (var i = 0, item; i < ouDim.items.length; i++) {
item = ouDim.items[i];
-
+
if (item.id === 'USER_ORGUNIT') {
isOu = true;
}
@@ -5268,16 +5250,16 @@
userOrganisationUnitChildren.setValue(isOuc);
userOrganisationUnitGrandChildren.setValue(isOugc);
}
-
+
treePanel.numberOfRecords = gis.util.object.getLength(view.parentGraphMap);
-
+
for (var key in view.parentGraphMap) {
if (view.parentGraphMap.hasOwnProperty(key)) {
treePanel.multipleExpand(key, view.parentGraphMap[key], false);
}
}
}();
-
+
setLayerGui = function() {
// Layer item
@@ -5290,14 +5272,14 @@
if (layer.filterWindow && layer.filterWindow.isVisible()) {
layer.filterWindow.filter();
}
- }();
+ }();
};
getView = function(config) {
var vType = valueType.getValue() === dimConf.dataElement.objectName ? dataElementDetailLevel.getValue() : valueType.getValue(),
objectNameCmpMap = {},
view = {};
-
+
objectNameCmpMap[dimConf.indicator.objectName] = indicator;
objectNameCmpMap[dimConf.dataElement.objectName] = dataElement;
objectNameCmpMap[dimConf.operand.objectName] = dataElement;
@@ -5309,16 +5291,16 @@
id: objectNameCmpMap[vType].getValue()
}]
}];
-
+
view.rows = [treePanel.getDimension()];
-
+
view.filters = [{
dimension: dimConf.period.objectName,
items: [{
id: period.getValue()
}]
}];
-
+
view.classes = parseInt(classes.getValue());
view.method = parseInt(method.getValue());
view.colorLow = colorLow.getValue();
@@ -5326,7 +5308,7 @@
view.radiusLow = parseInt(radiusLow.getValue());
view.radiusHigh = parseInt(radiusHigh.getValue());
view.opacity = layer.item.getOpacity();
-
+
if (legendType.getValue() === gis.conf.finals.widget.legendtype_predefined && legendSet.getValue()) {
view.legendSet = {
id: legendSet.getValue()
@@ -5344,6 +5326,9 @@
reset: reset,
setGui: setGui,
getView: getView,
+ getParentGraphMap: function() {
+ return treePanel.getParentGraphMap();
+ },
infrastructuralDataElementValuesStore: infrastructuralDataElementValuesStore,
@@ -5422,7 +5407,7 @@
// Components
groupSet,
-
+
treePanel,
userOrganisationUnit,
userOrganisationUnitChildren,
@@ -5432,11 +5417,11 @@
toolMenu,
tool,
toolPanel,
-
+
areaRadius,
// Functions
-
+
//createSelectHandlers,
reset,
setGui,
@@ -5547,31 +5532,18 @@
}
});
},
- selectByGroup: function(id) {
- if (id) {
- var url = gis.init.contextPath + gis.conf.finals.url.path_module + gis.conf.finals.url.organisationunit_getbygroup,
- params = {id: id};
- this.select(url, params);
- }
- },
- selectByLevel: function(level) {
- if (level) {
- var url = gis.init.contextPath + gis.conf.finals.url.path_module + gis.conf.finals.url.organisationunit_getbylevel,
- params = {level: level};
- this.select(url, params);
- }
- },
- selectByIds: function(ids) {
- if (ids) {
- var url = gis.init.contextPath + gis.conf.finals.url.path_module + gis.conf.finals.url.organisationunit_getbyids;
- Ext.Array.each(ids, function(item) {
- url = Ext.String.urlAppend(url, 'ids=' + item);
- });
- if (!this.rendered) {
- gis.cmp.dimension.organisationUnit.panel.expand();
+ getParentGraphMap: function() {
+ var selection = this.getSelectionModel().getSelection(),
+ map = {};
+
+ if (Ext.isArray(selection) && selection.length) {
+ for (var i = 0, pathArray, key; i < selection.length; i++) {
+ pathArray = selection[i].getPath().split('/');
+ map[pathArray.pop()] = pathArray.join('/');
}
- this.select(url);
}
+
+ return map;
},
store: Ext.create('Ext.data.TreeStore', {
proxy: {
@@ -5775,7 +5747,7 @@
if (!param) {
return;
}
-
+
var items = this.items.items;
this.menuValue = param;
@@ -5898,23 +5870,23 @@
layer.circleLayer = null;
}
- // Components
+ // Components
if (!layer.window.isRendered) {
return;
}
-
+
groupSet.clearValue();
-
+
toolMenu.clickHandler(toolMenu.menuValue);
-
+
if (!skipTree) {
treePanel.reset();
}
-
+
userOrganisationUnit.setValue(false);
userOrganisationUnitChildren.setValue(false);
userOrganisationUnitGrandChildren.setValue(false);
-
+
organisationUnitLevel.clearValue();
organisationUnitGroup.clearValue();
@@ -5930,17 +5902,16 @@
groups = [],
setWidgetGui,
setLayerGui;
-
+
setWidgetGui = function() {
-
- // Components
+
+ // Components
if (!layer.window.isRendered) {
- layer.window.view = view;
return;
}
-
+
reset(true);
-
+
// Group set
groupSet.store.removeAll();
groupSet.store.add(view.organisationUnitGroupSet);
@@ -5949,7 +5920,7 @@
// Organisation units
for (var i = 0, item; i < ouDim.items.length; i++) {
item = ouDim.items[i];
-
+
if (item.id === 'USER_ORGUNIT') {
isOu = true;
}
@@ -5981,19 +5952,19 @@
userOrganisationUnitChildren.setValue(isOuc);
userOrganisationUnitGrandChildren.setValue(isOugc);
}
-
+
treePanel.numberOfRecords = gis.util.object.getLength(view.parentGraphMap);
-
+
for (var key in view.parentGraphMap) {
if (view.parentGraphMap.hasOwnProperty(key)) {
treePanel.multipleExpand(key, view.parentGraphMap[key], false);
}
}
-
+
// Area radius
areaRadius.setValue(!!view.areaRadius, !!view.areaRadius ? view.areaRadius : null);
}();
-
+
setLayerGui = function() {
// Layer item
@@ -6011,19 +5982,19 @@
getView = function(config) {
var view = {};
-
+
view.layer = layer.id;
-
+
view.rows = [treePanel.getDimension()];
-
+
view.organisationUnitGroupSet = {
id: groupSet.getValue()
};
-
+
view.areaRadius = areaRadius.getValue() ? areaRadius.getNumber() : null;
-
+
view.opacity = layer.item.getOpacity();
-
+
return validateView(view);
};
@@ -6033,7 +6004,7 @@
alert(GIS.i18n.no_groupset_selected);
return false;
}
-
+
if (!(Ext.isArray(view.rows) && view.rows.length && Ext.isString(view.rows[0].dimension) && Ext.isArray(view.rows[0].items) && view.rows[0].items.length)) {
GIS.logg.push([view.rows, layer.id + '.rows: dimension array']);
alert('No organisation units selected');
@@ -6051,6 +6022,9 @@
reset: reset,
setGui: setGui,
getView: getView,
+ getParentGraphMap: function() {
+ return treePanel.getParentGraphMap();
+ },
infrastructuralDataElementValuesStore: infrastructuralDataElementValuesStore,
@@ -6132,7 +6106,7 @@
defaultButton = Ext.create('Ext.button.Button', {
text: GIS.i18n.map,
- iconCls: 'gis-button-icon-table',
+ iconCls: 'gis-button-icon-map',
toggleGroup: 'module',
pressed: true,
handler: function() {
@@ -6141,7 +6115,7 @@
}
}
});
-
+
centerRegion = new GeoExt.panel.Map({
region: 'center',
map: gis.olmap,
@@ -6289,19 +6263,19 @@
{
text: 'Open this map as table' + ' ', //i18n
cls: 'gis-menu-item-noicon',
- disabled: !GIS.isSessionStorage || !gis.util.layout.getAnalytical(),
+ disabled: !(GIS.isSessionStorage && gis.util.layout.getAnalytical()),
handler: function() {
if (GIS.isSessionStorage) {
- gis.util.layout.setSessionStorage(gis.util.layout.getAnalytical(), 'analytical', gis.init.contextPath + '/dhis-web-pivot/app/index.html?s=analytical');
+ gis.util.layout.setSessionStorage('analytical', gis.util.layout.getAnalytical(), gis.init.contextPath + '/dhis-web-pivot/app/index.html?s=analytical');
}
}
},
{
text: 'Open last table' + ' ', //i18n
cls: 'gis-menu-item-noicon',
- disabled: !(GIS.isSessionStorage && JSON.parse(sessionStorage.getItem('dhis2')) && JSON.parse(sessionStorage.getItem('dhis2'))['chart']),
+ disabled: !(GIS.isSessionStorage && JSON.parse(sessionStorage.getItem('dhis2')) && JSON.parse(sessionStorage.getItem('dhis2'))['table']),
handler: function() {
- window.location.href = gis.init.contextPath + '/dhis-web-pivot/app/index.html?s=chart';
+ window.location.href = gis.init.contextPath + '/dhis-web-pivot/app/index.html?s=table';
}
}
],
@@ -6348,7 +6322,7 @@
disabled: !GIS.isSessionStorage || !gis.util.layout.getAnalytical(),
handler: function() {
if (GIS.isSessionStorage) {
- gis.util.layout.setSessionStorage(gis.util.layout.getAnalytical(), 'analytical', gis.init.contextPath + '/dhis-web-visualizer/app/index.html?s=analytical');
+ gis.util.layout.setSessionStorage('analytical', gis.util.layout.getAnalytical(), gis.init.contextPath + '/dhis-web-visualizer/app/index.html?s=analytical');
}
}
},
@@ -6549,7 +6523,7 @@
};
GIS.core.MapLoader(gis).load();
}
- else if (Ext.isString(session) && GIS.isSessionStorage && Ext.isObject(JSON.parse(sessionStorage.getItem('dhis2'))) && session in JSON.parse(sessionStorage.getItem('dhis2'))) {
+ else if (Ext.isString(session) && GIS.isSessionStorage && Ext.isObject(JSON.parse(sessionStorage.getItem('dhis2'))) && session in JSON.parse(sessionStorage.getItem('dhis2'))) {
layout = gis.api.layout.Layout(JSON.parse(sessionStorage.getItem('dhis2'))[session]);
if (layout) {
@@ -6643,8 +6617,7 @@
GIS.app.extendInstance(gis);
- gis.viewport = createViewport();
-console.log("gis", gis);
+ gis.viewport = createViewport();
}
});
}();
=== 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 2013-10-03 11:29:17 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js 2013-10-08 13:23:38 +0000
@@ -11,7 +11,7 @@
thematic_layer_2_legend: 'Thematic layer 2 legend',
thematic_layer_3_legend: 'Thematic layer 3 legend',
thematic_layer_4_legend: 'Thematic layer 4 legend',
- facility_layer_legend: 'Facility layer legend'
+ facility_layer_legend: 'Facility layer legend'
}
};
}
@@ -169,10 +169,10 @@
layer: layers.boundary,
gis: gis
});
-
+
for (var i = 0, number; i < layerNumbers.length; i++) {
- number = layerNumbers[i];
-
+ number = layerNumbers[i];
+
layers['thematic' + number] = GIS.core.VectorLayer(gis, 'thematic' + number, GIS.i18n.thematic_layer + ' ' + number, {opacity: 0.8});
layers['thematic' + number].layerCategory = gis.conf.finals.layer.category_thematic,
layers['thematic' + number].core = new mapfish.GeoStat['Thematic' + number](gis.olmap, {
@@ -228,7 +228,8 @@
drill,
menu,
selectHandlers,
- isPoint = feature.geometry.CLASS_NAME === gis.conf.finals.openLayers.point_classname;
+ isPoint = feature.geometry.CLASS_NAME === gis.conf.finals.openLayers.point_classname,
+ att = feature.attributes;
// Relocate
showRelocate = function() {
@@ -245,7 +246,7 @@
this.setWidth(this.getWidth() < minWidth ? minWidth : this.getWidth());
},
items: {
- html: feature.attributes.name,
+ html: att.name,
cls: 'gis-container-inner'
},
bbar: [
@@ -280,7 +281,7 @@
Ext.Ajax.request({
url: gis.init.contextPath + gis.conf.finals.url.path_module + 'getFacilityInfo.action',
params: {
- id: feature.attributes.id
+ id: att.id
},
success: function(r) {
var ou = Ext.decode(r.responseText);
@@ -305,8 +306,8 @@
items: function() {
var a = [];
- if (feature.attributes.name) {
- a.push({html: GIS.i18n.name, cls: 'gis-panel-html-title'}, {html: feature.attributes.name, cls: 'gis-panel-html'}, {cls: 'gis-panel-html-separator'});
+ if (att.name) {
+ a.push({html: GIS.i18n.name, cls: 'gis-panel-html-title'}, {html: att.name, cls: 'gis-panel-html'}, {cls: 'gis-panel-html-separator'});
}
if (ou.pa) {
@@ -367,7 +368,7 @@
layer.widget.infrastructuralDataElementValuesStore.load({
params: {
periodId: infrastructuralPeriod,
- organisationUnitId: feature.attributes.internalId
+ organisationUnitId: att.internalId
}
});
}
@@ -411,7 +412,7 @@
infrastructuralDataElementValuesStore.load({
params: {
periodId: infrastructuralPeriod,
- organisationUnitId: feature.attributes.internalId
+ organisationUnitId: att.internalId
}
});
}
@@ -426,19 +427,21 @@
};
// Drill or float
- drill = function(parent, level) {
+ drill = function(parentId, parentGraph, level) {
var view = Ext.clone(layer.core.view),
- items,
loader;
-
- items = [
- {id: parent},
- {id: 'LEVEL-' + level}
- ];
-
+
+ // parent graph map
+ view.parentGraphMap = {};
+ view.parentGraphMap[parentId] = parentGraph;
+console.log(view.parentGraphMap);
+ // dimension
view.rows = [{
dimension: dimConf.organisationUnit.objectName,
- items: items
+ items: [
+ {id: parentId},
+ {id: 'LEVEL-' + level}
+ ]
}];
if (view) {
@@ -455,18 +458,18 @@
Ext.create('Ext.menu.Item', {
text: 'Float up',
iconCls: 'gis-menu-item-icon-float',
- disabled: !feature.attributes.hasCoordinatesUp,
+ disabled: !att.hasCoordinatesUp,
handler: function() {
- drill(feature.attributes.grandParentId, parseInt(feature.attributes.level) - 1);
+ drill(att.grandParentId, att.grandParentParentGraph, parseInt(att.level) - 1);
}
}),
Ext.create('Ext.menu.Item', {
text: 'Drill down',
iconCls: 'gis-menu-item-icon-drill',
cls: 'gis-menu-item-first',
- disabled: !feature.attributes.hasCoordinatesDown,
+ disabled: !att.hasCoordinatesDown,
handler: function() {
- drill(feature.attributes.id, parseInt(feature.attributes.level) + 1);
+ drill(att.id, att.parentGraph, parseInt(att.level) + 1);
}
})
];
@@ -726,11 +729,11 @@
if (Ext.isArray(view.columns) && view.columns.length) {
for (var j = 0, dim; j < view.columns.length; j++) {
dim = view.columns[j];
-
+
if (Ext.isArray(dim.items) && dim.items.length) {
for (var k = 0, item; k < dim.items.length; k++) {
item = dim.items[k];
-
+
item.id = item.id.replace('.', '-');
}
}
@@ -760,13 +763,13 @@
alert(GIS.i18n.favorite_outdated_create_new);
return;
}
-
+
for (var i = 0; i < views.length; i++) {
views[i] = gis.api.layout.Layout(views[i]);
}
-
+
views = Ext.Array.clean(views);
-
+
if (!views.length) {
return;
}
@@ -779,7 +782,7 @@
for (var i = 0, layout; i < views.length; i++) {
layout = views[i];
-
+
loader = gis.layer[layout.layer].core.getLoader();
loader.updateGui = !gis.el;
loader.callBack = callBack;
@@ -820,7 +823,7 @@
loader = {
load: function(views) {
gis.olmap.mask.show();
-
+
if (gis.map && gis.map.id) {
getMap();
}
@@ -830,7 +833,7 @@
mapViews: views
};
}
-
+
setMap();
}
}
@@ -861,22 +864,22 @@
}
return gis.conf.finals.widget.loadtype_organisationunit;
}
-
+
viewIds = [];
viewDim = view.rows[0];
srcIds = [];
srcDim = src.rows[0];
-
+
// organisation units
- if (viewDim.items.length === srcDim.items.length) {
+ if (viewDim.items.length === srcDim.items.length) {
for (var i = 0; i < viewDim.items.length; i++) {
viewIds.push(viewDim.items[i].id);
}
-
+
for (var i = 0; i < srcDim.items.length; i++) {
srcIds.push(srcDim.items[i].id);
}
-
+
if (Ext.Array.difference(viewIds, srcIds).length !== 0) {
if (doExecute) {
loadOrganisationUnits(view);
@@ -897,19 +900,19 @@
loadOrganisationUnits = function(view) {
var items = view.rows[0].items,
idParamString = '';
-
+
for (var i = 0; i < items.length; i++) {
idParamString += 'ids=' + items[i].id;
idParamString += i !== items.length - 1 ? '&' : '';
}
-
+
Ext.data.JsonP.request({
url: gis.init.contextPath + gis.conf.finals.url.path_module + 'getGeoJson.action?' + idParamString,
scope: this,
disableCaching: false,
success: function(r) {
var geojson = gis.util.geojson.decode(r),
- format = new OpenLayers.Format.GeoJSON(),
+ format = new OpenLayers.Format.GeoJSON(),
features = gis.util.map.getTransformedFeatureArray(format.read(geojson));
if (!Ext.isArray(features)) {
@@ -1043,7 +1046,7 @@
viewDim,
srcIds,
srcDim;
-
+
loader.zoomToVisibleExtent = true;
if (!src) {
@@ -1052,22 +1055,22 @@
}
return gis.conf.finals.widget.loadtype_organisationunit;
}
-
+
// organisation units
viewIds = [];
viewDim = view.rows[0];
srcIds = [];
srcDim = src.rows[0];
-
- if (viewDim.items.length === srcDim.items.length) {
+
+ if (viewDim.items.length === srcDim.items.length) {
for (var i = 0; i < viewDim.items.length; i++) {
viewIds.push(viewDim.items[i].id);
}
-
+
for (var i = 0; i < srcDim.items.length; i++) {
srcIds.push(srcDim.items[i].id);
}
-
+
if (Ext.Array.difference(viewIds, srcIds).length !== 0) {
if (doExecute) {
loadOrganisationUnits(view);
@@ -1081,24 +1084,24 @@
}
return gis.conf.finals.widget.loadtype_organisationunit;
}
-
+
// data
loader.zoomToVisibleExtent = false;
-
+
viewIds = [];
viewDim = view.columns[0];
srcIds = [];
srcDim = src.columns[0];
-
+
if (viewDim.items.length === srcDim.items.length) {
for (var i = 0; i < viewDim.items.length; i++) {
viewIds.push(viewDim.items[i].id);
}
-
+
for (var i = 0; i < srcDim.items.length; i++) {
srcIds.push(srcDim.items[i].id);
}
-
+
if (Ext.Array.difference(viewIds, srcIds).length !== 0) {
if (doExecute) {
loadData(view);
@@ -1112,22 +1115,22 @@
}
return gis.conf.finals.widget.loadtype_organisationunit;
}
-
+
// period
viewIds = [];
viewDim = view.filters[0];
srcIds = [];
srcDim = src.filters[0];
-
- if (viewDim.items.length === srcDim.items.length) {
+
+ if (viewDim.items.length === srcDim.items.length) {
for (var i = 0; i < viewDim.items.length; i++) {
viewIds.push(viewDim.items[i].id);
}
-
+
for (var i = 0; i < srcDim.items.length; i++) {
srcIds.push(srcDim.items[i].id);
}
-
+
if (Ext.Array.difference(viewIds, srcIds).length !== 0) {
if (doExecute) {
loadData(view);
@@ -1141,8 +1144,8 @@
}
return gis.conf.finals.widget.loadtype_organisationunit;
}
-
- // legend
+
+ // legend
//if (typeof view.legendSet !== typeof src.legendSet) {
//if (doExecute) {
//loadLegend(view);
@@ -1160,7 +1163,7 @@
//}
//return gis.conf.finals.widget.loadtype_legend;
//}
-
+
// if no changes - reload legend but do not zoom
if (doExecute) {
loader.zoomToVisibleExtent = false;
@@ -1174,19 +1177,19 @@
loadOrganisationUnits = function(view) {
var items = view.rows[0].items,
idParamString = '';
-
+
for (var i = 0; i < items.length; i++) {
idParamString += 'ids=' + items[i].id;
idParamString += i !== items.length - 1 ? '&' : '';
}
-
+
Ext.data.JsonP.request({
url: gis.init.contextPath + gis.conf.finals.url.path_module + 'getGeoJson.action?' + idParamString,
scope: this,
disableCaching: false,
success: function(r) {
var geojson = gis.util.geojson.decode(r),
- format = new OpenLayers.Format.GeoJSON(),
+ format = new OpenLayers.Format.GeoJSON(),
features = gis.util.map.getTransformedFeatureArray(format.read(geojson));
if (!Ext.isArray(features)) {
@@ -1223,7 +1226,7 @@
// ou
paramString += 'dimension=ou:';
-
+
for (var i = 0; i < ouItems.length; i++) {
paramString += ouItems[i].id;
paramString += i < ouItems.length - 1 ? ';' : '';
@@ -1231,22 +1234,22 @@
// dx
paramString += '&dimension=dx:';
-
+
for (var i = 0; i < dxItems.length; i++) {
paramString += isOperand ? dxItems[i].id.split('-')[0] : dxItems[i].id;
paramString += i < dxItems.length - 1 ? ';' : '';
}
-
+
paramString += isOperand ? '&dimension=co' : '';
-
+
// pe
paramString += '&filter=pe:';
-
+
for (var i = 0; i < peItems.length; i++) {
paramString += peItems[i].id;
paramString += i < peItems.length - 1 ? ';' : '';
}
-
+
Ext.data.JsonP.request({
url: gis.init.contextPath + '/api/analytics.jsonp' + paramString,
disableCaching: false,
@@ -1261,7 +1264,7 @@
newFeatures = [],
dimensions,
items = [];
-
+
if (!response) {
alert(GIS.i18n.current_selection_no_data);
olmap.mask.hide();
@@ -1281,7 +1284,7 @@
// Feature map
for (var i = 0, id; i < features.length; i++) {
var id = features[i].attributes.id;
-
+
featureMap[id] = true;
}
@@ -1289,14 +1292,14 @@
for (var i = 0; i < response.rows.length; i++) {
var id = response.rows[i][ouIndex],
value = parseFloat(response.rows[i][valueIndex]);
-
+
valueMap[id] = value;
}
for (var i = 0; i < features.length; i++) {
var feature = features[i],
id = feature.attributes.id;
-
+
if (featureMap.hasOwnProperty(id) && valueMap.hasOwnProperty(id)) {
feature.attributes.value = valueMap[id];
feature.attributes.label = feature.attributes.name + ' (' + feature.attributes.value + ')';
@@ -1308,7 +1311,7 @@
layer.addFeatures(newFeatures);
layer.core.featureStore.loadFeatures(layer.features.slice(0));
-
+
gis.response = response;
loadLegend(view);
@@ -1320,23 +1323,23 @@
var bounds,
addNames,
fn;
-
+
view = view || layer.core.view;
-
+
addNames = function(response) {
-
+
// All dimensions
var dimensions = [].concat(view.columns || [], view.rows || [], view.filters || []),
metaData = response.metaData;
-
+
for (var i = 0, dimension; i < dimensions.length; i++) {
dimension = dimensions[i];
-
+
for (var j = 0, item; j < dimension.items.length; j++) {
item = dimension.items[j];
-
+
if (item.id.indexOf('-') !== -1) {
- var ids = item.id.split('-');
+ var ids = item.id.split('-');
item.name = metaData.names[ids[0]] + ' ' + metaData.names[ids[1]];
}
else {
@@ -1344,15 +1347,14 @@
}
}
}
-
+
// Period name without changing the id
view.filters[0].items[0].name = metaData.names[gis.response.metaData[dimConf.period.objectName][0]];
};
-
+
fn = function() {
-
addNames(gis.response);
-
+
// Classification options
var options = {
indicator: gis.conf.finals.widget.value,
@@ -1363,14 +1365,14 @@
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 = [],
@@ -1400,7 +1402,7 @@
names.push(legends[i].name);
bounds.push(legends[i].endValue);
}
-
+
view.legendSet.names = names;
view.legendSet.bounds = bounds;
view.legendSet.colors = colors;
@@ -1498,7 +1500,7 @@
viewDim,
srcIds,
srcDim;
-
+
loader.zoomToVisibleExtent = true;
if (!src) {
@@ -1507,22 +1509,22 @@
}
return gis.conf.finals.widget.loadtype_organisationunit;
}
-
+
// organisation units
viewIds = [];
viewDim = view.rows[0];
srcIds = [];
srcDim = src.rows[0];
-
+
if (viewDim.items.length === srcDim.items.length) {
for (var i = 0; i < viewDim.items.length; i++) {
viewIds.push(viewDim.items[i].id);
}
-
+
for (var i = 0; i < srcDim.items.length; i++) {
srcIds.push(srcDim.items[i].id);
}
-
+
if (Ext.Array.difference(viewIds, srcIds).length !== 0) {
if (doExecute) {
loadOrganisationUnits(view);
@@ -1536,7 +1538,7 @@
}
return gis.conf.finals.widget.loadtype_organisationunit;
}
-
+
// Group set
loader.zoomToVisibleExtent = false;
@@ -1553,8 +1555,8 @@
//}
//return gis.conf.finals.widget.loadtype_legend;
//}
-
- // always reload legend
+
+ // always reload legend
if (doExecute) {
loadLegend(view);
return gis.conf.finals.widget.loadtype_legend;
@@ -1566,12 +1568,12 @@
loadOrganisationUnits = function(view) {
var items = view.rows[0].items,
idParamString = '';
-
+
for (var i = 0; i < items.length; i++) {
idParamString += 'ids=' + items[i].id;
idParamString += i !== items.length - 1 ? '&' : '';
}
-
+
Ext.data.JsonP.request({
url: gis.init.contextPath + gis.conf.finals.url.path_module + 'getGeoJsonFacilities.action?' + idParamString,
scope: this,
@@ -1941,7 +1943,7 @@
level: doc.geojson[i].le,
grandParentParentGraph: doc.geojson[i].gppg,
grandParentId: doc.geojson[i].gpuid,
- path: doc.geojson[i].path,
+ parentGraph: doc.geojson[i].parentGraph,
parentId: doc.geojson[i].pi,
parentName: doc.geojson[i].pn
}
@@ -1959,9 +1961,9 @@
cmpArray[i].queryMode = mode;
}
};
-
+
util.object = {};
-
+
util.object.sortObjectsByString = function(array, key) {
key = key || 'name';
array.sort( function(a, b) {
@@ -1978,7 +1980,7 @@
});
return array;
};
-
+
util.object.getLength = function(object) {
var size = 0;
@@ -1999,10 +2001,10 @@
// api
(function() {
var dimConf = gis.conf.finals.dimension;
-
+
api.layout = {};
api.response = {};
-
+
api.layout.Record = function(config) {
var record = {};
@@ -2082,7 +2084,7 @@
var layout = {},
getValidatedDimensionArray,
validateSpecialCases;
-
+
// layer: string
// columns: [Dimension]
@@ -2104,7 +2106,7 @@
// radiusHigh: integer (15)
// opacity: integer (0.8) - 0-1
-
+
// legendSet: object
getValidatedDimensionArray = function(dimensionArray) {
@@ -2132,10 +2134,10 @@
dxDim,
peDim,
ouDim;
-
+
for (var i = 0, dim; i < dimensions.length; i++) {
dim = dimensions[i];
-
+
if (dim.dimension === dimConf.indicator.objectName ||
dim.dimension === dimConf.dataElement.objectName ||
dim.dimension === dimConf.operand.objectName ||
@@ -2149,13 +2151,13 @@
ouDim = dim;
}
}
-
+
config.columns = [dxDim];
config.rows = [ouDim];
config.filters = [peDim];
-
+
return config;
- };
+ };
return function() {
var a = [],
@@ -2164,7 +2166,7 @@
isOu = false,
isOuc = false,
isOugc = false;
-
+
config = validateSpecialCases(config);
config.columns = getValidatedDimensionArray(config.columns);
@@ -2225,9 +2227,9 @@
layout.userOrganisationUnitGrandChildren = isOugc;
layout.parentGraphMap = Ext.isObject(config.parentGraphMap) ? config.parentGraphMap : null;
-
+
layout.legendSet = config.legendSet;
-
+
layout.organisationUnitGroupSet = config.organisationUnitGroupSet;
layout.areaRadius = config.areaRadius;
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/geojsonmin.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/geojsonmin.vm 2013-09-23 15:14:11 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/geojsonmin.vm 2013-10-08 12:24:25 +0000
@@ -1,1 +1,1 @@
-#set($size=$object.size())#if($callback)$!{callback}(#end{"geojson":[#foreach($unit in $object){"ty":#if(${unit.featureType}=="Point")"2"#else"1"#end,"co":$!encoder.jsonEncode($!{unit.validCoordinates}),"uid":"$!{unit.uid}","iid":$!{unit.id},"na":"$!encoder.jsonEncode(${unit.name})","hcd":$!{unit.hasChildrenWithCoordinates()},"hcu":$!{unit.hasCoordinatesUp()},"le":$!{unit.getOrganisationUnitLevel()},"gppg":"$!{unit.parent.parent.getParentGraph()}","gpuid":"$!{unit.parent.parent.uid}","path":"$!{unit.getParentGraph()}/${unit.uid}","pi":"$!{unit.getParent().uid}","pn":"$!{unit.getParent().name}"}#if($velocityCount<$size),#end#end]}#if($callback))#end
\ No newline at end of file
+#set($size=$object.size())#if($callback)$!{callback}(#end{"geojson":[#foreach($unit in $object){"ty":#if(${unit.featureType}=="Point")"2"#else"1"#end,"co":$!encoder.jsonEncode($!{unit.validCoordinates}),"uid":"$!{unit.uid}","iid":$!{unit.id},"na":"$!encoder.jsonEncode(${unit.name})","hcd":$!{unit.hasChildrenWithCoordinates()},"hcu":$!{unit.hasCoordinatesUp()},"le":$!{unit.getOrganisationUnitLevel()},"gppg":"$!{unit.parent.parent.getParentGraph()}","gpuid":"$!{unit.parent.parent.uid}","parentGraph":"$!{unit.getParentGraph()}","pi":"$!{unit.getParent().uid}","pn":"$!{unit.getParent().name}"}#if($velocityCount<$size),#end#end]}#if($callback))#end
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2013-10-07 16:18:43 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2013-10-08 11:41:57 +0000
@@ -4319,11 +4319,11 @@
{
text: 'Open this table as chart' + ' ', //i18n
cls: 'pt-menu-item-noicon',
- disabled: !PT.isSessionStorage || !pt.layout,
+ disabled: !(PT.isSessionStorage && pt.layout),
handler: function() {
if (PT.isSessionStorage) {
pt.layout.parentGraphMap = treePanel.getParentGraphMap();
- pt.engine.setSessionStorage(pt.layout, 'analytical', pt.init.contextPath + '/dhis-web-visualizer/app/index.html?s=analytical');
+ pt.engine.setSessionStorage('analytical', pt.layout, pt.init.contextPath + '/dhis-web-visualizer/app/index.html?s=analytical');
}
}
},
@@ -4375,15 +4375,16 @@
{
text: 'Open this table as map' + ' ', //i18n
cls: 'pt-menu-item-noicon',
- disabled: !PT.isSessionStorage || !pt.layout,
+ disabled: !(PT.isSessionStorage && pt.layout),
handler: function() {
if (PT.isSessionStorage) {
- pt.engine.setSessionStorage(pt.layout, 'analytical', pt.init.contextPath + '/dhis-web-mapping/app/index.html?s=analytical');
+ pt.layout.parentGraphMap = treePanel.getParentGraphMap();
+ pt.engine.setSessionStorage('analytical', pt.layout, pt.init.contextPath + '/dhis-web-mapping/app/index.html?s=analytical');
}
}
},
{
- text: 'Open last chart' + ' ', //i18n
+ text: 'Open last map' + ' ', //i18n
cls: 'pt-menu-item-noicon',
disabled: !(PT.isSessionStorage && JSON.parse(sessionStorage.getItem('dhis2')) && JSON.parse(sessionStorage.getItem('dhis2'))['map']),
handler: function() {
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js 2013-10-07 16:28:57 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js 2013-10-08 09:53:16 +0000
@@ -1175,9 +1175,9 @@
return paramString;
};
- engine.setSessionStorage = function(obj, session, url) {
+ engine.setSessionStorage = function(session, obj, url) {
if (PT.isSessionStorage) {
- dhis2 = JSON.parse(sessionStorage.getItem('dhis2')) || {};
+ var dhis2 = JSON.parse(sessionStorage.getItem('dhis2')) || {};
dhis2[session] = obj;
sessionStorage.setItem('dhis2', JSON.stringify(dhis2));
@@ -1203,7 +1203,7 @@
uuidDimUuidsMap = {},
uuidObjectMap = {};
- isHierarchy = function(id, response) {
+ isHierarchy = function(id, response) {
return layout.showHierarchy && Ext.isObject(response.metaData.ouHierarchy) && response.metaData.ouHierarchy.hasOwnProperty(id);
};
@@ -2452,7 +2452,7 @@
else {
if (PT.isSessionStorage) {
setMouseHandlers();
- engine.setSessionStorage(layout, 'table');
+ engine.setSessionStorage('table', layout);
}
if (updateGui) {
@@ -2635,7 +2635,6 @@
uuids = pt.uuidDimUuidsMap[uuid],
layoutConfig = Ext.clone(pt.layout),
objects = [],
- dhis2,
menu;
// modify layout dimension items based on uuid objects
@@ -2674,7 +2673,7 @@
iconCls: 'pt-button-icon-chart',
param: 'chart',
handler: function() {
- that.setSessionStorage(layoutConfig, 'analytical', pt.init.contextPath + '/dhis-web-visualizer/app/index.html?s=analytical');
+ that.setSessionStorage('analytical', layoutConfig, pt.init.contextPath + '/dhis-web-visualizer/app/index.html?s=analytical');
},
listeners: {
render: function() {
@@ -2694,7 +2693,7 @@
param: 'map',
disabled: true,
handler: function() {
- that.setSessionStorage(layoutConfig, pt.init.contextPath + '/dhis-web-mapping/app/index.html?s=analytical');
+ that.setSessionStorage('analytical', layoutConfig, pt.init.contextPath + '/dhis-web-mapping/app/index.html?s=analytical');
},
listeners: {
render: function() {
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js 2013-10-07 16:18:43 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js 2013-10-08 09:53:16 +0000
@@ -1868,7 +1868,7 @@
userGroupRowContainer = Ext.create('Ext.container.Container', {
bodyStyle: 'border:0 none'
});
-
+
if (sharing.meta.allowExternalAccess) {
externalAccess = userGroupRowContainer.add({
xtype: 'checkbox',
@@ -3552,11 +3552,11 @@
},
multipleExpand: function(id, path, doUpdate) {
var rootId = dv.conf.finals.root.id;
-
+
if (path.substr(0, rootId.length + 1) !== ('/' + rootId)) {
path = '/' + rootId + path;
}
-
+
this.expandPath('/' + path, 'id', '/', function() {
var record = this.getRootNode().findChild('id', id, true);
this.recordsToSelect.push(record);
@@ -3581,6 +3581,19 @@
}
});
},
+ getParentGraphMap: function() {
+ var selection = this.getSelectionModel().getSelection(),
+ map = {};
+
+ if (Ext.isArray(selection) && selection.length) {
+ for (var i = 0, pathArray, key; i < selection.length; i++) {
+ pathArray = selection[i].getPath().split('/');
+ map[pathArray.pop()] = pathArray.join('/');
+ }
+ }
+
+ return map;
+ },
store: Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
@@ -3712,7 +3725,7 @@
if (!param) {
return;
}
-
+
var items = this.items.items;
this.menuValue = param;
@@ -4523,7 +4536,8 @@
disabled: !DV.isSessionStorage || !dv.layout,
handler: function() {
if (DV.isSessionStorage) {
- dv.engine.setSessionStorage(dv.layout, 'analytical', dv.init.contextPath + '/dhis-web-pivot/app/index.html?s=analytical');
+ dv.layout.parentGraphMap = treePanel.getParentGraphMap();
+ dv.engine.setSessionStorage('analytical', dv.layout, dv.init.contextPath + '/dhis-web-pivot/app/index.html?s=analytical');
}
}
},
@@ -4555,14 +4569,61 @@
},
defaultButton,
{
- text: DV.i18n.map,
- iconCls: 'dv-button-icon-map',
- toggleGroup: 'module',
- //menu: {},
- handler: function(b) {
- window.location.href = dv.init.contextPath + '/dhis-web-mapping/app/index.html';
- }
- },
+ text: DV.i18n.map,
+ iconCls: 'dv-button-icon-map',
+ toggleGroup: 'module',
+ menu: {},
+ handler: function(b) {
+ b.menu = Ext.create('Ext.menu.Menu', {
+ closeAction: 'destroy',
+ shadow: false,
+ showSeparator: false,
+ items: [
+ {
+ text: 'Go to maps' + ' ', //i18n
+ cls: 'dv-menu-item-noicon',
+ handler: function() {
+ window.location.href = dv.init.contextPath + '/dhis-web-mapping/app/index.html';
+ }
+ },
+ '-',
+ {
+ text: 'Open this chart as map' + ' ', //i18n
+ cls: 'dv-menu-item-noicon',
+ disabled: !DV.isSessionStorage || !dv.layout,
+ handler: function() {
+ if (DV.isSessionStorage) {
+ dv.layout.parentGraphMap = treePanel.getParentGraphMap();
+ dv.engine.setSessionStorage('analytical', dv.layout, dv.init.contextPath + '/dhis-web-mapping/app/index.html?s=analytical');
+ }
+ }
+ },
+ {
+ text: 'Open last map' + ' ', //i18n
+ cls: 'dv-menu-item-noicon',
+ disabled: !(DV.isSessionStorage && JSON.parse(sessionStorage.getItem('dhis2')) && JSON.parse(sessionStorage.getItem('dhis2'))['map']),
+ handler: function() {
+ window.location.href = dv.init.contextPath + '/dhis-web-mapping/app/index.html?s=chart';
+ }
+ }
+ ],
+ listeners: {
+ show: function() {
+ dv.util.window.setAnchorPosition(b.menu, b);
+ },
+ hide: function() {
+ b.menu.destroy();
+ defaultButton.toggle();
+ },
+ destroy: function(m) {
+ b.menu = null;
+ }
+ }
+ });
+
+ b.menu.show();
+ }
+ },
getSeparator(),
{
xtype: 'button',
@@ -4602,7 +4663,7 @@
// State
downloadButton.enable();
-
+
if (isFavorite) {
interpretationButton.enable();
}
@@ -4730,14 +4791,14 @@
userOrganisationUnitChildren.setValue(isOuc);
userOrganisationUnitGrandChildren.setValue(isOugc);
}
-
+
if (!(isOu || isOuc || isOugc)) {
// If fav has organisation units, wait for tree callback before update
if (Ext.isObject(graphMap)) {
treePanel.numberOfRecords = dv.util.object.getLength(graphMap);
- for (var key in graphMap) {
+ for (var key in graphMap) {
if (graphMap.hasOwnProperty(key)) {
treePanel.multipleExpand(key, graphMap[key], false);
}
@@ -4823,9 +4884,9 @@
url: '../initialize.action',
success: function(r) {
var init = Ext.decode(r.responseText);
-
+
DV.i18n = init.i18n;
-
+
dv = DV.core.getInstance(init);
DV.app.extendInstance(dv);
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js 2013-10-07 16:28:57 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js 2013-10-08 09:53:16 +0000
@@ -2,14 +2,14 @@
// ext config
Ext.Ajax.method = 'GET';
-
- // dv
+
+ // dv
DV = {
core: {
instances: []
- },
- i18n: {},
- isDebug: false,
+ },
+ i18n: {},
+ isDebug: false,
isSessionStorage: 'sessionStorage' in window && window['sessionStorage'] !== null
};
@@ -773,43 +773,43 @@
}();
};
}());
-
+
// service
(function() {
service.layout = {};
-
+
service.layout.getObjectNameDimensionMap = function(dimensionArray) {
var map = {};
-
- if (Ext.isArray(dimensionArray) && dimensionArray.length) {
+
+ if (Ext.isArray(dimensionArray) && dimensionArray.length) {
for (var i = 0, dim; i < dimensionArray.length; i++) {
dim = api.layout.Dimension(dimensionArray[i]);
-
+
if (dim) {
map[dim.dimension] = dim;
}
}
}
-
+
return map;
- };
-
+ };
+
service.layout.getObjectNameDimensionItemsMap = function(dimensionArray) {
var map = {};
-
- if (Ext.isArray(dimensionArray) && dimensionArray.length) {
+
+ if (Ext.isArray(dimensionArray) && dimensionArray.length) {
for (var i = 0, dim; i < dimensionArray.length; i++) {
dim = api.layout.Dimension(dimensionArray[i]);
-
+
if (dim) {
map[dim.dimension] = dim.items;
}
}
}
-
+
return map;
};
-
+
service.response = {};
}());
@@ -1073,9 +1073,9 @@
return paramString;
};
- engine.setSessionStorage = function(obj, session, url) {
+ engine.setSessionStorage = function(session, obj, url) {
if (DV.isSessionStorage) {
- dhis2 = JSON.parse(sessionStorage.getItem('dhis2')) || {};
+ var dhis2 = JSON.parse(sessionStorage.getItem('dhis2')) || {};
dhis2[session] = obj;
sessionStorage.setItem('dhis2', JSON.stringify(dhis2));
@@ -1089,7 +1089,7 @@
var getSyncronizedXLayout,
getExtendedResponse,
validateUrl,
-
+
getDefaultStore,
getDefaultNumericAxis,
getDefaultCategoryAxis,
@@ -1100,12 +1100,12 @@
getDefaultBaseLine,
getDefaultTips,
setDefaultTheme,
- getDefaultLegend,
+ getDefaultLegend,
getDefaultChartTitle,
getDefaultChartSizeHandler,
getDefaultChartTitlePositionHandler,
getDefaultChart,
-
+
generator = {},
afterLoad,
initialize;
@@ -1177,10 +1177,10 @@
responseOu = response.metaData[ou];
userOugc = [];
-
+
for (var j = 0, id; j < responseOu.length; j++) {
id = responseOu[j];
-
+
if (!Ext.Array.contains(userOuOuc, id)) {
userOugc.push({
id: id,
@@ -1197,14 +1197,14 @@
else if (isLevel || isGroup) {
for (var j = 0, responseOu = response.metaData[ou], id; j < responseOu.length; j++) {
id = responseOu[j];
-
+
dim.items.push({
id: id,
name: response.metaData.names[id]
});
}
- dim.items = pt.util.array.sortObjectsByString(dim.items);
+ dim.items = dv.util.array.sortObjectsByString(dim.items);
}
else {
dim.items = Ext.clone(xLayout.dimensionNameItemsMap[dim.dimensionName]);
@@ -2205,15 +2205,15 @@
};
afterLoad = function(layout, xLayout, xResponse) {
-
+
if (dv.isPlugin) {
-
+
}
else {
if (DV.isSessionStorage) {
- engine.setSessionStorage(layout, 'chart');
+ engine.setSessionStorage('chart', layout);
}
-
+
if (updateGui) {
dv.viewport.setGui(layout, xLayout, updateGui, isFavorite);
}
@@ -2294,7 +2294,7 @@
// Update viewport
dv.viewport.centerRegion.removeAll(true);
dv.viewport.centerRegion.add(chart);
-
+
afterLoad(layout, xLayout, xResponse);
}
});