← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3866: Separated stores for indicators, data elements and periods. Improved code.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 3866 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-06-10 14:41:00 +0200
message:
  Separated stores for indicators, data elements and periods. Improved code.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js
  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/Point.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-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-06-10 11:47:41 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-06-10 12:39:23 +0000
@@ -57,28 +57,6 @@
         }
     });
     
-    var indicatorsByGroupStore = new Ext.data.JsonStore({
-        url: G.conf.path_mapping + 'getIndicatorsByIndicatorGroup' + G.conf.type,
-        root: 'indicators',
-        fields: ['id', 'name', 'shortName'],
-        idProperty: 'id',
-        sortInfo: {field: 'name', direction: 'ASC'},
-        autoLoad: false,
-        isLoaded: false,
-        listeners: {
-            'load': function(store) {
-                store.isLoaded = true;
-                store.each(
-                    function fn(record) {
-                        var name = record.get('name');
-                        name = name.replace('&lt;', '<').replace('&gt;', '>');
-                        record.set('name', name);
-                    }
-                );
-            }
-        }
-    });
-    
 	var indicatorStore = new Ext.data.JsonStore({
         url: G.conf.path_mapping + 'getAllIndicators' + G.conf.type,
         root: 'indicators',
@@ -102,27 +80,6 @@
         }
     });
     
-    var dataElementsByGroupStore = new Ext.data.JsonStore({
-        url: G.conf.path_mapping + 'getDataElementsByDataElementGroup' + G.conf.type,
-        root: 'dataElements',
-        fields: ['id', 'name', 'shortName'],
-        sortInfo: {field: 'name', direction: 'ASC'},
-        autoLoad: false,
-        isLoaded: false,
-        listeners: {
-            'load': function(store) {
-                store.isLoaded = true;
-                store.each(
-                    function fn(record) {
-                        var name = record.get('name');
-                        name = name.replace('&lt;', '<').replace('&gt;', '>');
-                        record.set('name', name);
-                    }
-                );
-            }
-        }
-    });
-    
     var dataElementStore = new Ext.data.JsonStore({
         url: G.conf.path_mapping + 'getAllDataElements' + G.conf.type,
         root: 'dataElements',
@@ -146,17 +103,6 @@
             'load': G.func.storeLoadListener
         }
     });
-        
-    var periodsByTypeStore = new Ext.data.JsonStore({
-        url: G.conf.path_mapping + 'getPeriodsByPeriodType' + G.conf.type,
-        root: 'periods',
-        fields: ['id', 'name'],
-        autoLoad: false,
-        isLoaded: false,
-        listeners: {
-            'load': G.func.storeLoadListener
-        }
-    });
     
     var infrastructuralPeriodTypeStore = new Ext.data.JsonStore({
         url: G.conf.path_mapping + 'getAllPeriodTypes' + G.conf.type,
@@ -279,13 +225,10 @@
     G.stores = {
 		mapView: mapViewStore,
         indicatorGroup: indicatorGroupStore,
-        indicatorsByGroup: indicatorsByGroupStore,
         indicator: indicatorStore,
         dataElementGroup: dataElementGroupStore,
-        dataElementsByGroup: dataElementsByGroupStore,
         dataElement: dataElementStore,
         periodType: periodTypeStore,
-        periodsByType: periodsByTypeStore,
         infrastructuralPeriodType: infrastructuralPeriodTypeStore,
         infrastructuralPeriodsByType: infrastructuralPeriodsByTypeStore,
         predefinedMapLegend: predefinedMapLegendStore,

=== 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-06-10 11:47:41 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-06-10 12:39:23 +0000
@@ -228,6 +228,57 @@
                 listeners: {
                     'load': G.func.storeLoadListener
                 }
+            }),
+            indicatorsByGroup: new Ext.data.JsonStore({
+                url: G.conf.path_mapping + 'getIndicatorsByIndicatorGroup' + G.conf.type,
+                root: 'indicators',
+                fields: ['id', 'name', 'shortName'],
+                idProperty: 'id',
+                sortInfo: {field: 'name', direction: 'ASC'},
+                autoLoad: false,
+                isLoaded: false,
+                listeners: {
+                    'load': function(store) {
+                        store.isLoaded = true;
+                        store.each(
+                            function fn(record) {
+                                var name = record.get('name');
+                                name = name.replace('&lt;', '<').replace('&gt;', '>');
+                                record.set('name', name);
+                            }
+                        );
+                    }
+                }
+            }),
+            dataElementsByGroup: new Ext.data.JsonStore({
+                url: G.conf.path_mapping + 'getDataElementsByDataElementGroup' + G.conf.type,
+                root: 'dataElements',
+                fields: ['id', 'name', 'shortName'],
+                sortInfo: {field: 'name', direction: 'ASC'},
+                autoLoad: false,
+                isLoaded: false,
+                listeners: {
+                    'load': function(store) {
+                        store.isLoaded = true;
+                        store.each(
+                            function fn(record) {
+                                var name = record.get('name');
+                                name = name.replace('&lt;', '<').replace('&gt;', '>');
+                                record.set('name', name);
+                            }
+                        );
+                    }
+                }
+            }),
+            periodsByType: new Ext.data.JsonStore({
+                url: G.conf.path_mapping + 'getPeriodsByPeriodType' + G.conf.type,
+                root: 'periods',
+                fields: ['id', 'name'],
+                autoLoad: false,
+                isLoaded: false,
+                listeners: {
+                    'load': G.func.storeLoadListener
+                }
             })
         };
     },
