LP#1880028 Backdate Checkins Until Logout Option
authorDan Briem <dbriem@wlsmail.org>
Sat, 30 May 2020 23:27:39 +0000 (19:27 -0400)
committerJason Boyer <JBoyer@equinoxinitiative.org>
Thu, 3 Sep 2020 21:50:42 +0000 (17:50 -0400)
- Adds a checkbox option to store the backdate as a
  session item and only loads the backdate on the checkin
  screen (backdate ignored on the hold capture screen)
- Adjusts existing $watch to enable/disable the checkbox
  and store/remove session backdate when appropriate
- Adjusts is_backdate() to not consider null or undefined
  dates as backdates so the visible alert is accurate
- Adjusts "today" comparison to use a time of 00:00:00 so
  that when the Clear button is used and clears the time
  the Today button won't cause a backdate just because it's
  an earlier time on the same date

Signed-off-by: Dan Briem <dbriem@wlsmail.org>
Signed-off-by: rfrasur <rfrasur@library.in.gov>
Signed-off-by: Dawn Dale <ddale@georgialibraries.org>
Signed-off-by: Jason Boyer <JBoyer@equinoxinitiative.org>

Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2
Open-ILS/web/js/ui/default/staff/circ/checkin/app.js

index 417f26a..6e505de 100644 (file)
@@ -9,9 +9,14 @@
 
 <div class="row">
   <div class="col-md-12">
-    <div ng-if="is_backdate()" class="alert-danger pad-all-min">
-      [% l('Backdated Check In [_1]', 
-        '{{checkinArgs.backdate | date:$root.egDateFormat}}') %]
+    <div ng-if="is_backdate()">
+      <div class="alert-danger pad-all-min">
+        [% l('Backdated Check In [_1]', 
+          '{{checkinArgs.backdate | date:$root.egDateFormat}}') %]
+      </div>
+      <div ng-if="backdate.untilLogout" class="alert-danger pad-all-min">
+        [% l('Use Effective Date Until Logout') %]
+      </div>
     </div>
     <div ng-if="modifiers.no_precat_alert" class="alert-danger pad-all-min">
       [% l('Ignore Pre-Cataloged Items') %]
       <div><eg-date-input ng-model="checkinArgs.backdate"></eg-date-input>
       </div>
     </div>
+    <div class="flex-row" ng-show="is_backdate()">
+      <div class="flex-cell"></div>
+      <div class="checkbox pad-horiz">
+        <label>
+          <input type="checkbox" ng-model="backdate.untilLogout" ng-change="onUntilLogoutChange()"/>
+          [% l('Use effective date until logout') %]
+        </label>
+      </div>
+    </div>
   </div>
 </div>
 
index eb360c9..5c89922 100644 (file)
@@ -39,7 +39,7 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg
 
     $scope.focusMe = true;
     $scope.checkins = checkinSvc.checkins;
-    var today = new Date();
+    var today = new Date(new Date().setHours(0,0,0,0));
     $scope.checkinArgs = {backdate : today}
     $scope.modifiers = {};
     $scope.fine_total = 0;
@@ -90,6 +90,26 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg
         modifiers.push('noop'); // AKA suppress holds and transits
         modifiers.push('auto_print_holds_transits');
         modifiers.push('do_inventory_update');
+
+        // backdate is possible so load options
+        $scope.backdate = {date: egCore.hatch.getSessionItem('eg.circ.checkin.backdate')};
+        $scope.backdate.untilLogout = !!$scope.backdate.date;
+        if ($scope.backdate.untilLogout)
+            $scope.checkinArgs.backdate = new Date($scope.backdate.date);
+
+        // watch backdate to enable/disable the sticky option
+        // and ensure the backdate is not in the future
+        // note: input type=date max=foo not yet supported anywhere
+        $scope.$watch('checkinArgs.backdate', function(newval) {
+            if (!newval || newval.getTime() == today.getTime()) {
+                $scope.backdate.untilLogout = false;
+                egCore.hatch.removeSessionItem('eg.circ.checkin.backdate');
+            } else if (newval > today) {
+                $scope.checkinArgs.backdate = today;
+            } else if ($scope.backdate.untilLogout) {
+                egCore.hatch.setSessionItem('eg.circ.checkin.backdate', newval);
+            }
+        });
     }
 
     // set modifiers from stored preferences
@@ -116,16 +136,17 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg
         }
     }
 
-
-    // ensure the backdate is not in the future
-    // note: input type=date max=foo not yet supported anywhere
-    $scope.$watch('checkinArgs.backdate', function(newval) {
-        if (newval && newval > today) 
-            $scope.checkinArgs.backdate = today;
-    });
+    $scope.onUntilLogoutChange = function() {
+        if ($scope.backdate.untilLogout)
+            egCore.hatch.setSessionItem('eg.circ.checkin.backdate',
+                $scope.checkinArgs.backdate
+            );
+        else
+            egCore.hatch.removeSessionItem('eg.circ.checkin.backdate');
+    };
 
     $scope.is_backdate = function() {
-        return $scope.checkinArgs.backdate < today;
+        return $scope.checkinArgs.backdate && $scope.checkinArgs.backdate < today;
     }
 
     var checkinGrid = $scope.gridControls = {};