=== 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 2010-03-12 15:26:21 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2010-03-15 14:28:53 +0000 @@ -3271,7 +3271,6 @@ var indicatorId = Ext.getCmp('indicator_cb').getValue(); var periodId = Ext.getCmp('period_cb').getValue(); var mapLayerPath = MAPDATA.mapLayerPath; - var url = MAPSOURCE == map_source_type_geojson || MAPSOURCE == map_source_type_shapefile ? 'getMapValuesByMap' : 'getMapValuesByLevel'; var params = MAPSOURCE == map_source_type_geojson || MAPSOURCE == map_source_type_shapefile ? { indicatorId: indicatorId, periodId: periodId, mapLayerPath: mapLayerPath } : { indicatorId: indicatorId, periodId: periodId, level: URL }; @@ -3280,8 +3279,53 @@ method: 'POST', params: params, - success: function( responseObject ) { - dataReceivedChoropleth( responseObject.responseText ); + success: function(r) { + var layers = MAP.getLayersByName('Thematic map'); + var features = layers[0].features; + var mapvalues = Ext.util.JSON.decode(r.responseText).mapvalues; + var mv = new Array(); + var nameColumn = MAPDATA.nameColumn; + var options = {}; + + if (mapvalues.length == 0) { + Ext.messageRed.msg('Thematic map', 'The selected indicator, period and level returned no data.'); + MASK.hide(); + return; + } + + for (var i = 0; i < mapvalues.length; i++) { + mv[mapvalues[i].featureId] = mapvalues[i].featureId ? mapvalues[i].value : ''; + } + + if (MAPSOURCE == map_source_type_geojson || MAPSOURCE == map_source_type_shapefile) { + for (var j = 0; j < features.length; j++) { + features[j].attributes.value = mv[features[j].attributes[nameColumn]] ? mv[features[j].attributes[nameColumn]] : 0; + } + } + else if (MAPSOURCE == map_source_type_database) { + for (var i = 0; i < mapvalues.length; i++) { + for (var j = 0; j < features.length; j++) { + if (mapvalues[i].orgUnitName == features[j].attributes.name) { + features[j].attributes.value = parseFloat(mapvalues[i].value); + break; + } + } + } + } + + choropleth.indicator = 'value'; + choropleth.indicatorText = 'Indicator'; + options.indicator = choropleth.indicator; + + options.method = Ext.getCmp('method').getValue(); + options.numClasses = Ext.getCmp('numClasses').getValue(); + options.colors = choropleth.getColors(); + + choropleth.coreComp.updateOptions(options); + choropleth.coreComp.applyClassification(); + choropleth.classificationApplied = true; + + MASK.hide(); }, failure: function() { alert( 'Error: getMapValues' ); @@ -3289,57 +3333,6 @@ }); } -function dataReceivedChoropleth( responseText ) { - var layers = MAP.getLayersByName('Thematic map'); - var features = layers[0].features; - var mapvalues = Ext.util.JSON.decode(responseText).mapvalues; - var mv = new Array(); - var nameColumn = MAPDATA.nameColumn; - - if (mapvalues.length == 0) { - Ext.messageRed.msg('Thematic map', 'The selected indicator, period and level returned no data.'); - MASK.hide(); - return; - } - - for (var i = 0; i < mapvalues.length; i++) { - mv[mapvalues[i].featureId] = mapvalues[i].featureId ? mapvalues[i].value : ''; - } - - if (MAPSOURCE == map_source_type_geojson || MAPSOURCE == map_source_type_shapefile) { - for (var j = 0; j < features.length; j++) { - features[j].attributes.value = mv[features[j].attributes[nameColumn]] ? mv[features[j].attributes[nameColumn]] : 0; - } - } - else if (MAPSOURCE == map_source_type_database) { - for (var i = 0; i < mapvalues.length; i++) { - for (var j = 0; j < features.length; j++) { - if (mapvalues[i].orgUnitName == features[j].attributes.name) { - features[j].attributes.value = parseFloat(mapvalues[i].value); - break; - } - } - } - } - - var options = {}; - - /*hidden*/ - choropleth.indicator = 'value'; - choropleth.indicatorText = 'Indicator'; - options.indicator = choropleth.indicator; - - options.method = Ext.getCmp('method').getValue(); - options.numClasses = Ext.getCmp('numClasses').getValue(); - options.colors = choropleth.getColors(); - - choropleth.coreComp.updateOptions(options); - choropleth.coreComp.applyClassification(); - choropleth.classificationApplied = true; - - MASK.hide(); -} - /*MAPPING*/ function getAssignOrganisationUnitData() { MASK.msg = 'Creating map...'; @@ -3364,13 +3357,11 @@ function dataReceivedAssignOrganisationUnit( responseText ) { var layers = MAP.getLayersByName('Thematic map'); features = layers[0]['features']; - var relations = Ext.util.JSON.decode(responseText).mapOrganisationUnitRelations; - var nameColumn = MAPDATA.nameColumn; - var noCls = 1; var noAssigned = 0; + var options = {}; for (var i = 0; i < features.length; i++) { features[i].attributes['value'] = 0; @@ -3387,18 +3378,9 @@ } } - var color = unassigned_row_color; - - if (noCls > 1) { - if (noAssigned == features.length) { - noCls = 1; - color = assigned_row_color; - } - } - - var options = {}; - - /*hidden*/ + var color = noCls > 1 && noAssigned == features.length ? assigned_row_color : unassigned_row_color; + noCls = noCls > 1 && noAssigned == features.length ? 1 : noCls; + mapping.indicator = 'value'; mapping.indicatorText = 'Indicator'; options.indicator = mapping.indicator; @@ -3485,7 +3467,7 @@ MASK.msg = 'Applying organisation units relations...'; MASK.show(); - Ext.messageBlack.msg('Assign organisation units', '' + count_match + ' organisation units assigned.

Database: ' + organisationUnits.length + '
Shapefile: ' + features.length + ''); + Ext.messageBlack.msg('Assign organisation units', '' + count_match + ' organisation units assigned.

Database: ' + organisationUnits.length + '
Shapefile: ' + features.length + ''); Ext.getCmp('grid_gp').getStore().reload(); loadMapData(organisationUnitAssignment, position); === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js' --- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js 2010-03-10 14:41:28 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js 2010-03-15 14:28:53 +0000 @@ -322,7 +322,7 @@ var mlp = Ext.getCmp('maps_cb').getValue(); var msg; - if (!selection) { + if (selection == '') { Ext.messageRed.msg('Remove relation', 'Please select at least one organisation unit in the list.'); return; } @@ -384,6 +384,7 @@ Ext.messageBlack.msg('Assign organisation units', '' + mapping.relation + ' (map) assigned to ' + name + ' (database).'); Ext.getCmp('grid_gp').getStore().reload(); popup.hide(); + mapping.relation = false; loadMapData(organisationUnitAssignment, true); }, failure: function() {