@@ -329,8 +380,8 @@
                     scope: this,
                     fn: function(cb) {
 						this.form.findField('indicator').clearValue();
-                        G.stores.indicatorsByGroup.setBaseParam('indicatorGroupId', cb.getValue());
-                        G.stores.indicatorsByGroup.load();
+                        this.stores.indicatorsByGroup.setBaseParam('indicatorGroupId', cb.getValue());
+                        this.stores.indicatorsByGroup.load();
                     }
                 }
             }
@@ -349,7 +400,7 @@
             triggerAction: 'all',
             selectOnFocus: true,
             width: G.conf.combo_width,
-            store: G.stores.indicatorsByGroup,
+            store: this.stores.indicatorsByGroup,
             currentValue: null,
             keepPosition: false,
             listeners: {
@@ -418,8 +469,8 @@
                     scope: this,
                     fn: function(cb) {
                         this.form.findField('dataelement').clearValue();
-						G.stores.dataElementsByGroup.setBaseParam('dataElementGroupId', cb.getValue());
-                        G.stores.dataElementsByGroup.load();
+						this.stores.dataElementsByGroup.setBaseParam('dataElementGroupId', cb.getValue());
+                        this.stores.dataElementsByGroup.load();
                     }
                 }
             }
@@ -438,7 +489,7 @@
             triggerAction: 'all',
             selectOnFocus: true,
             width: G.conf.combo_width,
-            store: G.stores.dataElementsByGroup,
+            store: this.stores.dataElementsByGroup,
             keepPosition: false,
             listeners: {
                 'select': {
@@ -506,8 +557,8 @@
                     scope: this,
                     fn: function(cb) {
                         this.form.findField('period').clearValue();
-                        G.stores.periodsByType.setBaseParam('name', cb.getValue());
-                        G.stores.periodsByType.load();
+                        this.stores.periodsByType.setBaseParam('name', cb.getValue());
+                        this.stores.periodsByType.load();
                     }
                 }
             }
@@ -526,7 +577,7 @@
             triggerAction: 'all',
             selectOnFocus: true,
             width: G.conf.combo_width,
-            store: G.stores.periodsByType,
+            store: this.stores.periodsByType,
             keepPosition: false,
             listeners: {
                 'select': {
@@ -1193,7 +1244,7 @@
             };
             obj.stores = {
                 valueTypeGroup: G.stores.indicatorGroup,
-                valueType: G.stores.indicatorsByGroup
+                valueType: this.stores.indicatorsByGroup
             };
             obj.mapView = {
                 valueTypeGroup: 'indicatorGroupId',
@@ -1211,7 +1262,7 @@
             };
             obj.stores = {
                 valueTypeGroup: G.stores.dataElementGroup,
-                valueType: G.stores.dataElementsByGroup
+                valueType: this.stores.dataElementsByGroup
             };
             obj.mapView = {
                 valueTypeGroup: 'dataElementGroupId',
@@ -1234,7 +1285,7 @@
             };
             obj.stores = {
                 c1: G.stores.periodType,
-                c2: G.stores.periodsByType
+                c2: this.stores.periodsByType
             };
             obj.mapView = {
                 c1: 'periodTypeId',

=== 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-06-10 11:47:41 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js	2011-06-10 12:39:23 +0000
@@ -199,6 +199,57 @@
                 listeners: {
                     'load': G.func.storeLoadListener
                 }
+            }),
+            indicatorsByGroup: new Ext.data.JsonStore({
+                url: G.conf.path_mapping + 'getIndicatorsByIndicatorGroup' + G.conf.type,
+                root: 'indicators',
+                fields: ['id', 'name', 'shortName'],
+                idProperty: 'id',
+                sortInfo: {field: 'name', direction: 'ASC'},
+                autoLoad: false,
+                isLoaded: false,
+                listeners: {
+                    'load': function(store) {
+                        store.isLoaded = true;
+                        store.each(
+                            function fn(record) {
+                                var name = record.get('name');
+                                name = name.replace('&lt;', '<').replace('&gt;', '>');
+                                record.set('name', name);
+                            }
+                        );
+                    }
+                }
+            }),
+            dataElementsByGroup: new Ext.data.JsonStore({
+                url: G.conf.path_mapping + 'getDataElementsByDataElementGroup' + G.conf.type,
+                root: 'dataElements',
+                fields: ['id', 'name', 'shortName'],
+                sortInfo: {field: 'name', direction: 'ASC'},
+                autoLoad: false,
+                isLoaded: false,
+                listeners: {
+                    'load': function(store) {
+                        store.isLoaded = true;
+                        store.each(
+                            function fn(record) {
+                                var name = record.get('name');
+                                name = name.replace('&lt;', '<').replace('&gt;', '>');
+                                record.set('name', name);
+                            }
+                        );
+                    }
+                }
+            }),
+            periodsByType: new Ext.data.JsonStore({
+                url: G.conf.path_mapping + 'getPeriodsByPeriodType' + G.conf.type,
+                root: 'periods',
+                fields: ['id', 'name'],
+                autoLoad: false,
+                isLoaded: false,
+                listeners: {
+                    'load': G.func.storeLoadListener
+                }
             })
         };
     },
