From 87dc85c0661203f203af5ef60434ce6e1f2b6325 Mon Sep 17 00:00:00 2001 From: Jason Boyer Date: Wed, 13 Sep 2017 15:36:47 -0500 Subject: [PATCH] LP1717025: Persist Specific Due Dates Until Logout Add an option to the specific due date feature to save the specified date until logout. This allows all circulations from a given workstation to be due on the same date. Signed-off-by: Jason Boyer Signed-off-by: Cesar Velez Signed-off-by: Mike Rylander --- .../src/templates/staff/circ/patron/t_checkout.tt2 | 40 +++++++++++++++--- .../js/ui/default/staff/circ/patron/checkout.js | 47 ++++++++++++++++++++++ 2 files changed, 81 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2 index 9343c92e6c..a2db38ea44 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2 @@ -38,20 +38,48 @@ diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js index e85a3f753d..7c42a27413 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js @@ -45,6 +45,53 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc , } } + $scope.date_options = { + due_date : egCore.hatch.getSessionItem('eg.circ.checkout.due_date'), + sticky_date : egCore.hatch.getSessionItem('eg.circ.checkout.until_logout'), + until_logout : egCore.hatch.getSessionItem('eg.circ.checkout.until_logout') + } + + if ($scope.date_options.until_logout) { // If until_logout is set there should also be a date set. + $scope.checkoutArgs.due_date = new Date($scope.date_options.due_date); + $scope.checkoutArgs.sticky_date = true; + } + + $scope.toggle_opt = function(opt) { + if ($scope.date_options[opt]) { + $scope.date_options[opt] = false; + } else { + $scope.date_options[opt] = true; + } + } + + // The interactions between these options are complicated enough that $watch'ing them all is the only safe way to keep things sane. + $scope.$watch('date_options.sticky_date', function(newval) { + if ( newval ) { // was false, is true + // $scope.date_options.due_date = checkoutArgs.due_date; + } else { + $scope.date_options.until_logout = false; + } + $scope.checkoutArgs.sticky_date = newval; + }); + + $scope.$watch('date_options.until_logout', function(newval) { + if ( newval ) { // was false, is true + $scope.date_options.sticky_date = true; + $scope.date_options.due_date = $scope.checkoutArgs.due_date; + egCore.hatch.setSessionItem('eg.circ.checkout.until_logout', true); + egCore.hatch.setSessionItem('eg.circ.checkout.due_date', $scope.checkoutArgs.due_date); + } else { + egCore.hatch.removeSessionItem('eg.circ.checkout.until_logout'); + egCore.hatch.removeSessionItem('eg.circ.checkout.due_date'); + } + }); + + $scope.$watch('checkoutArgs.due_date', function(newval) { + if ( $scope.date_options.until_logout ) { + egCore.hatch.setSessionItem('eg.circ.checkout.due_date', newval); + } + }); + $scope.has_email_address = function() { return ( patronSvc.current && -- 2.11.0