patron holds : edit dates
authorBill Erickson <berick@esilibrary.com>
Thu, 3 Jul 2014 18:29:52 +0000 (14:29 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 3 Jul 2014 18:29:52 +0000 (14:29 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_holds.tt2
Open-ILS/src/templates/staff/circ/share/t_hold_dates.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/circ/share/t_hold_notification_prefs.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/holds.js
Open-ILS/web/js/ui/default/staff/circ/services/holds.js
Open-ILS/web/js/ui/default/staff/services/ui.js

index d1ff57f..ea0c7dd 100644 (file)
@@ -25,6 +25,8 @@
     label="[% l('Edit Pickup Library') %]"></eg-grid-action>
   <eg-grid-action handler="edit_notify_prefs"
     label="[% l('Edit Notification Settings') %]"></eg-grid-action>
+  <eg-grid-action handler="edit_dates"
+    label="[% l('Edit Hold Dates') %]"></eg-grid-action>
   <eg-grid-action handler="cancel_hold"
     label="[% l('Cancel Hold') %]"></eg-grid-action>
 
diff --git a/Open-ILS/src/templates/staff/circ/share/t_hold_dates.tt2 b/Open-ILS/src/templates/staff/circ/share/t_hold_dates.tt2
new file mode 100644 (file)
index 0000000..b145d0e
--- /dev/null
@@ -0,0 +1,75 @@
+<div class="modal-content" id='hold-notify-settings'>
+  <div class="modal-header">
+    <button type="button" class="close" 
+      ng-click="cancel()" aria-hidden="true">&times;</button>
+    <h4 class="modal-title">
+      [% l('Modify Dates for [_1] Hold(s)', '{{num_holds}}') %]
+    </h4>
+  </div>
+  <div class="modal-body">
+    <div class="row header-row">
+      <div class="col-md-12">
+        [% l('Check the checkbox next to each field you wish to modify.') %]
+      </div>
+    </div>
+    <hr/>
+    <div class="row">
+      <div class="col-md-1">
+        <label for="modify_thaw_date" class="sr-only">[% l('Update Activate Email') %]</label>
+        <input id='modify_thaw_date' ng-model="args.modify_thaw_date" type="checkbox"/>
+      </div>
+      <div class="col-md-4">
+        <label for='thaw_date'>[% l("Hold Activate Date") %]</label>
+      </div>
+      <div class="col-md-7">
+        <input id='thaw_date' eg-date-input 
+          ng-disabled="!args.modify_thaw_date" ng-model="args.thaw_date"/>
+      </div>
+    </div>
+    <div class="row">
+      <div class="col-md-1">
+        <label for="modify_request_time" class="sr-only">[% l('Update Phone Number') %]</label>
+        <input id='modify_request_time' ng-model="args.modify_request_time" type="checkbox"/>
+      </div>
+      <div class="col-md-4">
+        <label for='request_time'>[% l("Hold Request Date") %]</label>
+      </div>
+      <div class="col-md-7">
+        <input id='request_time' eg-date-input 
+          ng-disabled="!args.modify_request_time" ng-model="args.request_time"/>
+      </div>
+    </div>
+    <div class="row">
+      <div class="col-md-1">
+        <label for="modify_expire_time" class="sr-only">[% l('Update Expire Time') %]</label>
+        <input id='modify_expire_time' ng-model="args.modify_expire_time" type="checkbox"/>
+      </div>
+      <div class="col-md-4">
+        <label for='expire_time'>[% l("Hold Expire Date") %]</label>
+      </div>
+      <div class="col-md-7">
+        <input id='expire_time' eg-date-input 
+          ng-disabled="!args.modify_expire_time" ng-model="args.expire_time"/>
+      </div>
+    </div>
+    <div class="row">
+      <div class="col-md-1">
+        <label for="modify_shelf_expire_time" class="sr-only">[% l('Update SMS Carrier') %]</label>
+        <input id='modify_shelf_expire_time' ng-model="args.modify_shelf_expire_time" type="checkbox"/>
+      </div>
+      <div class="col-md-4">
+        <label for='shelf_expire_time'>[% l("Shelf Expire Date") %]</label>
+      </div>
+      <div class="col-md-7">
+        <input id='shelf_expire_time' eg-date-input 
+          ng-disabled="!args.modify_shelf_expire_time" ng-model="args.shelf_expire_time"/>
+      </div>
+    </div>
+  </div>
+  <div class="modal-footer">
+    <button class="btn btn-default" ng-click="ok()">[% l('Submit') %]</button>
+    <button class="btn btn-warning" ng-click="cancel()">[% l('Cancel') %]</button>
+  </div>
+</div>
+
+
index c0f55d2..7f2659d 100644 (file)
@@ -3,7 +3,7 @@
     <button type="button" class="close" 
       ng-click="cancel()" aria-hidden="true">&times;</button>
     <h4 class="modal-title">
-      [% l('Edit Hold Notification Settings') %]
+      [% l('Edit Notification Settings for [_1] Hold(s)', '{{num_holds}}') %]
     </h4>
   </div>
   <div class="modal-body">
@@ -15,7 +15,8 @@
     <hr/>
     <div class="row">
       <div class="col-md-1">
-        <input id='use-email' ng-model="args.update_email_notify" type="checkbox"/>
+        <label for="activate-use-email" class="sr-only">[% l('Update Activate Email') %]</label>
+        <input id='activate-use-email' ng-model="args.update_email_notify" type="checkbox"/>
       </div>
       <div class="col-md-4">
         <label for='use-email'>[% l("Send Emails") %]</label>
     </div>
     <div class="row">
       <div class="col-md-1">
-        <input id='use-phone' ng-model="args.update_phone_notify" type="checkbox"/>
+        <label for="activate-phone-number" class="sr-only">[% l('Update Phone Number') %]</label>
+        <input id='activate-phone-number' ng-model="args.update_phone_notify" type="checkbox"/>
       </div>
       <div class="col-md-4">
-        <label for='use-phone'>[% l("Phone #") %]</label>
+        <label for='phone-number'>[% l("Phone #") %]</label>
       </div>
       <div class="col-md-7">
-        <input type='tel' ng-model="args.phone_notify" ng-disabled="!args.update_phone_notify"/>
+        <input id="phone-number" type='tel' 
+          ng-model="args.phone_notify" ng-disabled="!args.update_phone_notify"/>
       </div>
     </div>
     <div class="row">
       <div class="col-md-1">
-        <input id='use-sms' ng-model="args.update_sms_notify" type="checkbox"/>
+        <label for="activate-sms-number" class="sr-only">[% l('Update SMS Number') %]</label>
+        <input id='activate-sms-number' ng-model="args.update_sms_notify" type="checkbox"/>
       </div>
       <div class="col-md-4">
-        <label for='use-sms'>[% l("Text/SMS #") %]</label>
+        <label for='sms-number'>[% l("Text/SMS #") %]</label>
       </div>
       <div class="col-md-7">
-        <input type='tel' ng-model="args.sms_notify" ng-disabled="!args.update_sms_notify"/>
+        <input id="sms-number" type='tel' 
+          ng-model="args.sms_notify" ng-disabled="!args.update_sms_notify"/>
       </div>
     </div>
     <div class="row">
       <div class="col-md-1">
-        <input id='sms-carrier' ng-model="args.update_sms_carrier" type="checkbox"/>
+        <label for="activate-sms-carrier" class="sr-only">[% l('Update SMS Carrier') %]</label>
+        <input id='activate-sms-carrier' ng-model="args.update_sms_carrier" type="checkbox"/>
       </div>
       <div class="col-md-4">
         <label for='sms-carrier'>[% l("SMS Carrier") %]</label>
       </div>
       <div class="col-md-7">
-        <select ng-model="args.sms_carrier" ng-disabled="!args.update_sms_carrier"
+        <select id='sms-carrier'
+          ng-model="args.sms_carrier" 
+          ng-disabled="!args.update_sms_carrier"
           ng-options="carrier.name() for carrier in sms_carriers">
         </select>
       </div>
index ca54d56..8720003 100644 (file)
@@ -129,6 +129,9 @@ function($scope,  $q,  $routeParams,  egCore,  egUser,  patronSvc,
     $scope.edit_notify_prefs = function(items) {
         generic_update(items, 'edit_notify_prefs');
     }
+    $scope.edit_dates = function(items) {
+        generic_update(items, 'edit_dates');
+    }
 
 }])
 
