=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js' --- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2014-08-08 11:08:16 +0000 +++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2014-08-08 13:15:52 +0000 @@ -83,6 +83,18 @@ return Ext.clone(dimensionNames); }; + config.hasDimension = function(id) { + return Ext.isString(id) && this.findExact('id', id) != -1 ? true : false; + }; + + config.removeDimension = function(id) { + var index = this.findExact('id', id); + + if (index != -1) { + this.remove(this.getAt(index)); + } + }; + return Ext.create('Ext.data.Store', config); }; @@ -270,6 +282,10 @@ if (!hasDimension(record.id)) { store.add(record); } + + if (store !== dimensionStore && dimensionStore.hasDimension(record.id)) { + dimensionStore.removeDimension(record.id); + } }; removeDimension = function(dataElementId) { @@ -277,10 +293,9 @@ for (var i = 0, store, index; i < stores.length; i++) { store = stores[i]; - index = store.findExact('id', dataElementId); - if (index != -1) { - store.remove(store.getAt(index)); + if (store.hasDimension(dataElementId)) { + store.removeDimension(dataElementId); dimensionStoreMap[dataElementId] = store; } } @@ -290,10 +305,7 @@ var stores = [colStore, rowStore, filterStore]; for (var i = 0, store, index; i < stores.length; i++) { - store = stores[i]; - index = store.findExact('id', id); - - if (index != -1) { + if (stores[i].hasDimension(id)) { return true; } } === modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js' --- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js 2014-08-08 12:23:05 +0000 +++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js 2014-08-08 13:21:16 +0000 @@ -83,6 +83,18 @@ return Ext.clone(dimensionNames); }; + config.hasDimension = function(id) { + return Ext.isString(id) && this.findExact('id', id) != -1 ? true : false; + }; + + config.removeDimension = function(id) { + var index = this.findExact('id', id); + + if (index != -1) { + this.remove(this.getAt(index)); + } + }; + return Ext.create('Ext.data.Store', config); }; @@ -306,6 +318,10 @@ if (!hasDimension(record.id)) { store.add(record); } + + if (store !== dimensionStore && dimensionStore.hasDimension(record.id)) { + dimensionStore.removeDimension(record.id); + } }; removeDimension = function(dataElementId) { @@ -313,10 +329,9 @@ for (var i = 0, store, index; i < stores.length; i++) { store = stores[i]; - index = store.findExact('id', dataElementId); - if (index != -1) { - store.remove(store.getAt(index)); + if (store.hasDimension(dataElementId)) { + store.removeDimension(dataElementId); dimensionStoreMap[dataElementId] = store; } } @@ -326,10 +341,7 @@ var stores = [colStore, rowStore, filterStore]; for (var i = 0, store, index; i < stores.length; i++) { - store = stores[i]; - index = store.findExact('id', id); - - if (index != -1) { + if (stores[i].hasDimension(id)) { return true; } }