dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26603
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13158: (GIS) New sharemenuitem: Embed plugin config + (PT) Table layout bug fixed.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 13158 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-12-05 17:37:18 +0100
message:
(GIS) New sharemenuitem: Embed plugin config + (PT) Table layout bug fixed.
added:
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/dl_datasource.png
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/dl_tablelayout.png
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/map.js
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/app/styles/style.css
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/styles/style.css
--
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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/map.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/map.js 2013-11-26 12:24:35 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/map.js 2013-12-05 14:05:04 +0000
@@ -1194,8 +1194,8 @@
}
}
- if (gis.viewport.interpretationButton) {
- gis.viewport.interpretationButton.enable();
+ if (gis.viewport.shareButton) {
+ gis.viewport.shareButton.enable();
}
gis.olmap.mask.hide();
@@ -1399,7 +1399,7 @@
}
else {
gis.map = null;
- gis.viewport.interpretationButton.disable();
+ gis.viewport.shareButton.disable();
}
};
@@ -1867,8 +1867,8 @@
}
else {
gis.map = null;
- if (gis.viewport.interpretationButton) {
- gis.viewport.interpretationButton.disable();
+ if (gis.viewport.shareButton) {
+ gis.viewport.shareButton.disable();
}
}
};
@@ -2104,7 +2104,7 @@
}
else {
gis.map = null;
- gis.viewport.interpretationButton.disable();
+ gis.viewport.shareButton.disable();
}
};
=== added file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/dl_datasource.png'
Binary files dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/dl_datasource.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/dl_datasource.png 2013-12-05 14:05:04 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/dl_tablelayout.png'
Binary files dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/dl_tablelayout.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/dl_tablelayout.png 2013-12-05 14:05:04 +0000 differ
=== 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-11-29 11:52:49 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js 2013-12-05 16:36:13 +0000
@@ -88,6 +88,100 @@
return new OpenLayers.LonLat(point.x, point.y);
};
+ util.map.map2plugin = function(map) {
+ if (map.id) {
+ return {id: map.id};
+ }
+
+ delete map.access;
+ delete map.created;
+ delete lastUpdated;
+ delete name;
+
+ for (var i = 0, dimensions, layout; i < map.mapViews.length; i++) {
+ layout = map.mapViews[i];
+
+ dimensions = Ext.Array.clean([].concat(layout.columns || [], layout.rows || [], layout.filters || []));dimension = dimensions[i];
+
+ for (var j = 0, dimension; j < dimensions.length; j++) {
+ dimension = dimensions[j];
+
+ delete dimension.id;
+ delete dimension.ids;
+ delete dimension.type;
+ delete dimension.dimensionName;
+ delete dimension.objectName;
+
+ for (var k = 0, item; k < dimension.items.length; k++) {
+ item = dimension.items[k];
+
+ delete item.name;
+ delete item.code;
+ delete item.created;
+ delete item.lastUpdated;
+ }
+ }
+
+ if (layout.legendSet) {
+ delete layout.method;
+ delete layout.classes;
+ delete layout.colorLow;
+ delete layout.colorHigh;
+ delete layout.radiusLow;
+ delete layout.radiusHigh;
+ }
+ else {
+ if (layout.method === 2) {
+ delete layout.method;
+ }
+
+ if (layout.classes === 5) {
+ delete layout.classes;
+ }
+
+ if (layout.colorLow === "ff0000") {
+ delete layout.colorLow;
+ }
+
+ if (layout.colorHigh === "00ff00") {
+ delete layout.colorHigh;
+ }
+
+ if (layout.radiusLow === 5) {
+ delete layout.radiusLow;
+ }
+
+ if (layout.radiusHigh === 15) {
+ delete layout.radiusHigh;
+ }
+ }
+
+ if (layout.opacity === 0.8) {
+ delete layout.opacity;
+ }
+
+ if (!layout.userOrganisationUnit) {
+ delete layout.userOrganisationUnit;
+ }
+
+ if (!layout.userOrganisationUnitChildren) {
+ delete layout.userOrganisationUnitChildren;
+ }
+
+ if (!layout.userOrganisationUnitGrandChildren) {
+ delete layout.userOrganisationUnitGrandChildren;
+ }
+
+ if (!layout.organisationUnitGroupSet) {
+ delete layout.organisationUnitGroupSet;
+ }
+
+ delete layout.parentGraphMap;
+ }
+
+ return map;
+ };
+
util.url = util.url || {};
util.url.getUrlParam = function(s) {
@@ -336,6 +430,29 @@
return;
};
+ util.layout.getPluginConfig = function() {
+ var layers = gis.util.map.getVisibleVectorLayers(),
+ map = {};
+
+ if (gis.map) {
+ return gis.map;
+ }
+
+ map.mapViews = [];
+
+ for (var i = 0, layer; i < layers.length; i++) {
+ layer = layers[i];
+
+ if (layer.core.view) {
+ layer.core.view.layer = layer.id;
+
+ map.mapViews.push(layer.core.view);
+ }
+ }
+
+ return map;
+ };
+
util.layout.setSessionStorage = function(session, obj, url) {
if (GIS.isSessionStorage) {
var dhis2 = JSON.parse(sessionStorage.getItem('dhis2')) || {};
@@ -905,8 +1022,6 @@
text: GIS.i18n.close,
iconCls: 'gis-menu-item-icon-clear',
handler: function() {
- gis.viewport.interpretationButton.disable();
-
layer.core.reset();
}
};
@@ -1961,7 +2076,7 @@
gis.store.maps.loadStore();
- gis.viewport.interpretationButton.enable();
+ gis.viewport.shareButton.enable();
window.destroy();
}
@@ -2181,7 +2296,7 @@
params: Ext.encode(map),
success: function() {
gis.map = map;
- gis.viewport.interpretationButton.enable();
+ gis.viewport.shareButton.enable();
gis.store.maps.loadStore();
}
});
@@ -3189,7 +3304,6 @@
fieldStyle: 'padding-left: 4px; padding-top: 3px',
emptyText: GIS.i18n.write_your_interpretation
});
- console.log(gis);
panel = Ext.create('Ext.panel.Panel', {
cls: 'gis-container-inner',
@@ -6229,7 +6343,7 @@
var centerRegion,
eastRegion,
downloadButton,
- interpretationButton,
+ shareButton,
defaultButton,
layersPanel,
resizeButton,
@@ -6256,6 +6370,112 @@
}
});
+ interpretationItem = Ext.create('Ext.menu.Item', {
+ text: 'Write interpretation' + ' ',
+ iconCls: 'gis-menu-item-tablelayout',
+ disabled: true,
+ xable: function() {
+ if (gis.map) {
+ this.enable();
+ }
+ else {
+ this.disable();
+ }
+ },
+ handler: function() {
+ if (viewport.interpretationWindow) {
+ viewport.interpretationWindow.destroy();
+ viewport.interpretationWindow = null;
+ }
+
+ viewport.interpretationWindow = GIS.app.InterpretationWindow();
+ viewport.interpretationWindow.show();
+ }
+ });
+
+ pluginItem = Ext.create('Ext.menu.Item', {
+ text: 'Embed as plugin' + ' ',
+ iconCls: 'gis-menu-item-datasource',
+ disabled: true,
+ xable: function() {
+ if (gis.util.map.hasVisibleFeatures()) {
+ this.enable();
+ }
+ else {
+ this.disable();
+ }
+ },
+ handler: function() {
+ var textArea,
+ window;
+
+ textArea = Ext.create('Ext.form.field.TextArea', {
+ width: 400,
+ height: 200,
+ readOnly: true,
+ cls: 'gis-textarea monospaced',
+ value: JSON.stringify(gis.util.map.map2plugin(gis.util.layout.getPluginConfig()))
+ });
+
+ window = Ext.create('Ext.window.Window', {
+ title: 'Plugin configuration',
+ layout: 'fit',
+ modal: true,
+ resizable: false,
+ items: textArea,
+ destroyOnBlur: true,
+ bbar: [
+ '->',
+ {
+ text: 'Format',
+ handler: function() {
+ textArea.setValue(JSON.stringify(gis.util.map.map2plugin(gis.util.layout.getPluginConfig()), null, 2));
+
+ }
+ },
+ {
+ text: 'Select',
+ handler: function() {
+ textArea.selectText();
+ }
+ }
+ ],
+ listeners: {
+ show: function(w) {
+ this.setPosition(215, 33);
+ }
+ }
+ });
+
+ window.show();
+ }
+ });
+
+ shareButton = Ext.create('Ext.button.Button', {
+ text: GIS.i18n.share,
+ xableItems: function() {
+ interpretationItem.xable();
+ pluginItem.xable();
+ },
+ menu: {
+ cls: 'gis-menu',
+ shadow: false,
+ showSeparator: false,
+ items: [
+ interpretationItem,
+ pluginItem
+ ],
+ listeners: {
+ afterrender: function() {
+ this.getEl().addCls('gis-toolbar-btn-menu');
+ },
+ show: function() {
+ shareButton.xableItems();
+ }
+ }
+ }
+ });
+
centerRegion = new GeoExt.panel.Map({
region: 'center',
map: gis.olmap,
@@ -6361,24 +6581,7 @@
}
}
});
- a.push({
- text: GIS.i18n.share,
- menu: {},
- disabled: true,
- handler: function() {
- if (viewport.interpretationWindow && viewport.interpretationWindow.destroy) {
- viewport.interpretationWindow.destroy();
- }
-
- viewport.interpretationWindow = GIS.app.InterpretationWindow();
- viewport.interpretationWindow.show();
- },
- listeners: {
- added: function() {
- interpretationButton = this;
- }
- }
- });
+ a.push(shareButton);
a.push('->');
a.push({
@@ -6713,7 +6916,7 @@
eastRegion: eastRegion,
centerRegion: centerRegion,
downloadButton: downloadButton,
- interpretationButton: interpretationButton,
+ shareButton: shareButton,
layersPanel: layersPanel,
items: [
centerRegion,
=== 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-11-26 12:24:35 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js 2013-12-05 16:34:40 +0000
@@ -803,8 +803,8 @@
}
// interpretation button
- if (gis.map.id && gis.viewport.interpretationButton) {
- gis.viewport.interpretationButton.enable();
+ if (gis.map.id && gis.viewport.shareButton) {
+ gis.viewport.shareButton.enable();
}
// session storage
@@ -998,7 +998,6 @@
}
else {
gis.map = null;
- gis.viewport.interpretationButton.disable();
}
};
@@ -1450,8 +1449,7 @@
}
else {
gis.map = null;
- if (gis.viewport.interpretationButton) {
- gis.viewport.interpretationButton.disable();
+ if (gis.viewport.shareButton) {
}
}
@@ -1692,7 +1690,6 @@
}
else {
gis.map = null;
- gis.viewport.interpretationButton.disable();
}
};
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/styles/style.css 2013-11-29 11:52:49 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/styles/style.css 2013-12-05 16:34:40 +0000
@@ -560,6 +560,15 @@
padding-left: 18px;
}
+.gis-menu-item-tablelayout {
+ background-image:url('../images/dl_tablelayout.png');
+ padding-left: 18px;
+}
+.gis-menu-item-datasource {
+ background-image:url('../images/dl_datasource.png');
+ padding-left: 18px;
+}
+
/* Menu align */
.gis-btn-menu {
margin-top: 2px;
@@ -797,6 +806,12 @@
font-size: 11px;
}
+.gis-textarea.monospaced textarea {
+ font-family: monospace, consolas, courier new !important;
+ padding: 4px;
+ border: 0 none;
+}
+
/*----------------------------------------------------------------------------
* Checkbox
=== 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-12-05 12:11:45 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2013-12-05 14:36:45 +0000
@@ -4636,8 +4636,21 @@
openTableLayoutTab = function(type, isNewTab) {
if (ns.core.init.contextPath && ns.app.paramString) {
- var url = ns.core.init.contextPath + '/api/analytics.' + type + ns.core.web.analytics.getParamString(ns.app.xLayout);
- url += '&tableLayout=true&columns=' + ns.app.xLayout.columnDimensionNames.join(';') + '&rows=' + ns.app.xLayout.rowDimensionNames.join(';');
+ var colDimNames = Ext.clone(ns.app.xLayout.columnDimensionNames),
+ colObjNames = ns.app.xLayout.columnObjectNames,
+ rowDimNames = Ext.clone(ns.app.xLayout.rowDimensionNames),
+ rowObjNames = ns.app.xLayout.rowObjectNames,
+ dc = ns.core.conf.finals.dimension.operand.objectName,
+ co = ns.core.conf.finals.dimension.category.dimensionName,
+ columnNames = Ext.Array.clean([].concat(colDimNames, (Ext.Array.contains(colObjNames, dc) ? co : []))),
+ rowNames = Ext.Array.clean([].concat(rowDimNames, (Ext.Array.contains(rowObjNames, dc) ? co : []))),
+ url = '';
+
+ url += ns.core.init.contextPath + '/api/analytics.' + type;
+ url += ns.core.web.analytics.getParamString(ns.app.xLayout);
+ url += '&tableLayout=true';
+ url += '&columns=' + columnNames.join(';');
+ url += '&rows=' + rowNames.join(';');
window.open(url, isNewTab ? '_blank' : '_top');
}
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/styles/style.css 2013-12-04 17:23:27 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/styles/style.css 2013-12-05 16:34:40 +0000
@@ -985,4 +985,5 @@
.ns-textarea.monospaced textarea {
font-family: monospace, consolas, courier new;
padding: 4px;
+ border: 0 none;
}