← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4403: (GIS) Mapview management improved.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 4403 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-08-20 21:59:41 +0200
message:
  (GIS) Mapview management improved.
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/javascript/global.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/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/Point.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-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-08-19 21:17:43 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css	2011-08-20 19:30:37 +0000
@@ -141,6 +141,9 @@
 .menu-featureoptions-relocate {
     background-image:url('../../../images/relocate.png');
 }
+.menu-mapview {
+    background-image:url('../../../images/favorite.png');
+}
 .no-icon-menu .x-menu-item-icon {
     display: none;
 }
@@ -277,6 +280,12 @@
 .x-btn .icon-measure {
 	background-image:url('../../../images/measure.png');
 }
+.x-btn .icon-thematic1 {
+	background-image:url('../../../images/thematic1.png');
+}
+.x-btn .icon-thematic2 {
+	background-image:url('../../../images/thematic2.png');
+}
 .x-btn-noicon .x-btn-small .x-btn-text {
     height:16px;
     padding:0 5px;

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js	2011-08-20 12:01:15 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js	2011-08-20 19:52:17 +0000
@@ -492,6 +492,90 @@
             str = str.substr(0,len) + '..';
         }
         return str;
+    },
+    
+    mapView: {
+        layer: function(id) {
+            var w = new Ext.Window({
+                id: 'mapviewlayer_w',
+                title: '<span id="window-favorites-title">Favorite</span>',
+                layout: 'fit',
+                modal: true,
+                width: 150,
+                height: 98,
+                items: [
+                    {
+                        xtype: 'panel',
+                        bodyStyle: 'padding:14px;',
+                        items: [
+                            { html: 'Open in which layer?' }
+                        ]
+                    }
+                ],
+                bbar: [
+                    '->',
+                    {
+                        xtype: 'button',
+                        iconCls: 'icon-thematic1',
+                        hideLabel: true,
+                        handler: function() {
+                            G.util.mapView.prepare.call(choropleth, id);
+                            Ext.getCmp('mapviewlayer_w').destroy();
+                        }
+                    },
+                    {
+                        xtype: 'button',
+                        iconCls: 'icon-thematic2',
+                        hideLabel: true,
+                        handler: function() {
+                            G.util.mapView.prepare.call(point, id);
+                            Ext.getCmp('mapviewlayer_w').destroy();
+                        }
+                    }
+                ]                    
+            });
+            var c = Ext.getCmp('center').x;
+            var e = Ext.getCmp('east').x;
+            w.setPagePosition(c+((e-c)/2)-(w.width/2), Ext.getCmp('east').y + 100);
+            w.show();
+        },
+        
+        prepare: function(id) {
+            
+            if (!this.window.isShown) {
+                this.window.show();
+                this.window.hide();
+            }
+            var store = G.stores.mapView;
+            if (!store.isLoaded) {
+                store.load({scope: this, callback: function() {
+                    G.util.mapView.launch.call(this, id);
+                }});
+            }
+            else {
+                G.util.mapView.launch.call(this, id);
+            }
+        },
+        
+        launch: function(id) {
+            var store = G.stores.mapView;
+            this.mapView = store.getAt(store.find('id', id)).data;
+            this.updateValues = true;
+            
+            this.legend.value = this.mapView.mapLegendType;
+            this.legend.method = this.mapView.method || this.legend.method;
+            this.legend.classes = this.mapView.classes || this.legend.classes;
+
+            G.vars.map.setCenter(new OpenLayers.LonLat(this.mapView.longitude, this.mapView.latitude), this.mapView.zoom);
+            G.system.mapDateType.value = this.mapView.mapDateType;
+            Ext.getCmp('mapdatetype_cb').setValue(G.system.mapDateType.value);
+
+            this.valueType.value = this.mapView.mapValueType;
+            this.cmp.mapValueType.setValue(this.valueType.value);
+            
+            this.setMapView();
+            this.window.cmp.reset.enable();
+        }
     }
 };
 

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-08-20 02:34:06 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-08-20 19:15:25 +0000
@@ -550,13 +550,9 @@
                         params: params,
                         success: function(r) {
                             Ext.message.msg(true, G.i18n.favorite + ' <span class="x-msg-hl">' + vn + '</span> ' + G.i18n.registered);
-                            G.stores.mapView.load();
-                            if (params.featureType == G.conf.map_feature_type_multipolygon) {
-								G.stores.polygonMapView.load();
-							}
-							else if (params.featureType == G.conf.map_feature_type_point) {
-								G.stores.pointMapView.load();
-							}
+                            G.stores.mapView.load({callback: function() {
+                                favoriteButton.reloadMenu();
+                            }});
                             Ext.getCmp('favoritename_tf').reset();
                             Ext.getCmp('favoritesystem_chb').reset();
                         }
@@ -584,21 +580,15 @@
                                     Ext.message.msg(true, G.i18n.favorite + ' <span class="x-msg-hl">' + rw + '</span> ' + G.i18n.deleted);
                                     Ext.getCmp('favorite_cb').clearValue();
                                     
