dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19878
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8855: (GIS) Download image.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 8855 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-11-04 13:29:27 +0300
message:
(GIS) Download image.
removed:
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/download_22.png
added:
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/download_14.png
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/ext-ux/panel/LayerItemPanel.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/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
=== added file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/download_14.png'
Binary files dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/download_14.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/download_14.png 2012-11-04 10:23:39 +0000 differ
=== removed file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/download_22.png'
Binary files dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/download_22.png 2012-10-24 15:00:24 +0000 and dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/download_22.png 1970-01-01 00:00:00 +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 2012-11-04 09:20:14 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js 2012-11-04 10:23:39 +0000
@@ -287,15 +287,34 @@
};
GIS.util.map.getVisibleVectorLayers = function() {
- var a = [];
+ var layers = [],
+ layer;
+
for (var i = 0; i < GIS.map.layers.length; i++) {
- if (GIS.map.layers[i].layerType === GIS.conf.finals.layer.type_vector &&
- GIS.map.layers[i].visibility &&
- GIS.map.layers[i].features.length) {
- a.push(GIS.map.layers[i]);
- }
- }
- return a.length ? a : false;
+ layer = GIS.map.layers[i];
+ if (layer.layerType === GIS.conf.finals.layer.type_vector &&
+ layer.visibility &&
+ layer.features.length) {
+ layers.push(layer);
+ }
+ }
+ return layers;
+ };
+
+ GIS.util.map.hasVisibleFeatures = function() {
+ var layers = GIS.util.map.getVisibleVectorLayers(),
+ layer;
+
+ if (layers.length) {
+ for (var i = 0; i < layers.length; i++) {
+ layer = layers[i];
+ if (layer.features.length) {
+ return true;
+ }
+ }
+ }
+
+ return false;
};
GIS.util.map.getLayersByType = function(layerType) {
@@ -324,7 +343,7 @@
GIS.util.map.zoomToVisibleExtent = function() {
var bounds = GIS.util.map.getExtendedBounds(GIS.util.map.getVisibleVectorLayers());
- if (bounds) {
+ if (bounds.length) {
GIS.map.zoomToExtent(bounds);
}
};
@@ -416,6 +435,10 @@
x = 20,
y = 35,
center = GIS.cmp.region.center;
+
+ if (!layers.length) {
+ return false;
+ }
namespace = 'xmlns="http://www.w3.org/2000/svg"';
@@ -427,10 +450,6 @@
y += 35;
- if (!layers.length) {
- return false;
- }
-
for (var i = layers.length - 1; i > 0; i--) {
if (layers[i].base.id === GIS.base.facility.id) {
layers.splice(i, 1);
@@ -2758,78 +2777,61 @@
return window;
};
- GIS.obj.DownloadMenu = function() {
- var menu,
- item,
+ GIS.obj.DownloadWindow = function() {
+ var window,
textfield,
button;
textfield = Ext.create('Ext.form.field.Text', {
cls: 'gis-textfield',
- height: 28,
- emptyText: 'Enter map title..', //i18n
- style: 'margin-right: 2px'
+ height: 26,
+ width: 230,
+ fieldStyle: 'padding-left: 5px',
+ emptyText: 'Enter map title...' //i18n
});
button = Ext.create('Ext.button.Button', {
- width: 28,
- height: 28,
- iconCls: 'gis-btn-icon-download',
- style: 'border-radius: 1px',
+ text: 'Download', //i18n
handler: function() {
var title = textfield.getValue(),
svg = GIS.util.svg.getString(title, GIS.util.map.getVisibleVectorLayers()),
exportForm = document.getElementById('exportForm');
-
- if (svg) {
- document.getElementById('svgField').value = svg;
- document.getElementById('titleField').value = title;
- exportForm.action = '../exportImage.action';
- exportForm.method = 'post';
- exportForm.submit();
- }
- else {
+
+ if (!svg) {
alert('Please create a map first'); //todo //i18n
+ return;
}
- textfield.reset();
- menu.hide();
+ document.getElementById('svgField').value = svg;
+ document.getElementById('titleField').value = title;
+ exportForm.action = '../exportImage.action';
+ exportForm.method = 'post';
+ exportForm.submit();
+
+ window.destroy();
}
});
-
- item = Ext.create('Ext.panel.Panel', {
- layout: 'hbox',
- width: 185,
- height: 30,
- items: [
- textfield,
+
+ window = Ext.create('Ext.window.Window', {
+ title: 'Download map as PNG', //i18n
+ layout: 'fit',
+ iconCls: 'gis-window-title-icon-download',
+ cls: 'gis-container-default',
+ resizable: true,
+ modal: true,
+ items: textfield,
+ bbar: [
+ '->',
button
- ]
- });
-
- menu = Ext.create('Ext.menu.Menu', {
- shadow: false,
- showSeparator: false,
- enableKeyNav: false,
- width: 185,
- height: 30,
- cls: 'gis-menu',
- items: item,
- listeners: {
- afterrender: function() {
- this.getEl().addCls('gis-toolbar-btn-menu gis-toolbar-btn-menu-download');
- },
+ ],
+ listeners: {
show: function() {
- this.keyNav.disable();
- textfield.focus();
- },
- hide: function() {
- this.keyNav.enable();
+ this.setPosition(253, 37);
}
}
});
- return menu;
+ return window;
};
GIS.obj.InterpretationWindow = function() {
@@ -2838,7 +2840,6 @@
button;
textarea = Ext.create('Ext.form.field.TextArea', {
- xtype: 'textarea',
cls: 'gis-textarea',
height: 170,
emptyText: 'Write your interpretation...' //i18n
@@ -3218,7 +3219,29 @@
},
{
text: 'Download', //i18n
- menu: new GIS.obj.DownloadMenu()
+ menu: {},
+ disabled: true,
+ handler: function() {
+ if (GIS.cmp.downloadWindow && GIS.cmp.downloadWindow.destroy) {
+ GIS.cmp.downloadWindow.destroy();
+ }
+
+ GIS.cmp.downloadWindow = new GIS.obj.DownloadWindow();
+ GIS.cmp.downloadWindow.show();
+ },
+ xable: function() {
+ if (GIS.util.map.hasVisibleFeatures()) {
+ this.enable();
+ }
+ else {
+ this.disable();
+ }
+ },
+ listeners: {
+ added: function() {
+ GIS.cmp.downloadButton = this;
+ }
+ }
},
{
text: 'Share', //i18n
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/ext-ux/panel/LayerItemPanel.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/ext-ux/panel/LayerItemPanel.js 2012-10-31 15:54:48 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/ext-ux/panel/LayerItemPanel.js 2012-11-04 10:03:11 +0000
@@ -78,6 +78,8 @@
}
}
that.updateItem(value);
+
+ GIS.cmp.downloadButton.xable();
}
}
});
=== 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 2012-11-04 09:20:14 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/styles/style.css 2012-11-04 10:23:39 +0000
@@ -192,16 +192,6 @@
border-radius: 1px;
}
-.gis-toolbar-btn-menu-download .x-btn-icon,
-.gis-toolbar-btn-menu-download .x-btn-default-small-icon button {
- width: 28px !important;
- height: 28px !important;
-}
-
-.gis-btn-icon-download {
- background: url('../images/download_22.png') no-repeat;
-}
-
/* Toolbar */
.x-toolbar-default {
@@ -335,19 +325,7 @@
.x-menu-item-text {
font-size: 10px !important;
}
-
-.gis-toolbar-btn-menu-download .x-panel-body-default { /* Specific for download menu */
- border: 0 none;
-}
-.gis-toolbar-btn-menu-download .x-menu-body {
- background: transparent !important;
-}
-.gis-toolbar-btn-menu-download .x-panel-body-default {
- background: transparent;
-}
-.gis-toolbar-btn-menu-download .x-form-text {
- padding-left: 6px;
-}
+
/* Treepanel */
@@ -441,6 +419,9 @@
.gis-window-title-icon-legendset {
background: url('../images/legendset_14.png') no-repeat;
}
+.gis-window-title-icon-download {
+ background: url('../images/download_14.png') no-repeat;
+}
.gis-window-title-icon-interpretation {
background: url('../images/interpretation_14.png') no-repeat;
}