From: Galen Charlton Date: Tue, 2 Jun 2020 22:36:56 +0000 (-0400) Subject: finish schedule pickup tab for the staff interface X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f1ca476c2aa957ac549f06b646b7361521968ab3;p=working%2FEvergreen.git finish schedule pickup tab for the staff interface Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/templates/staff/circ/curbside/index.tt2 b/Open-ILS/src/templates/staff/circ/curbside/index.tt2 index e17ec40dbf..efbf9800f6 100644 --- a/Open-ILS/src/templates/staff/circ/curbside/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/curbside/index.tt2 @@ -26,6 +26,12 @@ angular.module('egCoreMod').run(['egStrings', function(s) { s.SUCCESS_CURBSIDE_MARK_DELIVERED = "[% l('Marked curbside appointment {{slot_id}} as delivered') %]"; s.NOTFOUND_CURBSIDE_MARK_DELIVERED = "[% l('Could not find curbside appointment {{slot_id}} to mark as delivered') %]"; s.FAILED_CURBSIDE_MARK_DELIVERED = "[% l('Failed to mark curbside appointment {{slot_id}} as delivered: {{evt_code}}') %]"; + s.CONFIRM_CANCEL_TITLE = "[% l('Cancel Curbside Pickup Appointment') %]"; + s.CONFIRM_CANCEL_BODY = "[% l('Cancel curbside pickup appointment [_1]?', '{{slot_id}}') %]"; + s.SUCCESS_CANCEL_APPOINTMENT = "[% l('Canceled curbside appointment {{slot_id}}') %]"; + s.FAILED_CANCEL_APPOINTMENT = "[% l('Failed to cancel curbside appointment {{slot_id}} ({{evt_code}})') %]"; + s.SUCCESS_SAVE_APPOINTMENT = "[% l('Saved curbside appointment {{slot_id}}') %]"; + s.FAILED_SAVE_APPOINTMENT = "[% l('Failed to save changes to curbside appointment ({{evt_code}})') %]"; }]); [% END %] diff --git a/Open-ILS/src/templates/staff/circ/curbside/t_schedule_pickup.tt2 b/Open-ILS/src/templates/staff/circ/curbside/t_schedule_pickup.tt2 index 65dae44e42..2425a26ce3 100644 --- a/Open-ILS/src/templates/staff/circ/curbside/t_schedule_pickup.tt2 +++ b/Open-ILS/src/templates/staff/circ/curbside/t_schedule_pickup.tt2 @@ -38,4 +38,38 @@
[% l('Patron has [_1] ready holds at this location.', '{{readyHolds}}') %]
+ +
+ +
+
+
+ +
+ +
{{appt.id}}
+
+
+ + + +
+
+ + +
+
+ +
+ + +
+
+
+
diff --git a/Open-ILS/web/js/ui/default/staff/circ/curbside/directives/schedule_pickup.js b/Open-ILS/web/js/ui/default/staff/circ/curbside/directives/schedule_pickup.js index 7ec9be67a4..c4b9f8b37e 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/curbside/directives/schedule_pickup.js +++ b/Open-ILS/web/js/ui/default/staff/circ/curbside/directives/schedule_pickup.js @@ -16,6 +16,8 @@ function($scope , $q , egCurbsideCoreSvc , egCore , patronSvc , $scope.user_id = undefined; $scope.args = {}; $scope.readyHolds = 0; + $scope.openAppointments = []; + $scope.forms = []; } $scope.clear(); @@ -207,11 +209,150 @@ function($scope , $q , egCurbsideCoreSvc , egCore , patronSvc , }); } + function fetchOpenAppointments(user_id) { + return egCore.net.request( + 'open-ils.curbside', + 'open-ils.curbside.open_user_appointments_at_lib.atomic', + egCore.auth.token(), + user_id + ).then(function(resp) { + if (evt = egCore.evt.parse(resp)) { + return 0; + } else { + return resp; + } + }); + } + + function mungeOneAppointment(c, isNew) { + var hash = egCore.idl.toHash(c); + if (hash.slot === null) { + // coerce to today for the purpose of the + // form if no slot time has been set yet + hash.slot = new Date().toISOString(); + hash.slot_time = null; + } else { + if (!isNew) { + hash.slot_time = hash.slot.substring(11, 19); + } + } + hash.slot_date = new Date(hash.slot); + hash.available_times = []; + egCore.net.request ( + 'open-ils.curbside', + 'open-ils.curbside.times_for_date.atomic', + egCore.auth.token(), + hash.slot.substring(0, 10), + ).then(function(times) { + hash.available_times = times.map(function(t) { return t[0]; }); + }); + return hash; + } + + function mungeAppointmentList(list) { + $scope.openAppointments = list.map(function(c) { + var hash = mungeOneAppointment(c); + return hash; + }); + } + function loadPatron(user_id) { $scope.user_id = user_id; patronSvc.getPrimary(user_id); countReadyHolds(user_id).then(function(ct) { $scope.readyHolds = ct }); + fetchOpenAppointments(user_id).then(function(list) { + mungeAppointmentList(list); + }); + } + + + $scope.minDate = new Date(); + $scope.refreshAvailableTimes = function(hash) { + var dateStr = (new Date(hash.slot_date)).toISOString().substring(0, 10); + egCore.net.request ( + 'open-ils.curbside', + 'open-ils.curbside.times_for_date.atomic', + egCore.auth.token(), + dateStr, + ).then(function(times) { + hash.available_times = times.map(function(t) { return t[0]; }); + }); } + + $scope.startNewAppointment = function() { + var slot = new egCore.idl.acsp(); + slot.slot = new Date().toISOString(); + slot.patron = $scope.user_id; + slot.org = egCore.auth.user().ws_ou(); + $scope.openAppointments = [ mungeOneAppointment(slot, true) ]; + } + + $scope.updateAppointment = function(appt) { + var op = angular.isDefined(appt.id) ? 'update' : 'create'; + egCore.net.request( + 'open-ils.curbside', + 'open-ils.curbside.' + op + '_appointment', + egCore.auth.token(), + $scope.user_id, + (new Date(appt.slot_date)).toISOString().substring(0, 10), + appt.slot_time + ).then(function(resp) { + if (evt = egCore.evt.parse(resp)) { + ngToast.danger(egCore.strings.$replace( + egCore.strings.FAILED_SAVE_APPOINTMENT, + { evt_code : evt.code } + )); + } else { + ngToast.success(egCore.strings.$replace( + egCore.strings.SUCCESS_SAVE_APPOINTMENT, + { slot_id : resp.id() } + )); + } + fetchOpenAppointments($scope.user_id).then(function(list) { + mungeAppointmentList(list); + }); + }); + } + + function doCancel(id) { + egCore.net.request ( + 'open-ils.curbside', + 'open-ils.curbside.delete_appointment', + egCore.auth.token(), + id + ).then(function(resp) { + if (!angular.isDefined(resp)) { + ngToast.danger(egCore.strings.$replace( + egCore.strings.FAILED_CANCEL_APPOINTMENT, + { slot_id : id, evt_code : 'NO_SUCH_APPOINTMENT' } + )); + } else if (evt = egCore.evt.parse(resp)) { + ngToast.danger(egCore.strings.$replace( + egCore.strings.FAILED_CANCEL_APPOINTMENT, + { slot_id : id, evt_code : evt.code } + )); + } else { + ngToast.success(egCore.strings.$replace( + egCore.strings.SUCCESS_CANCEL_APPOINTMENT, + { slot_id : id } + )); + } + fetchOpenAppointments($scope.user_id).then(function(list) { + mungeAppointmentList(list); + }); + }); + } + $scope.cancelAppointment = function(id) { + egConfirmDialog.open( + egCore.strings.CONFIRM_CANCEL_TITLE, + egCore.strings.CONFIRM_CANCEL_BODY, + { slot_id : id, + ok : function() { doCancel(id) }, + cancel : function() {} + } + ); + } + $scope.patron = function() { return patronSvc.current; }