Author: joyce
Date: Tue Jun  4 21:27:40 2013
New Revision: 1489622

URL: http://svn.apache.org/r1489622
Log:
Resolves CLIMATE-76 - Add parameter checks when user changes values.

- Adds ParameterSelectCtrl.checkParameters() which ensures that all user
  input falls into the valid range as determined by the currently
  selected datasets.
- Updates all the parameter selection fields with an on-blur event that
  calls the new 'checkParameters' function.
- The ParameterSelectCtrl now maintains a record of the min/max
  lat/lon/time values when the datasets object changes. This allows for
  input changes to be tested properly!

Modified:
    incubator/climate/trunk/rcmet/src/main/ui/app/index.html
    incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers.js

Modified: incubator/climate/trunk/rcmet/src/main/ui/app/index.html
URL: 
http://svn.apache.org/viewvc/incubator/climate/trunk/rcmet/src/main/ui/app/index.html?rev=1489622&r1=1489621&r2=1489622&view=diff
==============================================================================
--- incubator/climate/trunk/rcmet/src/main/ui/app/index.html (original)
+++ incubator/climate/trunk/rcmet/src/main/ui/app/index.html Tue Jun  4 
21:27:40 2013
@@ -86,13 +86,13 @@
       <div class="span1 offset2 text-center">Start Date:</div>
       <div class="span2">
         <form>
-          <input type="text" class="text-center span2" 
ng-model="displayParams.start" ui-date="datepickerSettings" 
ui-date-format="yy-mm-dd" />
+          <input type="text" class="text-center span2" 
on-blur="checkParameters();" ng-model="displayParams.start" 
ui-date="datepickerSettings" ui-date-format="yy-mm-dd" />
         </form>
       </div>
       <div class="span1 text-center">End Date:</div>
       <div class="span2">
         <form>
-          <input type="text" class="text-center span2" 
ng-model="displayParams.end" ui-date="datepickerSettings" 
ui-date-format="yy-mm-dd" />
+          <input type="text" class="text-center span2" 
on-blur="checkParameters();" ng-model="displayParams.end" 
ui-date="datepickerSettings" ui-date-format="yy-mm-dd" />
         </form>
       </div>
       <div class="span1">
@@ -112,13 +112,13 @@
       <div class="span1 offset2 text-center">North:</div>
       <div class="span2">
         <form action="">
-                     <input ng-model="displayParams.latMax" type="text" 
class="span2 text-center" />
+                     <input ng-model="displayParams.latMax"  
on-blur="checkParameters();" type="text" class="span2 text-center" />
         </form>
       </div>
       <div class="span1 text-center">East:</div>
       <div class="span2">
         <form>
-                     <input ng-model="displayParams.lonMax" type="text" 
class="span2 text-center" />
+                     <input ng-model="displayParams.lonMax" 
on-blur="checkParameters();" type="text" class="span2 text-center" />
         </form>
       </div>
       <div class="span2">
@@ -132,13 +132,13 @@
       <div class="span1 offset2 text-center">South:</div>
       <div class="span2">
         <form action="">
-                     <input ng-model="displayParams.latMin" type="text" 
class="span2 text-center" />
+                     <input ng-model="displayParams.latMin" 
on-blur="checkParameters();" type="text" class="span2 text-center" />
         </form>
       </div>
       <div class="span1 text-center">West:</div>
       <div class="span2">
         <form>
-                     <input ng-model="displayParams.lonMin" type="text" 
class="span2 text-center" />
+                     <input ng-model="displayParams.lonMin" 
on-blur="checkParameters();"; type="text" class="span2 text-center" />
         </form>
       </div>
     </div>

Modified: incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers.js
URL: 
http://svn.apache.org/viewvc/incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers.js?rev=1489622&r1=1489621&r2=1489622&view=diff
==============================================================================
--- incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers.js (original)
+++ incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers.js Tue Jun  4 
21:27:40 2013
@@ -241,6 +241,25 @@ function ParameterSelectCtrl($rootScope,
                });
        }
 
+       // Check the Parameter selection boxes after the user has changed input 
to ensure that valid
+       // values were entered
+       $scope.checkParameters = function() {
+               if ($scope.displayParams.latMin < $scope.latMin) 
+                       $scope.displayParams.latMin = $scope.latMin;
+               if ($scope.displayParams.latMax > $scope.latMax) 
+                       $scope.displayParams.latMax = $scope.latMax;
+               if ($scope.displayParams.lonMin < $scope.lonMin) 
+                       $scope.displayParams.lonMin = $scope.lonMin;
+               if ($scope.displayParams.lonMax > $scope.lonMax) 
+                       $scope.displayParams.lonMax = $scope.lonMax;
+               if ($scope.displayParams.start < $scope.start) 
+                       $scope.displayParams.start = $scope.start;
+               if ($scope.displayParams.end > $scope.end)
+                       $scope.displayParams.end = $scope.end;
+
+               $scope.$apply();
+       }
+
        $scope.$watch('datasets', 
                function() { 
                        var numDatasets = $scope.datasets.length;
@@ -272,12 +291,21 @@ function ParameterSelectCtrl($rootScope,
                                $scope.areInUserRegridState = !datasetRegrid
                        }
 
+                       // Update the display parameters with the new valid 
overlap that we've found!
                        $scope.displayParams.latMin = latMin;
                        $scope.displayParams.latMax = latMax;
                        $scope.displayParams.lonMin = lonMin;
                        $scope.displayParams.lonMax = lonMax;
                        $scope.displayParams.start = start.split(" ")[0];
                        $scope.displayParams.end = end.split(" ")[0];
+
+                       // Update the local store values!
+                       $scope.latMin = latMin;
+                       $scope.latMax = latMax;
+                       $scope.lonMin = lonMin;
+                       $scope.lonMax = lonMax;
+                       $scope.start = start.split(" ")[0];
+                       $scope.end = end.split(" ")[0];
                }, true);
 }
 


Reply via email to