=== 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-05 09:24:07 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js 2012-11-06 06:05:58 +0000 @@ -2704,6 +2704,11 @@ hidden: true, handler: function() { if (legendSetName.getValue() && validateLegends()) { + if (legendSetStore.findExact('name', legendSetName.getValue()) !== -1) { + alert('Name already in use'); + return; + } + var body = Ext.encode(getRequestBody()); Ext.Ajax.request({ @@ -2725,6 +2730,10 @@ hidden: true, handler: function() { if (legendSetName.getValue() && validateLegends()) { + if (legendSetStore.findExact('name', legendSetName.getValue()) !== -1) { + alert('Name already in use'); + return; + } var body = getRequestBody(), id = legendPanel.legendSetId; body.id = id; @@ -2857,7 +2866,7 @@ panel = Ext.create('Ext.panel.Panel', { cls: 'gis-container-inner', - html: 'Direct link: ' + GIS.init.contextPath + '/dhis-web-mapping/app/index.html?id=' + GIS.map.mapLoader.id, + html: 'Link: ' + GIS.init.contextPath + '/dhis-web-mapping/app/index.html?id=' + GIS.map.mapLoader.id, style: 'padding-top: 9px; padding-bottom: 2px' }); === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Boundary.js' --- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Boundary.js 2012-11-05 19:23:01 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Boundary.js 2012-11-06 07:41:32 +0000 @@ -570,6 +570,8 @@ return; } + this.features = this.layer.features.slice(0); + this.loadData(features); } }); @@ -586,8 +588,10 @@ this.layer.removeFeatures(this.layer.features); this.layer.addFeatures(features); - this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features); - this.features = this.layer.features.slice(0); + + if (this.tmpView.extended.updateOrganisationUnit) { + this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features); + } this.loadLegend(); }, === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Facility.js' --- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Facility.js 2012-11-05 19:23:01 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Facility.js 2012-11-06 07:41:32 +0000 @@ -846,6 +846,8 @@ return; } + this.features = this.layer.features.slice(0); + this.loadData(features); } }); @@ -861,8 +863,10 @@ this.layer.removeFeatures(this.layer.features); this.layer.addFeatures(features); - this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features); - this.features = this.layer.features.slice(0); + + if (this.tmpView.extended.updateOrganisationUnit) { + this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features); + } this.loadLegend(); }, === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic1.js' --- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic1.js 2012-11-05 19:23:01 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic1.js 2012-11-06 07:41:32 +0000 @@ -59,7 +59,7 @@ store: { indicatorsByGroup: Ext.create('Ext.data.Store', { - fields: ['id', 'name'], + fields: ['id', 'name', 'legendSet'], proxy: { type: 'ajax', url: '', @@ -319,12 +319,7 @@ var store = this.cmp.indicator.store; store.proxy.url = GIS.conf.url.path_api + 'indicatorGroups/' + cb.getValue() + '.json?links=false&paging=false'; - store.load({ - scope: this, - callback: function() { - this.cmp.indicator.selectFirst(); - } - }); + store.load(); } } } @@ -341,16 +336,35 @@ labelWidth: GIS.conf.layout.widget.itemlabel_width, listConfig: {loadMask: false}, scope: this, - selectFirst: function() { - if (this.store.getCount() > 0) { - this.setValue(this.store.getAt(0).data.id); - } - this.scope.config.extended.updateData = true; - }, store: this.store.indicatorsByGroup, listeners: { select: function() { - this.scope.config.extended.updateData = true; + var that = this.scope; + that.config.extended.updateData = true; + + Ext.Ajax.request({ + url: GIS.conf.url.path_api + 'indicators/' + this.getValue() + '.json?links=false', + scope: this, + success: function(r) { + r = Ext.decode(r.responseText); + if (Ext.isDefined(r.legendSet) && r.legendSet && r.legendSet.id) { + that.cmp.legendType.setValue(GIS.conf.finals.widget.legendtype_predefined); + that.toggler.legendType(GIS.conf.finals.widget.legendtype_predefined); + if (GIS.store.legendSets.isLoaded) { + that.cmp.legendSet.setValue(r.legendSet.id); + } + else { + GIS.store.legendSets.loadFn( function() { + that.cmp.legendSet.setValue(r.legendSet.id); + }); + } + } + else { + that.cmp.legendType.setValue(GIS.conf.finals.widget.legendtype_automatic); + that.toggler.legendType(GIS.conf.finals.widget.legendtype_automatic); + } + } + }); } } }); @@ -399,16 +413,35 @@ listConfig: {loadMask: false}, hidden: true, scope: this, - selectFirst: function() { - if (this.store.getCount() > 0) { - this.setValue(this.store.getAt(0).data.id); - } - this.scope.config.extended.updateData = true; - }, store: this.store.dataElementsByGroup, listeners: { select: function() { - this.scope.config.extended.updateData = true; + var that = this.scope; + that.config.extended.updateData = true; + + Ext.Ajax.request({ + url: GIS.conf.url.path_api + 'dataElements/' + this.getValue() + '.json?links=false', + scope: this, + success: function(r) { + r = Ext.decode(r.responseText); + if (Ext.isDefined(r.legendSet) && r.legendSet && r.legendSet.id) { + that.cmp.legendType.setValue(GIS.conf.finals.widget.legendtype_predefined); + that.toggler.legendType(GIS.conf.finals.widget.legendtype_predefined); + if (GIS.store.legendSets.isLoaded) { + that.cmp.legendSet.setValue(r.legendSet.id); + } + else { + GIS.store.legendSets.loadFn( function() { + that.cmp.legendSet.setValue(r.legendSet.id); + }); + } + } + else { + that.cmp.legendType.setValue(GIS.conf.finals.widget.legendtype_automatic); + that.toggler.legendType(GIS.conf.finals.widget.legendtype_automatic); + } + } + }); } } }); @@ -1238,6 +1271,10 @@ success: function(r) { legends = Ext.decode(r.responseText).mapLegends; + Ext.Array.sort(legends, function (a, b) { + return a.startValue - b.startValue; + }); + for (var i = 0; i < legends.length; i++) { if (bounds[bounds.length-1] !== legends[i].startValue) { if (bounds.length !== 0) { @@ -1474,7 +1511,7 @@ updateLegend: Ext.isDefined(conf.extended.updateLegend) ? conf.extended.updateLegend : false, updateGui: Ext.isDefined(conf.extended.updateGui) ? conf.extended.updateGui : false }; - +console.log(view); return view; }, @@ -1629,6 +1666,8 @@ return; } + this.features = this.layer.features.slice(0); + this.loadData(features); } }); @@ -1693,8 +1732,10 @@ this.layer.removeFeatures(this.layer.features); this.layer.addFeatures(newFeatures); - this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features); - this.features = this.layer.features.slice(0); + + if (this.tmpView.extended.updateOrganisationUnit) { + this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features); + } this.loadLegend(); } === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic2.js' --- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic2.js 2012-11-05 19:23:01 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic2.js 2012-11-06 07:41:32 +0000 @@ -59,7 +59,7 @@ store: { indicatorsByGroup: Ext.create('Ext.data.Store', { - fields: ['id', 'name'], + fields: ['id', 'name', 'legendSet'], proxy: { type: 'ajax', url: '', @@ -319,12 +319,7 @@ var store = this.cmp.indicator.store; store.proxy.url = GIS.conf.url.path_api + 'indicatorGroups/' + cb.getValue() + '.json?links=false&paging=false'; - store.load({ - scope: this, - callback: function() { - this.cmp.indicator.selectFirst(); - } - }); + store.load(); } } } @@ -341,16 +336,35 @@ labelWidth: GIS.conf.layout.widget.itemlabel_width, listConfig: {loadMask: false}, scope: this, - selectFirst: function() { - if (this.store.getCount() > 0) { - this.setValue(this.store.getAt(0).data.id); - } - this.scope.config.extended.updateData = true; - }, store: this.store.indicatorsByGroup, listeners: { select: function() { - this.scope.config.extended.updateData = true; + var that = this.scope; + that.config.extended.updateData = true; + + Ext.Ajax.request({ + url: GIS.conf.url.path_api + 'indicators/' + this.getValue() + '.json?links=false', + scope: this, + success: function(r) { + r = Ext.decode(r.responseText); + if (Ext.isDefined(r.legendSet) && r.legendSet && r.legendSet.id) { + that.cmp.legendType.setValue(GIS.conf.finals.widget.legendtype_predefined); + that.toggler.legendType(GIS.conf.finals.widget.legendtype_predefined); + if (GIS.store.legendSets.isLoaded) { + that.cmp.legendSet.setValue(r.legendSet.id); + } + else { + GIS.store.legendSets.loadFn( function() { + that.cmp.legendSet.setValue(r.legendSet.id); + }); + } + } + else { + that.cmp.legendType.setValue(GIS.conf.finals.widget.legendtype_automatic); + that.toggler.legendType(GIS.conf.finals.widget.legendtype_automatic); + } + } + }); } } }); @@ -399,16 +413,35 @@ listConfig: {loadMask: false}, hidden: true, scope: this, - selectFirst: function() { - if (this.store.getCount() > 0) { - this.setValue(this.store.getAt(0).data.id); - } - this.scope.config.extended.updateData = true; - }, store: this.store.dataElementsByGroup, listeners: { select: function() { - this.scope.config.extended.updateData = true; + var that = this.scope; + that.config.extended.updateData = true; + + Ext.Ajax.request({ + url: GIS.conf.url.path_api + 'dataElements/' + this.getValue() + '.json?links=false', + scope: this, + success: function(r) { + r = Ext.decode(r.responseText); + if (Ext.isDefined(r.legendSet) && r.legendSet && r.legendSet.id) { + that.cmp.legendType.setValue(GIS.conf.finals.widget.legendtype_predefined); + that.toggler.legendType(GIS.conf.finals.widget.legendtype_predefined); + if (GIS.store.legendSets.isLoaded) { + that.cmp.legendSet.setValue(r.legendSet.id); + } + else { + GIS.store.legendSets.loadFn( function() { + that.cmp.legendSet.setValue(r.legendSet.id); + }); + } + } + else { + that.cmp.legendType.setValue(GIS.conf.finals.widget.legendtype_automatic); + that.toggler.legendType(GIS.conf.finals.widget.legendtype_automatic); + } + } + }); } } }); @@ -1238,6 +1271,10 @@ success: function(r) { legends = Ext.decode(r.responseText).mapLegends; + Ext.Array.sort(legends, function (a, b) { + return a.startValue - b.startValue; + }); + for (var i = 0; i < legends.length; i++) { if (bounds[bounds.length-1] !== legends[i].startValue) { if (bounds.length !== 0) { @@ -1474,7 +1511,7 @@ updateLegend: Ext.isDefined(conf.extended.updateLegend) ? conf.extended.updateLegend : false, updateGui: Ext.isDefined(conf.extended.updateGui) ? conf.extended.updateGui : false }; - +console.log(view); return view; }, @@ -1629,6 +1666,8 @@ return; } + this.features = this.layer.features.slice(0); + this.loadData(features); } }); @@ -1693,8 +1732,10 @@ this.layer.removeFeatures(this.layer.features); this.layer.addFeatures(newFeatures); - this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features); - this.features = this.layer.features.slice(0); + + if (this.tmpView.extended.updateOrganisationUnit) { + this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features); + } this.loadLegend(); } @@ -1784,7 +1825,7 @@ this.store.features.loadFeatures(this.layer.features); // Update filter window - if (this.cmp.filterWindow && this.cmp.filterWindow.isVisible()) { + if (this.cmp.filterWindow && this.cmp.filterWindow.isVisible()) { this.cmp.filterWindow.filter(); }