changes to time selector in staff interface
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 5 Jun 2020 20:33:49 +0000 (16:33 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 5 Jun 2020 20:35:21 +0000 (16:35 -0400)
* display the number of available appointments at each time
* disable times that have no available appointments (this
  does account for the appointment's current select time)

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/circ/curbside/t_schedule_pickup.tt2
Open-ILS/web/js/ui/default/staff/circ/curbside/directives/schedule_pickup.js

index 63448eb..678db78 100644 (file)
         <select class="form-control" id="appointment-time" ng-model="appt.slot_time"
                 name="slot_time" style="display: block;"
                 required ng-focus="refreshAvailableTimes(appt)">
-          <option ng-repeat="t in appt.available_times track by t.time" value="{{t.time}}">[% l('[_1] (Available: [_2])', '{{t.time_fmt}}', '{{t.available}}') %]</option>
+          <option value=""></option>
+          <option ng-repeat="t in appt.available_times track by t.time" value="{{t.time}}"
+                  ng-disabled="t.available === 0 && appt.original_slot_time !== t.time">
+            [% l('[_1] (Available: [_2])', '{{t.time_fmt}}', '{{t.available}}') %]
+        </option>
         </select>
       </div>
       <div class="col-md-2">
index 8cadbc3..a9ca76e 100644 (file)
@@ -226,15 +226,20 @@ function($scope , $q , egCurbsideCoreSvc , egCore , patronSvc ,
 
     function mungeAvailableTimes(hash, times) {
         var existing_present = false;
+        if (angular.isDefined(hash.slot_time) && hash.slot_time !== null) {
+            hash.original_slot_time = hash.slot_time;
+        }
         hash.available_times = times.map(function(t) {
-            if (hash.slot_time !== null && hash.slot_time === t[0]) existing_present = true;
+            if (angular.isDefined(hash.slot_time) && hash.slot_time !== null && hash.slot_time === t[0]) {
+                existing_present = true;
+            }
             return {
                 time: t[0],
                 available: t[1],
                 time_fmt: moment(t[0], [moment.ISO_8601, 'HH:mm:ss']).format('LT')
             };
         });
-        if (hash.slot_time !== null && !existing_present) {
+        if (angular.isDefined(hash.slot_time) && hash.slot_time !== null && !existing_present) {
             hash.available_times.unshift({
                 time: hash.slot_time,
                 available: 0,