=== 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-30 14:56:26 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js 2011-08-31 09:58:04 +0000 @@ -738,7 +738,7 @@ { text: 'Filter..', iconCls: 'menu-layeroptions-filter', - hidden: (widget.legendDiv == 'symbollegend' || widget.legendDiv == 'centroidlegend'), + hidden: widget.legendDiv == 'centroidlegend', scope: this, handler: function() { this.widget.filtering.showFilteringWindow.call(this.widget); === 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-30 14:56:26 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js 2011-08-31 09:58:04 +0000 @@ -94,16 +94,21 @@ var gt = this.filtering.options.gt; var lt = this.filtering.options.lt; var add = []; - for (var i = 0; i < this.filtering.cache.length; i++) { - if (gt && lt && this.filtering.cache[i].attributes.value > gt && this.filtering.cache[i].attributes.value < lt) { - add.push(this.filtering.cache[i]); - } - else { - if (!(gt && lt) && gt && this.filtering.cache[i].attributes.value > gt) { + if (!gt && !lt) { + add = this.filtering.cache.slice(0); + } + else { + for (var i = 0; i < this.filtering.cache.length; i++) { + if (gt && lt && this.filtering.cache[i].attributes.value > gt && this.filtering.cache[i].attributes.value < lt) { add.push(this.filtering.cache[i]); } - else if (!(gt && lt) && lt && this.filtering.cache[i].attributes.value < lt) { - add.push(this.filtering.cache[i]); + else { + if (!(gt && lt) && gt && this.filtering.cache[i].attributes.value > gt) { + add.push(this.filtering.cache[i]); + } + else if (!(gt && lt) && lt && this.filtering.cache[i].attributes.value < lt) { + add.push(this.filtering.cache[i]); + } } } } === 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-30 14:56:26 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js 2011-08-31 09:58:04 +0000 @@ -94,16 +94,21 @@ var gt = this.filtering.options.gt; var lt = this.filtering.options.lt; var add = []; - for (var i = 0; i < this.filtering.cache.length; i++) { - if (gt && lt && this.filtering.cache[i].attributes.value > gt && this.filtering.cache[i].attributes.value < lt) { - add.push(this.filtering.cache[i]); - } - else { - if (!(gt && lt) && gt && this.filtering.cache[i].attributes.value > gt) { + if (!gt && !lt) { + add = this.filtering.cache.slice(0); + } + else { + for (var i = 0; i < this.filtering.cache.length; i++) { + if (gt && lt && this.filtering.cache[i].attributes.value > gt && this.filtering.cache[i].attributes.value < lt) { add.push(this.filtering.cache[i]); } - else if (!(gt && lt) && lt && this.filtering.cache[i].attributes.value < lt) { - add.push(this.filtering.cache[i]); + else { + if (!(gt && lt) && gt && this.filtering.cache[i].attributes.value > gt) { + add.push(this.filtering.cache[i]); + } + else if (!(gt && lt) && lt && this.filtering.cache[i].attributes.value < lt) { + add.push(this.filtering.cache[i]); + } } } } === 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-08-29 15:24:44 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js 2011-08-31 09:58:04 +0000 @@ -82,6 +82,101 @@ requireUpdate: false, + filtering: { + cache: [], + options: { + type: [] + }, + filter: function() { + var type = this.filtering.options.type; + var add = []; + if (!type.length || !type[0]) { + add = this.filtering.cache.slice(0); + } + else { + for (var i = 0; i < this.filtering.cache.length; i++) { + for (var j = 0; j < type.length; j++) { + if (this.filtering.cache[i].attributes.type == type[j]) { + add.push(this.filtering.cache[i]); + } + } + } + } + this.layer.removeAllFeatures(); + this.layer.addFeatures(add); + }, + showFilteringWindow: function() { + var window = new Ext.Window({ + title: 'Organisation unit filter', + layout: 'fit', + autoHeight: true, + height: 'auto', + width: G.conf.window_width, + items: [ + { + xtype: 'form', + bodyStyle:'padding:8px', + autoHeight: true, + height: 'auto', + labelWidth: G.conf.label_width, + items: [ + { html: 'Show organisation units where type is..' }, + { html: '
' }, + { + xtype: 'multiselect', + hideLabel: true, + dataFields: ['id', 'name'], + valueField: 'name', + displayField: 'name', + width: G.conf.multiselect_width, + height: G.util.getMultiSelectHeight() / 2, + store: G.stores.groupsByGroupSet, + listeners: { + 'change': { + scope: this, + fn: function(ms) { + this.filtering.options.type = ms.getValue().split(','); + } + } + } + } + ] + } + ], + bbar: [ + '->', + { + xtype: 'button', + text: G.i18n.update, + iconCls: 'icon-assign', + scope: this, + handler: function() { + this.filtering.filter.call(this); + } + } + ], + listeners: { + 'afterrender': { + scope: this, + fn: function() { + this.filtering.cache = this.layer.features.slice(0); + } + }, + 'close': { + scope: this, + fn: function() { + this.layer.removeAllFeatures(); + this.layer.addFeatures(this.filtering.cache); + this.filtering.options.type = []; + } + } + } + }); + window.setPagePosition(G.conf.window_x_left,G.conf.window_y_left); + window.show(); + } + }, + initComponent: function() { this.initProperties();