← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16501: ER EV options bug fixed.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 16501 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-08-25 13:57:59 +0200
message:
  ER EV options bug fixed.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-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-apps/src/main/webapp/dhis-web-event-reports/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/scripts/app.js	2014-08-25 09:41:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/scripts/app.js	2014-08-25 11:55:15 +0000
@@ -442,29 +442,29 @@
 						var store = this,
 							params = {};
 
-						params['max'] = pageSize || 15;
+                        optionSetId = optionSetId || container.dataElement.optionSet.id;
 
 						if (key) {
 							params['key'] = key;
 						}
+                        
+						params['max'] = pageSize || 15;
 
 						Ext.Ajax.request({
 							url: ns.core.init.contextPath + '/api/optionSets/' + optionSetId + '/options.json',
 							params: params,
 							disableCaching: false,
 							success: function(r) {
-								var options = Ext.decode(r.responseText).options,
-									data = [];
-
-								Ext.each(options, function(option) {
-									data.push({
-										id: option,
-										name: option
-									});
-								});
-
+								var options = Ext.decode(r.responseText).options;
+
+                                for (var i = 0; i < options.length; i++) {
+                                    options[i].id = options[i].name;
+                                }
+                                    
 								store.removeAll();
-								store.add(data);
+                                store.loadData(options);
+
+                                container.triggerCmp.storage = Ext.clone(options);
 							}
 						});
 					},
@@ -532,27 +532,7 @@
                             container.valueStore.add(Ext.clone(b.storage));
                         }
                         else {
-                            Ext.Ajax.request({
-                                url: ns.core.init.contextPath + '/api/optionSets/' + container.dataElement.optionSet.id + '/options.json',
-                                params: {
-                                    'max': 14
-                                },
-                                success: function(r) {
-                                    var options = Ext.decode(r.responseText).options,
-                                        data = [];
-
-                                    Ext.each(options, function(option) {
-                                        data.push({
-                                            id: option,
-                                            name: option
-                                        });
-                                    });
-
-                                    b.storage = Ext.clone(data);
-									container.valueStore.removeAll();
-                                    container.valueStore.add(data);
-                                }
-                            });
+                            container.valueStore.loadOptionSet();
                         }
                     }
                 });

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/scripts/app.js	2014-08-25 10:14:13 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/scripts/app.js	2014-08-25 11:57:12 +0000
@@ -441,29 +441,29 @@
 						var store = this,
 							params = {};
 
-						params['max'] = pageSize || 15;
+                        optionSetId = optionSetId || container.dataElement.optionSet.id;
 
 						if (key) {
 							params['key'] = key;
 						}
+                        
+						params['max'] = pageSize || 15;
 
 						Ext.Ajax.request({
 							url: ns.core.init.contextPath + '/api/optionSets/' + optionSetId + '/options.json',
 							params: params,
 							disableCaching: false,
 							success: function(r) {
-								var options = Ext.decode(r.responseText).options,
-									data = [];
-
-								Ext.each(options, function(option) {
-									data.push({
-										id: option,
-										name: option
-									});
-								});
-
+								var options = Ext.decode(r.responseText).options;
+
+                                for (var i = 0; i < options.length; i++) {
+                                    options[i].id = options[i].name;
+                                }
+                                    
 								store.removeAll();
-								store.add(data);
+                                store.loadData(options);
+
+                                container.triggerCmp.storage = Ext.clone(options);
 							}
 						});
 					},
@@ -531,27 +531,7 @@
                             container.valueStore.add(Ext.clone(b.storage));
                         }
                         else {
-                            Ext.Ajax.request({
-                                url: ns.core.init.contextPath + '/api/optionSets/' + container.dataElement.optionSet.id + '/options.json',
-                                params: {
-                                    'max': 14
-                                },
-                                success: function(r) {
-                                    var options = Ext.decode(r.responseText).options,
-                                        data = [];
-
-                                    Ext.each(options, function(option) {
-                                        data.push({
-                                            id: option,
-                                            name: option
-                                        });
-                                    });
-
-                                    b.storage = Ext.clone(data);
-									container.valueStore.removeAll();
-                                    container.valueStore.add(data);
-                                }
-                            });
+                            container.valueStore.loadOptionSet();
                         }
                     }
                 });