=== 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-03-29 11:26:20 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js 2011-03-30 10:29:53 +0000 @@ -221,28 +221,6 @@ autoLoad: false, isLoaded: false, listeners: { - 'load': function(store) { - store.isLoaded = true; - - if (!symbol.form.findField('level').getValue()) { - if (this.isLoaded) { - var data = this.getAt(this.getTotalCount()-1).data; - symbol.organisationUnitSelection.setValues(null, null, null, data.level, data.name); - symbol.form.findField('level').setValue(data.name); - } - } - } - } - }); - - var polygonOrganisationUnitLevelStore = new Ext.data.JsonStore({ - url: G.conf.path_mapping + 'getOrganisationUnitLevelsByFeatureType' + G.conf.type, - baseParams: {featureType: G.conf.map_feature_type_multipolygon}, - root: 'organisationUnitLevels', - fields: ['id', 'level', 'name'], - autoLoad: false, - isLoaded: false, - listeners: { 'load': G.func.storeLoadListener } }); @@ -280,19 +258,6 @@ } }); - var baseLayerStore = new Ext.data.JsonStore({ - url: G.conf.path_mapping + 'getMapLayersByType' + G.conf.type, - baseParams: {type: G.conf.map_layer_type_baselayer}, - root: 'mapLayers', - fields: ['id', 'name', 'type', 'mapSource', 'layer', 'fillColor', 'fillOpacity', 'strokeColor', 'strokeWidth'], - sortInfo: {field: 'name', direction: 'ASC'}, - autoLoad: false, - isLoaded: false, - listeners: { - 'load': G.func.storeLoadListener - } - }); - var overlayStore = new Ext.data.JsonStore({ url: G.conf.path_mapping + 'getMapLayersByType' + G.conf.type, baseParams: {type: G.conf.map_layer_type_overlay}, @@ -306,16 +271,6 @@ } }); - var userSettingStore = new Ext.data.JsonStore({ - url: G.conf.path_mapping + 'getMapUserSettings' + G.conf.type, - fields: ['mapDateType'], - autoLoad: false, - isLoaded: false, - listeners: { - 'load': G.func.storeLoadListener - } - }); - G.stores = { mapView: mapViewStore, polygonMapView: polygonMapViewStore, @@ -331,11 +286,9 @@ predefinedMapLegend: predefinedMapLegendStore, predefinedMapLegendSet: predefinedMapLegendSetStore, organisationUnitLevel: organisationUnitLevelStore, - polygonOrganisationUnitLevel: polygonOrganisationUnitLevelStore, organisationUnitsAtLevel: organisationUnitsAtLevelStore, geojsonFiles: geojsonFilesStore, wmsCapabilities: wmsCapabilitiesStore, - baseLayer: baseLayerStore, overlay: overlayStore }; @@ -2317,12 +2270,6 @@ listeners: { 'expand': function() { G.vars.activePanel.setPoint(); - - if (!this.form.findField('level').getValue()) { - if (!G.stores.organisationUnitLevel.isLoaded) { - G.stores.organisationUnitLevel.load(); - } - } }, 'afterrender': function() { this.layer.widget = this; === 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-03-29 10:27:11 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js 2011-03-30 10:34:03 +0000 @@ -586,7 +586,6 @@ xtype: 'textfield', name: 'boundary', fieldLabel: G.i18n.boundary, - editable: false, emptyText: G.conf.emptytext, labelSeparator: G.conf.labelseparator, width: G.conf.combo_width, @@ -614,7 +613,6 @@ xtype: 'textfield', name: 'level', fieldLabel: G.i18n.level, - editable: false, emptyText: G.conf.emptytext, labelSeparator: G.conf.labelseparator, width: G.conf.combo_width, @@ -919,7 +917,7 @@ fieldLabel: 'Level', width: G.conf.combo_width_fieldset, minListWidth: G.conf.combo_width_fieldset, - store: G.stores.polygonOrganisationUnitLevel, + store: G.stores.organisationUnitLevel, listeners: { 'afterrender': { scope: this, @@ -968,8 +966,8 @@ ] }); - var x = Ext.getCmp('center').x + 15; - var y = Ext.getCmp('center').y + 41; + var x = Ext.getCmp('center').x + G.conf.window_position_x; + var y = Ext.getCmp('center').y + G.conf.window_position_y; w.setPosition(x,y); w.show(); this.form.findField('boundary').treeWindow = w; @@ -1430,7 +1428,7 @@ this.form.findField('bounds').reset(); this.layer.destroyFeatures(); - this.layer.setVisibility(false); + this.layer.setVisibility(false); } }, @@ -1474,7 +1472,7 @@ parentId: this.organisationUnitSelection.parent.id, level: this.organisationUnitSelection.level.level }; - + Ext.Ajax.request({ url: G.conf.path_mapping + dataUrl + G.conf.type, method: 'POST', === 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-03-29 10:27:11 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js 2011-03-30 10:34:03 +0000 @@ -585,7 +585,6 @@ xtype: 'textfield', name: 'boundary', fieldLabel: G.i18n.boundary, - editable: false, emptyText: G.conf.emptytext, labelSeparator: G.conf.labelseparator, width: G.conf.combo_width, @@ -593,7 +592,7 @@ node: {attributes: {hasChildrenWithCoordinates: false}}, selectedNode: null, treeWindow: null, - treePanel: null, + treePanel: null, listeners: { 'focus': { scope: this, @@ -613,13 +612,24 @@ xtype: 'textfield', name: 'level', fieldLabel: G.i18n.level, - disabled: true, - disabledClass: 'combo-disabled', - editable: false, emptyText: G.conf.emptytext, labelSeparator: G.conf.labelseparator, width: G.conf.combo_width, - levelComboBox: null + style: 'cursor:pointer', + levelComboBox: null, + listeners: { + 'focus': { + scope: this, + fn: function() { + if (this.form.findField('boundary').treeWindow) { + this.form.findField('boundary').treeWindow.show(); + } + else { + this.createSingletonCmp.treeWindow.call(this); + } + } + } + } }, { html: '
' }, @@ -878,7 +888,7 @@ }; var w = new Ext.Window({ - title: 'Boundary', + title: 'Boundary and level', closeAction: 'hide', autoScroll: true, height: 'auto', @@ -925,6 +935,40 @@ } } ] + }, + { + xtype: 'panel', + layout: 'form', + bodyStyle: 'padding:8px; background-color:#ffffff', + labelWidth: G.conf.label_width, + items: [ + {html: '
Select organisation unit level
'}, + { + xtype: 'combo', + fieldLabel: G.i18n.level, + editable: false, + valueField: 'level', + displayField: 'name', + mode: 'remote', + forceSelection: true, + triggerAction: 'all', + selectOnFocus: true, + emptyText: G.conf.emptytext, + labelSeparator: G.conf.labelseparator, + fieldLabel: 'Level', + width: G.conf.combo_width_fieldset, + minListWidth: G.conf.combo_width_fieldset, + store: G.stores.organisationUnitLevel, + listeners: { + 'afterrender': { + scope: this, + fn: function(cb) { + this.form.findField('level').levelComboBox = cb; + } + } + } + } + ] } ], bbar: [ @@ -936,7 +980,11 @@ scope: this, handler: function() { var node = this.form.findField('boundary').selectedNode; - if (!node) { + if (!node || !this.form.findField('level').levelComboBox.getValue()) { + return; + } + if (node.attributes.level > this.form.findField('level').levelComboBox.getValue()) { + Ext.message.msg(false, 'Level is higher than boundary level'); return; } @@ -946,8 +994,11 @@ this.form.findField('mapview').clearValue(); this.updateValues = true; - this.organisationUnitSelection.setValues(node.attributes.id, node.attributes.text, node.attributes.level, null, null); + this.organisationUnitSelection.setValues(node.attributes.id, node.attributes.text, node.attributes.level, + this.form.findField('level').levelComboBox.getValue(), this.form.findField('level').levelComboBox.getRawValue()); + this.form.findField('boundary').setValue(node.attributes.text); + this.form.findField('level').setValue(this.form.findField('level').levelComboBox.getRawValue()); this.form.findField('boundary').treeWindow.hide(); this.loadGeoJson(); @@ -956,8 +1007,8 @@ ] }); - var x = Ext.getCmp('center').x + 15; - var y = Ext.getCmp('center').y + 41; + var x = Ext.getCmp('center').x + G.conf.window_position_x; + var y = Ext.getCmp('center').y + G.conf.window_position_y; w.setPosition(x,y); w.show(); this.form.findField('boundary').treeWindow = w; @@ -1229,6 +1280,7 @@ this.organisationUnitSelection.setValues(this.mapView.parentOrganisationUnitId, this.mapView.parentOrganisationUnitName, this.mapView.parentOrganisationUnitLevel, this.mapView.organisationUnitLevel, this.mapView.organisationUnitLevelName); + G.stores.organisationUnitLevel.load(); this.form.findField('boundary').setValue(this.mapView.parentOrganisationUnitName); this.form.findField('level').setValue(this.mapView.organisationUnitLevelName); @@ -1411,10 +1463,13 @@ this.form.findField('startdate').reset(); this.form.findField('enddate').reset(); - var boundary = this.form.findField('boundary'); + var boundary = this.form.findField('boundary') + var level = this.form.findField('level'); boundary.reset(); - if (boundary.treePanel) { + level.reset(); + if (boundary.treePanel && level.levelComboBox) { boundary.treePanel.selectPath(boundary.treePanel.getRootNode().getPath()); + level.levelComboBox.clearValue(); } this.legend.reset(); @@ -1427,7 +1482,7 @@ this.form.findField('radiushigh').reset(); this.layer.destroyFeatures(); - this.layer.setVisibility(false); + this.layer.setVisibility(false); } }, @@ -1449,7 +1504,7 @@ if (!position && this.layer.features.length) { G.vars.map.zoomToExtent(this.layer.getDataExtent()); } - + if (this.mapView) { if (this.mapView.longitude && this.mapView.latitude && this.mapView.zoom) { var point = G.util.getTransformedPointByXY(this.mapView.longitude, this.mapView.latitude);