@@ -300,8 +351,8 @@
                     scope: this,
                     fn: function(cb) {
 						this.form.findField('indicator').clearValue();
-                        G.stores.indicatorsByGroup.setBaseParam('indicatorGroupId', cb.getValue());
-                        G.stores.indicatorsByGroup.load();
+                        this.stores.indicatorsByGroup.setBaseParam('indicatorGroupId', cb.getValue());
+                        this.stores.indicatorsByGroup.load();
                     }
                 }
             }
@@ -320,7 +371,7 @@
             triggerAction: 'all',
             selectOnFocus: true,
             width: G.conf.combo_width,
-            store: G.stores.indicatorsByGroup,
+            store: this.stores.indicatorsByGroup,
             currentValue: null,
             keepPosition: false,
             listeners: {
@@ -389,8 +440,8 @@
                     scope: this,
                     fn: function(cb) {
                         this.form.findField('dataelement').clearValue();
-						G.stores.dataElementsByGroup.setBaseParam('dataElementGroupId', cb.getValue());
-                        G.stores.dataElementsByGroup.load();
+						this.stores.dataElementsByGroup.setBaseParam('dataElementGroupId', cb.getValue());
+                        this.stores.dataElementsByGroup.load();
                     }
                 }
             }
@@ -409,7 +460,7 @@
             triggerAction: 'all',
             selectOnFocus: true,
             width: G.conf.combo_width,
-            store: G.stores.dataElementsByGroup,
+            store: this.stores.dataElementsByGroup,
             keepPosition: false,
             listeners: {
                 'select': {
@@ -477,8 +528,8 @@
                     scope: this,
                     fn: function(cb) {
                         this.form.findField('period').clearValue();
-                        G.stores.periodsByType.setBaseParam('name', cb.getValue());
-                        G.stores.periodsByType.load();
+                        this.stores.periodsByType.setBaseParam('name', cb.getValue());
+                        this.stores.periodsByType.load();
                     }
                 }
             }
@@ -497,7 +548,7 @@
             triggerAction: 'all',
             selectOnFocus: true,
             width: G.conf.combo_width,
-            store: G.stores.periodsByType,
+            store: this.stores.periodsByType,
             keepPosition: false,
             listeners: {
                 'select': {
@@ -1164,7 +1215,7 @@
             };
             obj.stores = {
                 valueTypeGroup: G.stores.indicatorGroup,
-                valueType: G.stores.indicatorsByGroup
+                valueType: this.stores.indicatorsByGroup
             };
             obj.mapView = {
                 valueTypeGroup: 'indicatorGroupId',
@@ -1182,7 +1233,7 @@
             };
             obj.stores = {
                 valueTypeGroup: G.stores.dataElementGroup,
-                valueType: G.stores.dataElementsByGroup
+                valueType: this.stores.dataElementsByGroup
             };
             obj.mapView = {
                 valueTypeGroup: 'dataElementGroupId',
@@ -1205,7 +1256,7 @@
             };
             obj.stores = {
                 c1: G.stores.periodType,
-                c2: G.stores.periodsByType
+                c2: this.stores.periodsByType
             };
             obj.mapView = {
                 c1: 'periodTypeId',