← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6598: (DV) Series/category/filter options autoselected when there is only one option.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 6598 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-04-16 14:23:34 +0200
message:
  (DV) Series/category/filter options autoselected when there is only one option.
modified:
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/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-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js	2012-04-13 14:40:16 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js	2012-04-16 12:13:58 +0000
@@ -666,11 +666,6 @@
 				setHeight: function(mx) {
 					var h = DV.cmp.region.west.getHeight() - DV.conf.layout.west_fill;
 					DV.cmp.dimension.panel.setHeight(h > mx ? mx : h);
-				},
-				setDimensionLabels: function() {
-					//alert(DV.cmp.settings.series.getValue());
-					//alert(DV.cmp.settings.series.getRawValue());
-					//DV.cmp.settings.series
 				}
 			}
         },
@@ -1073,11 +1068,6 @@
         },
         combobox: {
             filter: {
-                clearValue: function(v, cb, i, d) {
-                    if (v === cb.getValue()) {
-                        cb.clearValue();
-                    }
-                },
                 category: function() {
                     var cbs = DV.cmp.settings.series,
                         cbc = DV.cmp.settings.category,
@@ -1096,10 +1086,15 @@
                         return cbc.filterArray[index++];
                     });
                     
+                    if (!cbc.getValue() && cbf.getValue()) {
+						cbc.setValue(this.getAutoSelectOption(cbs.getValue(), cbf.getValue()));
+                    }
+                    
                     this.filter();
                 },                
                 filter: function() {
-                    var cbc = DV.cmp.settings.category,
+                    var cbs = DV.cmp.settings.series,
+                        cbc = DV.cmp.settings.category,
                         cbf = DV.cmp.settings.filter,
                         v = cbc.getValue(),
                         d = DV.conf.finals.dimension.data.value,
@@ -1116,8 +1111,25 @@
                     
                     cbf.store.filterBy( function(r) {
                         return cbf.filterArray[index++];
-                    });
-                }
+                    });                    
+                    
+                    if (!cbf.getValue()) {
+						cbf.setValue(this.getAutoSelectOption(cbs.getValue(), cbc.getValue()));
+                    }
+                },
+                clearValue: function(v, cb, i, d) {
+                    if (v === cb.getValue()) {
+                        cb.clearValue();
+                    }
+                },
+                getAutoSelectOption: function(o1, o2) {
+					var a = [DV.conf.finals.dimension.data.value, DV.conf.finals.dimension.period.value, DV.conf.finals.dimension.organisationunit.value];
+					for (var i = 0; i < a.length; i++) {
+						if (a[i] != o1 && a[i] != o2) {
+							return a[i];
+						}
+					}
+				}
             }
         },
         checkbox: {
@@ -2383,7 +2395,6 @@
                                             },
                                             select: function() {
                                                 DV.util.combobox.filter.category();
-                                                DV.util.dimension.panel.setDimensionLabels();
                                             }
                                         }
                                     }