LP#1717025 - make Specific Due Dates Until Logout in Patron Checkout
authorCesar Velez <cesar.velez@equinoxinitiative.org>
Thu, 21 Sep 2017 19:58:49 +0000 (15:58 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 16 Oct 2017 19:37:37 +0000 (15:37 -0400)
Made a few (opinionated) changes, that try to follow some JS
best practices. Changed Bool flags like date_options.sticky_date
to has_sticky_date, which avoids confusion with the checkoutArgs
property of the same name, and provides a clue about it's type
and function. Also added semicolons to any JS statements and
function expressions that were missing them.

Signed-off by: Cesar Velez <cesar.velez@equinoxinitiative.org>

Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js

index a2db38e..773d911 100644 (file)
       <ul class="pull-right" uib-dropdown-menu>
         <li>
           <a href
-            ng-click="toggle_opt('sticky_date')">
-            <span ng-if="date_options.sticky_date"
+            ng-click="toggle_opt('has_sticky_date')">
+            <span ng-if="date_options.has_sticky_date"
               class="label label-success">&#x2713;</span>
-            <span ng-if="!date_options.sticky_date"
+            <span ng-if="!date_options.has_sticky_date"
               class="label label-warning">&#x2717;</span>
             <span>[% l('Specific Due Date') %]</span>
           </a>
         </li>
         <li>
           <a href
-            ng-click="toggle_opt('until_logout')">
-            <span ng-if="date_options.until_logout"
+            ng-click="toggle_opt('is_until_logout')">
+            <span ng-if="date_options.is_until_logout"
               class="label label-success">&#x2713;</span>
-            <span ng-if="!date_options.until_logout"
+            <span ng-if="!date_options.is_until_logout"
               class="label label-warning">&#x2717;</span>
             <span>[% l('Use Specific Due Date Until Logout') %]</span>
           </a>
index 7c42a27..52f7944 100644 (file)
@@ -47,11 +47,11 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
 
     $scope.date_options = {
         due_date : egCore.hatch.getSessionItem('eg.circ.checkout.due_date'),
-        sticky_date : egCore.hatch.getSessionItem('eg.circ.checkout.until_logout'),
-        until_logout : egCore.hatch.getSessionItem('eg.circ.checkout.until_logout')
-    }
+        has_sticky_date : egCore.hatch.getSessionItem('eg.circ.checkout.is_until_logout'),
+        is_until_logout : egCore.hatch.getSessionItem('eg.circ.checkout.is_until_logout')
+    };
 
-    if ($scope.date_options.until_logout) { // If until_logout is set there should also be a date set. 
+    if ($scope.date_options.is_until_logout) { // If until_logout is set there should also be a date set.
         $scope.checkoutArgs.due_date = new Date($scope.date_options.due_date);
         $scope.checkoutArgs.sticky_date = true;
     }
@@ -62,32 +62,32 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
         } else {
             $scope.date_options[opt] = true;
         }
-    }
+    };
 
     // The interactions between these options are complicated enough that $watch'ing them all is the only safe way to keep things sane.
-    $scope.$watch('date_options.sticky_date', function(newval) {
+    $scope.$watch('date_options.has_sticky_date', function(newval) {
         if ( newval ) { // was false, is true
             // $scope.date_options.due_date = checkoutArgs.due_date;
         } else {
-            $scope.date_options.until_logout = false;
+            $scope.date_options.is_until_logout = false;
         }
         $scope.checkoutArgs.sticky_date = newval;
     });
 
-    $scope.$watch('date_options.until_logout', function(newval) {
+    $scope.$watch('date_options.is_until_logout', function(newval) {
         if ( newval ) { // was false, is true
-            $scope.date_options.sticky_date = true;
+            $scope.date_options.has_sticky_date = true;
             $scope.date_options.due_date = $scope.checkoutArgs.due_date;
-            egCore.hatch.setSessionItem('eg.circ.checkout.until_logout', true);
+            egCore.hatch.setSessionItem('eg.circ.checkout.is_until_logout', true);
             egCore.hatch.setSessionItem('eg.circ.checkout.due_date', $scope.checkoutArgs.due_date);
         } else {
-            egCore.hatch.removeSessionItem('eg.circ.checkout.until_logout');
+            egCore.hatch.removeSessionItem('eg.circ.checkout.is_until_logout');
             egCore.hatch.removeSessionItem('eg.circ.checkout.due_date');
         }
     });
 
     $scope.$watch('checkoutArgs.due_date', function(newval) {
-        if ( $scope.date_options.until_logout ) {
+        if ( $scope.date_options.is_until_logout ) {
             egCore.hatch.setSessionItem('eg.circ.checkout.due_date', newval);
         }
     });