dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10652
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2921: (GIS) View history implemented.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2921 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-02-25 17:14:36 +0100
message:
(GIS) View history implemented.
added:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/images/history.png
modified:
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.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
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/images/history.png'
Binary files dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/images/history.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/images/history.png 2011-02-25 15:16:39 +0000 differ
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css 2011-02-08 15:54:31 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css 2011-02-25 15:16:39 +0000
@@ -104,6 +104,15 @@
}
/* Ext Menu */
+a.x-menu-item-custom {
+ padding: 2px 17px 3px 12px;
+}
+#viewhistory_m .x-menu-list {
+ background-color:#f1f1f1;
+}
+.x-menu-list-item {
+ font:10px lucida sans unicode,ubuntu,arial;
+}
.menu-layeroptions-locate {
background-image:url(../../../images/magnifier.png);
}
@@ -214,6 +223,9 @@
.x-btn .icon-admin {
background-image:url(../../../images/settings.png);
}
+.x-btn .icon-history {
+ background-image:url(../../../images/history.png);
+}
.x-btn .icon-exit {
background-image:url(../../../images/exit.png);
}
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js 2011-02-02 13:36:42 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js 2011-02-25 14:14:20 +0000
@@ -91,6 +91,12 @@
G.util = {
+ expandWidget: function(widget) {
+ var collapsed = widget == choropleth ? symbol : choropleth;
+ collapsed.collapse();
+ widget.expand();
+ },
+
/* Detect mapview parameter in URL */
getUrlParam: function(strParam) {
var output = '';
@@ -272,19 +278,19 @@
},
setKeepPosition: function(cb) {
- if (!cb.keepPosition) {
- cb.keepPosition = true;
- }
+ cb.keepPosition = !cb.keepPosition ? true : cb.keepPosition;
},
getTransformedPointByXY: function(x, y) {
var p = new OpenLayers.Geometry.Point(parseFloat(x), parseFloat(y));
return p.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
- },
+ },
getTransformedFeatureArray: function(features) {
+ var sourceProjection = new OpenLayers.Projection("EPSG:4326");
+ var destinationProjection = new OpenLayers.Projection("EPSG:900913");
for (var i = 0; i < features.length; i++) {
- features[i].geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
+ features[i].geometry.transform(sourceProjection, destinationProjection);
}
return features;
},
@@ -374,6 +380,40 @@
}
}
return overlays;
+ },
+
+ findArrayValue: function(array, value) {
+ for (var i = 0; i < array.length; i++) {
+ if (value == array[i]) {
+ return true;
+ }
+ }
+ return false;
+ },
+
+ compareObjToObj: function(obj1, obj2, exceptions) {
+ for (p in obj1) {
+ if (obj1[p] !== obj2[p]) {
+ if (!G.util.findArrayValue(exceptions, p)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+};
+
+G.date = {
+ getNowHMS: function(date) {
+ date = date || new Date();
+ return G.date.getDoubleDigit(date.getHours()) + ':' +
+ G.date.getDoubleDigit(date.getMinutes()) + ':' +
+ G.date.getDoubleDigit(date.getSeconds());
+ },
+
+ getDoubleDigit: function(unit) {
+ unit = '' + unit;
+ return unit.length < 2 ? '0' + unit : unit;
}
};
@@ -382,28 +422,6 @@
parameter: null,
- mapSourceType: {
- value: null,
- setDatabase: function() {
- this.value = G.conf.map_source_type_database;
- },
- setGeojson: function() {
- this.value = G.conf.map_source_type_geojson;
- },
- setShapefile: function() {
- this.value = G.conf.map_source_type_shapefile;
- },
- isDatabase: function() {
- return this.value == G.conf.map_source_type_database;
- },
- isGeojson: function() {
- return this.value == G.conf.map_source_type_geojson;
- },
- isShapefile: function() {
- return this.value == G.conf.map_source_type_shapefile;
- }
- },
-
mapDateType: {
value: null,
setFixed: function() {
@@ -413,10 +431,10 @@
this.value = G.conf.map_date_type_start_end;
},
isFixed: function() {
- return this.value == G.conf.map_date_type_fixed;
+ return this.value === G.conf.map_date_type_fixed;
},
isStartEnd: function() {
- return this.value == G.conf.map_date_type_start_end;
+ return this.value === G.conf.map_date_type_start_end;
}
},
@@ -429,10 +447,10 @@
this.value = G.conf.thematicMap2;
},
isPolygon: function() {
- return this.value == G.conf.thematicMap;
+ return this.value === G.conf.thematicMap;
},
isPoint: function() {
- return this.value == G.conf.thematicMap2;
+ return this.value === G.conf.thematicMap2;
}
},
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2011-02-08 15:54:31 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2011-02-25 15:55:39 +0000
@@ -2301,7 +2301,71 @@
helpWindow.show();
}
});
-
+
+ var viewHistoryButton = new Ext.Button({
+ id: 'viewhistory_b',
+ iconCls: 'icon-history',
+ addMenu: function() {
+ this.menu = new Ext.menu.Menu({
+ id: 'viewhistory_m',
+ defaults: {
+ itemCls: 'x-menu-item x-menu-item-custom'
+ },
+ items: [],
+ listeners: {
+ 'add': function(menu) {
+ var items = menu.items.items;
+ var keys = menu.items.keys;
+ items.unshift(items.pop());
+ keys.unshift(keys.pop());
+ },
+ 'click': function(menu, item, e) {
+ var mapView = item.mapView;
+ var scope = mapView.widget;
+ scope.mapView = mapView;
+ scope.updateValues = true;
+
+ scope.legend.value = mapView.mapLegendType;
+ scope.legend.method = mapView.method || scope.legend.method;
+ scope.legend.classes = mapView.classes || scope.legend.classes;
+
+ G.vars.map.setCenter(new OpenLayers.LonLat(mapView.longitude, mapView.latitude), mapView.zoom);
+ G.vars.mapDateType.value = mapView.mapDateType;
+ Ext.getCmp('mapdatetype_cb').setValue(G.vars.mapDateType.value);
+
+ scope.valueType.value = mapView.mapValueType;
+ scope.form.findField('mapvaluetype').setValue(scope.valueType.value);
+
+ G.util.expandWidget(scope);
+ scope.setMapView();
+ }
+ }
+ });
+ },
+ addItem: function(scope) {
+ if (!this.menu) {
+ this.addMenu();
+ }
+
+ var mapView = scope.formValues.getAllValues.call(scope);
+ mapView.widget = scope;
+ mapView.timestamp = new Date();
+ mapView.label = G.date.getNowHMS(mapView.timestamp) + ' ' + mapView.parentOrganisationUnitName + ' (' + mapView.organisationUnitLevelName + ')';
+
+ for (var i = 0; i < this.menu.items.items.length; i++) {
+ if (G.util.compareObjToObj(this.menu.items.items[i].mapView, mapView, ['longitude','latitude','zoom','widget','timestamp','label'])) {
+ this.menu.items.items[i].destroy();
+ }
+ }
+
+ this.menu.addMenuItem({
+ html: mapView.label,
+ mapView: mapView
+ });
+console.log(this.menu.items);
+ }
+ });
+
var exitButton = new Ext.Button({
text: G.i18n.exit_gis,
iconCls: 'icon-exit',
@@ -2327,6 +2391,8 @@
'-',
adminButton,
helpButton,
+ '-',
+ viewHistoryButton,
'->',
exitButton,' ',' '
]
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js 2011-02-08 00:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js 2011-02-25 14:14:20 +0000
@@ -1031,7 +1031,6 @@
prepareMapViewValueType: function() {
var obj = {};
-
if (this.valueType.isIndicator()) {
this.form.findField('indicatorgroup').showField();
this.form.findField('indicator').showField();
@@ -1141,7 +1140,6 @@
function valueTypeGroupStoreCallback() {
obj.components.valueTypeGroup.setValue(this.mapView[obj.mapView.valueTypeGroup]);
-
obj.stores.valueType.setBaseParam(obj.mapView.valueTypeGroup, obj.components.valueTypeGroup.getValue());
obj.stores.valueType.load({scope: this, callback: function() {
obj.components.valueType.setValue(this.mapView[obj.mapView.valueType]);
@@ -1366,30 +1364,34 @@
formValues: {
getAllValues: function() {
return {
- featureType: G.conf.map_feature_type_multipolygon,
- mapValueType: this.form.findField('mapvaluetype').getValue(),
- indicatorGroupId: this.form.findField('indicatorgroup').getValue(),
- indicatorId: this.form.findField('indicator').getValue(),
- dataElementGroupId: this.form.findField('dataelementgroup').getValue(),
- dataElementId: this.form.findField('dataelement').getValue(),
- periodTypeId: this.form.findField('periodtype').getValue(),
- periodId: this.form.findField('period').getValue(),
- startDate: this.form.findField('startdate').getValue(),
- endDate: this.form.findField('enddate').getValue(),
- parentOrganisationUnitId: this.organisationUnitSelection.parent.id,
- organisationUnitLevel: this.organisationUnitSelection.level.level,
- mapLegendType: this.form.findField('maplegendtype').getValue(),
- method: this.legend.value == G.conf.map_legend_type_automatic ? this.form.findField('method').getValue() : null,
- classes: this.legend.value == G.conf.map_legend_type_automatic ? this.form.findField('classes').getValue() : null,
- bounds: this.legend.value == G.conf.map_legend_type_automatic && this.legend.method == G.conf.classify_with_bounds ? this.form.findField('bounds').getValue() : null,
- colorLow: this.legend.value == G.conf.map_legend_type_automatic ? this.form.findField('startcolor').getValue() : null,
- colorHigh: this.legend.value == G.conf.map_legend_type_automatic ? this.form.findField('endcolor').getValue() : null,
- mapLegendSetId: this.form.findField('maplegendset').getValue(),
- radiusLow: null,
- radiusHigh: null,
- longitude: G.vars.map.getCenter().lon,
- latitude: G.vars.map.getCenter().lat,
- zoom: parseFloat(G.vars.map.getZoom())
+ featureType: G.conf.map_feature_type_multipolygon,
+ mapValueType: this.form.findField('mapvaluetype').getValue(),
+ indicatorGroupId: this.form.findField('indicatorgroup').getValue(),
+ indicatorId: this.form.findField('indicator').getValue(),
+ dataElementGroupId: this.form.findField('dataelementgroup').getValue(),
+ dataElementId: this.form.findField('dataelement').getValue(),
+ mapDateType: G.vars.mapDateType.value,
+ periodTypeId: this.form.findField('periodtype').getValue(),
+ periodId: this.form.findField('period').getValue(),
+ startDate: this.form.findField('startdate').getValue(),
+ endDate: this.form.findField('enddate').getValue(),
+ parentOrganisationUnitId: this.organisationUnitSelection.parent.id,
+ parentOrganisationUnitLevel: this.organisationUnitSelection.parent.level,
+ parentOrganisationUnitName: this.organisationUnitSelection.parent.name,
+ organisationUnitLevel: this.organisationUnitSelection.level.level,
+ organisationUnitLevelName: this.organisationUnitSelection.level.name,
+ mapLegendType: this.form.findField('maplegendtype').getValue(),
+ method: this.legend.value == G.conf.map_legend_type_automatic ? this.form.findField('method').getValue() : null,
+ classes: this.legend.value == G.conf.map_legend_type_automatic ? this.form.findField('classes').getValue() : null,
+ bounds: this.legend.value == G.conf.map_legend_type_automatic && this.legend.method == G.conf.classify_with_bounds ? this.form.findField('bounds').getValue() : null,
+ colorLow: this.legend.value == G.conf.map_legend_type_automatic ? this.form.findField('startcolor').getValue() : null,
+ colorHigh: this.legend.value == G.conf.map_legend_type_automatic ? this.form.findField('endcolor').getValue() : null,
+ mapLegendSetId: this.form.findField('maplegendset').getValue(),
+ radiusLow: null,
+ radiusHigh: null,
+ longitude: G.vars.map.getCenter().lon,
+ latitude: G.vars.map.getCenter().lat,
+ zoom: parseFloat(G.vars.map.getZoom())
};
},
@@ -1487,6 +1489,8 @@
},
applyValues: function() {
+ Ext.getCmp('viewhistory_b').addItem(this);
+
var options = {
indicator: 'value',
method: this.form.findField('method').getValue(),
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js 2011-02-08 00:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js 2011-02-25 14:14:20 +0000
@@ -96,7 +96,6 @@
classes: this.mapView.classes || this.legend.classes
};
- G.vars.parameter.id = false;
G.vars.map.setCenter(new OpenLayers.LonLat(this.mapView.longitude, this.mapView.latitude), this.mapView.zoom);
function mapViewStoreCallback() {
@@ -1360,12 +1359,16 @@
indicatorId: this.form.findField('indicator').getValue(),
dataElementGroupId: this.form.findField('dataelementgroup').getValue(),
dataElementId: this.form.findField('dataelement').getValue(),
+ mapDateType: G.vars.mapDateType.value,
periodTypeId: this.form.findField('periodtype').getValue(),
periodId: this.form.findField('period').getValue(),
startDate: this.form.findField('startdate').getValue(),
endDate: this.form.findField('enddate').getValue(),
parentOrganisationUnitId: this.organisationUnitSelection.parent.id,
+ parentOrganisationUnitLevel: this.organisationUnitSelection.parent.level,
+ parentOrganisationUnitName: this.organisationUnitSelection.parent.name,
organisationUnitLevel: this.organisationUnitSelection.level.level,
+ organisationUnitLevelName: this.organisationUnitSelection.level.name,
mapLegendType: this.form.findField('maplegendtype').getValue(),
method: this.legend.value == G.conf.map_legend_type_automatic ? this.form.findField('method').getValue() : null,
classes: this.legend.value == G.conf.map_legend_type_automatic ? this.form.findField('classes').getValue() : null,
@@ -1475,6 +1478,8 @@
},
applyValues: function() {
+ Ext.getCmp('viewhistory_b').addItem(this);
+
var options = {
indicator: 'value',
method: this.form.findField('method').getValue(),
@@ -1513,8 +1518,7 @@
this.coreComp = new mapfish.GeoStat.Symbol(this.map, coreOptions);
if (G.vars.parameter.id) {
- choropleth.collapse();
- this.expand();
+ G.util.expandWidget(this);
G.vars.parameter = false;
}
}