index 2d4808e..a49fb89 100644 (file)
@@ -142,6 +142,7 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) {
                 function($scope, $modalInstance, sms_carriers) {
                     $scope.args = {}
                     $scope.sms_carriers = sms_carriers;
+                    $scope.num_holds = hold_ids.length;
                     $scope.ok = function() { 
 
                         var vals = hold_ids.map(function(hold_id) {
@@ -172,6 +173,50 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) {
         }).result;
     }
 
+    service.edit_dates = function(hold_ids) {
+        if (!hold_ids.length) return $q.when();
+
+        // collects the fields from the dialog the user wishes to modify
+        function relay_to_update(modal_scope) {
+            var vals = hold_ids.map(function(hold_id) {
+                var val = {id : hold_id};
+                angular.forEach(
+                    ['thaw_date', 'request_time', 'expire_time', 'shelf_expire_time'], 
+                    function(field) {
+                        if (modal_scope.args['modify_' + field]) 
+                            val[field] = modal_scope.args[field].toISOString();
+                    }
+                );
+
+                return val;
+            });
+
+            console.log(JSON.stringify(vals,null,2));
+            return service.update_holds(vals);
+        }
+
+        return $modal.open({
+            templateUrl : './circ/share/t_hold_dates',
+            controller : 
+                ['$scope', '$modalInstance',
+                function($scope, $modalInstance) {
+                    var today = new Date();
+                    $scope.args = {
+                        thaw_date : today,
+                        request_time : today,
+                        expire_time : today,
+                        shelf_expire_time : today
+                    }
+                    $scope.num_holds = hold_ids.length;
+                    $scope.ok = function() { 
+                        relay_to_update($scope).then($modalInstance.close);
+                    }
+                    $scope.cancel = function() { $modalInstance.dismiss() }
+                }
+            ],
+        }).result;
+    }
+
     return service;
 }])
 
index 91dc54f..138394a 100644 (file)
@@ -264,12 +264,27 @@ It also allows us to abstract away some browser finickiness.
             template: '<input type="date"></input>',
             replace: true,
             link: function(scope, elm, attrs, ngModelCtrl) {
+
+                // since this is a date-only selector, set the time
+                // portion to 00:00:00, which should better match the
+                // user's expectations.  Note this allows us to retain
+                // the timezone.
+                function strip_time(date) {
+                    date.setHours(0);
+                    date.setMinutes(0);
+                    date.setSeconds(0);
+                    date.setMilliseconds(0);
+                    return date;
+                }
+
                 ngModelCtrl.$formatters.unshift(function (modelValue) {
-                    return dateFilter(modelValue, 'yyyy-MM-dd');
+                    // apply strip_time here in case the user never 
+                    // modifies the date value.
+                    return dateFilter(strip_time(modelValue), 'yyyy-MM-dd');
                 });
                 
                 ngModelCtrl.$parsers.unshift(function(viewValue) {
-                    return new Date(viewValue);
+                    return strip_time(new Date(viewValue));
                 });
             },
         };