← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16354: PT DV table layout window fix.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 16354 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-08-08 15:22:17 +0200
message:
  PT DV table layout window fix.
modified:
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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;
                 }
             }