LP#1783793 - Suspend holds when activation date set in web client angularjs
authorJosh Stompro <stompro@stompro.org>
Tue, 28 Jan 2020 16:04:02 +0000 (10:04 -0600)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 31 Jul 2020 22:06:02 +0000 (18:06 -0400)
1. Modify Dates popup changed to not allow picking dates in the past for hold
  activation date both in the date picker, and if typed in manually.  If a
  date in the past is typed in, it is changed to today's date and an alert
  message is displayed.  The date picker just won't allow past days to be
  selected.  The alert message remains until a date in the future is selected.

2. Suspend holds when the activation date is set and saved.

3. Adds a note about the fact that the hold will be suspended when the hold
  activation date is selected for editing.  This makes the behavior clear so
  staff don't have to figure it out by trial and error.

4. Updates several sr-only (Screen Reader Only) labels in the holds date popup
  template that were set to the wrong values.  The file was copied from the hold
  notification popup and the screen reader descriptions were left unchanged from
  those values.

Signed-off-by: Josh Stompro <stompro@stompro.org>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/circ/share/t_hold_dates.tt2
Open-ILS/web/js/ui/default/staff/circ/services/holds.js

index 3c25872..9aea27f 100644 (file)
@@ -15,7 +15,7 @@
     <hr/>
     <div class="row">
       <div class="col-md-1">
-        <label for="modify_thaw_date" class="sr-only">[% l('Update Activate Email') %]</label>
+        <label for="modify_thaw_date" class="sr-only">[% l('Update Hold Activate Date') %]</label>
         <input id='modify_thaw_date' ng-model="args.modify_thaw_date" type="checkbox"/>
       </div>
       <div class="col-md-4">
       </div>
       <div class="col-md-7">
         <eg-date-input id='thaw_date'
-          ng-disabled="!args.modify_thaw_date" ng-model="args.thaw_date">
+          ng-disabled="!args.modify_thaw_date" ng-model="args.thaw_date" min-date="minDate">
         </eg-date-input>
+        <p ng-hide="!args.modify_thaw_date">[% l('Setting an activation date will also suspend hold.') %]
+        </p>
+        <p ng-hide="!args.thaw_date_error" class="alert alert-warning">
+          [% l('Activation dates in the past not allowed, resetting to today!') %]
+        </p>
       </div>
     </div>
     <div class="row">
       <div class="col-md-1">
-        <label for="modify_request_time" class="sr-only">[% l('Update Phone Number') %]</label>
+        <label for="modify_request_time" class="sr-only">[% l('Update Request Time') %]</label>
         <input id='modify_request_time' ng-model="args.modify_request_time" type="checkbox"/>
       </div>
       <div class="col-md-4">
@@ -57,7 +62,7 @@
     </div>
     <div class="row">
       <div class="col-md-1">
-        <label for="modify_shelf_expire_time" class="sr-only">[% l('Update SMS Carrier') %]</label>
+        <label for="modify_shelf_expire_time" class="sr-only">[% l('Update Shelf Expire Date') %]</label>
         <input id='modify_shelf_expire_time' ng-model="args.modify_shelf_expire_time" type="checkbox"/>
       </div>
       <div class="col-md-4">
index dcc1d11..0ae837a 100644 (file)
@@ -305,8 +305,13 @@ function($uibModal , $q , egCore , egConfirmDialog , egAlertDialog) {
                 angular.forEach(
                     ['thaw_date', 'request_time', 'expire_time', 'shelf_expire_time'], 
                     function(field) {
-                        if (modal_scope.args['modify_' + field]) 
+                        if (modal_scope.args['modify_' + field]) 
                             val[field] = modal_scope.args[field].toISOString();
+                            if (field === 'thaw_date') {
+                            //If we are setting the thaw_date, freeze the hold.
+                                val['frozen'] = true;
+                            }
+                        }
                     }
                 );
 
@@ -335,6 +340,17 @@ function($uibModal , $q , egCore , egConfirmDialog , egAlertDialog) {
                         relay_to_update($scope).then($uibModalInstance.close);
                     }
                     $scope.cancel = function() { $uibModalInstance.dismiss() }
+                    $scope.minDate = new Date();
+                    //watch for changes to the hold dates, and perform validations
+                    $scope.$watch('args', function(newValue,oldValue,scope) {
+                        if (newValue['thaw_date'] && newValue['thaw_date'] < today) {
+                            $scope.args['thaw_date'] = today;
+                            $scope.args.thaw_date_error = true;
+                        }
+                        if (newValue['thaw_date'] && newValue['thaw_date'] > today) {
+                            $scope.args.thaw_date_error = false;
+                        }
+                    }, true);
                 }
             ],
         }).result;