-                                    var featureType = G.stores.mapView.getAt(G.stores.mapView.findExact('id', v)).data.featureType;
-                                    if (featureType == G.conf.map_feature_type_multipolygon) {
-                                        G.stores.polygonMapView.load();
-                                    }
-                                    else if (featureType == G.conf.map_feature_type_point) {
-                                        G.stores.pointMapView.load();
-                                    }
-                                    
-                                    G.stores.mapView.load();
-                                    
-                                    if (v == choropleth.form.findField('mapview').getValue()) {
-                                        choropleth.form.findField('mapview').clearValue();
-                                    }
-                                    if (v == point.form.findField('mapview').getValue()) {
-                                        point.form.findField('mapview').clearValue();
+                                    G.stores.mapView.load({callback: function() {
+                                        favoriteButton.reloadMenu();
+                                    }});
+                                    
+                                    if (v == choropleth.cmp.mapview.getValue()) {
+                                        choropleth.cmp.mapView.clearValue();
+                                    }
+                                    if (v == point.cmp.mapview.getValue()) {
+                                        point.cmp.mapView.clearValue();
                                     }
                                 }
                             });
@@ -2231,7 +2221,16 @@
                     }
                 }
             }
-        ]
+        ],
+        listeners: {
+            'show': {
+                scope: choropleth,
+                fn: function() {
+                    this.cmp.parent.isLoaded = true;
+                    this.window.isShown = true;
+                }
+            }
+        }
     });    
     choropleth.window.setPagePosition(G.conf.window_x_left,G.conf.window_y_left);
     
@@ -2530,7 +2529,7 @@
                         Ext.getCmp('mapdatetype_cb').setValue(G.system.mapDateType.value);
 
                         scope.valueType.value = mapView.mapValueType;
-                        scope.form.findField('mapvaluetype').setValue(scope.valueType.value);
+                        scope.cmp.mapValueType.setValue(scope.valueType.value);
                         
                         G.util.expandWidget(scope);                        
                         scope.setMapView();
@@ -2570,19 +2569,64 @@
         }
     });
 	
-	var favoritesButton = new Ext.Button({
+	var favoriteButton = new Ext.Button({
 		iconCls: 'icon-favorite',
 		tooltip: G.i18n.favorite_map_views,
         style: 'margin-top:1px',
-		handler: function() {
-            if (!favoriteWindow.hidden) {
-				favoriteWindow.hide();
-			}
-			else {
-                favoriteWindow.setPagePosition(G.conf.window_x_left,G.conf.window_y_left);
-				favoriteWindow.show(this.id);
-			}
-		}
+        addMenuItems: function(store) {
+            this.menu.addItem('-');
+            
+            for (var i = 0; i < store.data.items.length; i++) {
+                var item = new Ext.menu.Item({
+                    text: store.data.items[i].data.name,
+                    iconCls: 'menu-mapview',
+                    mapViewId: store.data.items[i].data.id,
+                    scope: choropleth,
+                    handler: function(i) {
+                        G.util.mapView.layer(i.mapViewId);
+                    }
+                });
+                this.menu.addItem(item);
+            }            
+        },
+        reloadMenu: function() {
+            if (this.menu) {
+                this.menu.destroy();
+            }            
+            this.menu = new Ext.menu.Menu({
+                items: [
+                    {
+                        text: 'Manage favorites..',
+                        iconCls: 'menu-layeroptions-edit',
+                        scope: this,
+                        handler: function() {
+                            if (!favoriteWindow.hidden) {
+                                favoriteWindow.hide();
+                            }
+                            else {
+                                favoriteWindow.setPagePosition(G.conf.window_x_left,G.conf.window_y_left);
+                                favoriteWindow.show(this.id);
+                            }
+                        }
+                    }
+                ]
+            });
+            
+            var store = G.stores.mapView;            
+            if (!store.isLoaded) {
+                store.load({scope: this, callback: function() {
+                    this.addMenuItems(store);
+                }});
+            }
+            else {
+                this.addMenuItems(store);
+            }
+        },
+        listeners: {
+            'afterrender': function(b) {
+                b.reloadMenu();
+            }
+        }
 	});
 	
 	var predefinedMapLegendSetButton = new Ext.Button({
@@ -2738,7 +2782,7 @@
 			' ',' ',' ',
 			toolsLabel,
 			' ',' ',
-			favoritesButton,
+			favoriteButton,
             predefinedMapLegendSetButton,
 			exportImageButton,
             measureDistanceButton,
@@ -2888,6 +2932,11 @@
                 });
                 
                 document.getElementById('featuredatatext').innerHTML = '<div style="color:#666">' + G.i18n.no_feature_selected + '</div>';
+                
+                if (G.vars.parameter.id) {
+                    G.util.mapView.layer(G.vars.parameter.id);
+                    G.vars.parameter.id = null;
+                }
             }
         }
     });

=== 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-08-20 12:01:15 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-08-20 19:52:17 +0000
@@ -95,35 +95,6 @@
         this.addItems();
         
         this.createSelectFeatures();
-
-        if (G.vars.parameter.id) {
-            this.mapView = G.vars.parameter.mapView;
-            this.updateValues = true;
-            this.legend = {
-                value: this.mapView.mapLegendType,
-                method: this.mapView.method || this.legend.method,
-                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() {
-                this.cmp.mapview.setValue(this.mapView.id);
-                this.valueType.value = this.mapView.mapValueType;
-                this.cmp.mapValueType.setValue(this.valueType.value);
-                this.setMapView();
-            }
-            
-            if (G.stores.mapView.isLoaded) {
-                mapViewStoreCallback.call(this);
-            }
-            else {
-                G.stores.mapView.load({scope: this, callback: function() {
-                    mapViewStoreCallback.call(this);
-                }});
-            }
-        }
         
 		mapfish.widgets.geostat.Choropleth.superclass.initComponent.apply(this);
     },
@@ -307,22 +278,7 @@
                 'select': {
                     scope: this,
                     fn: function(cb) {
-                        this.mapView = G.stores.mapView.getAt(G.stores.mapView.find('id', cb.getValue())).data;
-                        this.updateValues = true;
-                        
-                        this.legend.value = this.mapView.mapLegendType;
-                        this.legend.method = this.mapView.method || this.legend.method;
-                        this.legend.classes = this.mapView.classes || this.legend.classes;
-
-                        G.vars.map.setCenter(new OpenLayers.LonLat(this.mapView.longitude, this.mapView.latitude), this.mapView.zoom);
-                        G.system.mapDateType.value = this.mapView.mapDateType;
-                        Ext.getCmp('mapdatetype_cb').setValue(G.system.mapDateType.value);
-
-                        this.valueType.value = this.mapView.mapValueType;
-                        this.cmp.mapValueType.setValue(this.valueType.value);
-                        this.setMapView();
-                        
-                        this.window.cmp.reset.enable();
+                        G.util.mapView.prepare.call(this, cb.getValue());
                     }
                 }
             }
@@ -894,6 +850,7 @@
                 expanded: true
             },
             widget: this,
+            isLoaded: false,
             isSelected: false,
             reset: function() {
                 if (this.getSelectionModel().getSelectedNode()) {
@@ -1431,7 +1388,8 @@
         this.organisationUnitSelection.setValues(this.mapView.parentOrganisationUnitId, this.mapView.parentOrganisationUnitName,
             this.mapView.parentOrganisationUnitLevel, this.mapView.organisationUnitLevel, this.mapView.organisationUnitLevelName);
             
-        this.cmp.parent.reset();
+        //this.cmp.parent.reset();
+        
         this.cmp.parent.selectedNode = {attributes: {
             id: this.mapView.parentOrganisationUnitId,
             text: this.mapView.parentOrganisationUnitName,

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js	2011-08-20 12:01:15 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js	2011-08-20 19:52:17 +0000
@@ -95,35 +95,6 @@
         this.addItems();
         
         this.createSelectFeatures();
-
-        if (G.vars.parameter.id) {
-            this.mapView = G.vars.parameter.mapView;
-            this.updateValues = true;
-            this.legend = {
-                value: this.mapView.mapLegendType,
-                method: this.mapView.method || this.legend.method,
-                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() {
-                this.cmp.mapview.setValue(this.mapView.id);
-                this.valueType.value = this.mapView.mapValueType;
-                this.cmp.mapValueType.setValue(this.valueType.value);
-                this.setMapView();
-            }
-            
-            if (G.stores.mapView.isLoaded) {
-                mapViewStoreCallback.call(this);
-            }
-            else {
-                G.stores.mapView.load({scope: this, callback: function() {
-                    mapViewStoreCallback.call(this);
-                }});
-            }
-        }
         
 		mapfish.widgets.geostat.Point.superclass.initComponent.apply(this);
     },
@@ -307,22 +278,7 @@
                 'select': {
                     scope: this,
                     fn: function(cb) {
-                        this.mapView = G.stores.mapView.getAt(G.stores.mapView.find('id', cb.getValue())).data;
-                        this.updateValues = true;
-                        
-                        this.legend.value = this.mapView.mapLegendType;
-                        this.legend.method = this.mapView.method || this.legend.method;
-                        this.legend.classes = this.mapView.classes || this.legend.classes;
-
-                        G.vars.map.setCenter(new OpenLayers.LonLat(this.mapView.longitude, this.mapView.latitude), this.mapView.zoom);
-                        G.system.mapDateType.value = this.mapView.mapDateType;
-                        Ext.getCmp('mapdatetype_cb').setValue(G.system.mapDateType.value);
-
-                        this.valueType.value = this.mapView.mapValueType;
-                        this.cmp.mapValueType.setValue(this.valueType.value);
-                        this.setMapView();
-                        
-                        this.window.cmp.reset.enable();
+                        G.util.mapView.prepare.call(this, cb.getValue());
                     }
                 }
             }