From b029becb7736565cf3d28e048166a31e1e36e90b Mon Sep 17 00:00:00 2001 From: Mike Risher Date: Mon, 1 Jul 2019 15:56:17 +0000 Subject: [PATCH] LP1752356 Offline block list date addition In offline mode when checking out for an expired patron, we changed the error message so that the last date the blocklist was downloaded is displayed along with the patron barcode Signed-off-by: Mike Risher Changes to be committed: modified: Open-ILS/src/templates/staff/offline-interface.tt2 modified: Open-ILS/web/js/ui/default/staff/offline.js modified: Open-ILS/web/js/ui/default/staff/services/lovefield.js Signed-off-by: Bill Erickson --- Open-ILS/src/templates/staff/offline-interface.tt2 | 4 +- Open-ILS/web/js/ui/default/staff/offline.js | 55 +++++++++++++++------- .../web/js/ui/default/staff/services/lovefield.js | 21 +++++++++ 3 files changed, 60 insertions(+), 20 deletions(-) diff --git a/Open-ILS/src/templates/staff/offline-interface.tt2 b/Open-ILS/src/templates/staff/offline-interface.tt2 index dc7b56ba9b..dae9b17a2b 100644 --- a/Open-ILS/src/templates/staff/offline-interface.tt2 +++ b/Open-ILS/src/templates/staff/offline-interface.tt2 @@ -616,12 +616,12 @@ angular.module('egCoreMod').run(['egStrings', function(s) { "[% l('Please enter valid values for all required fields.') %]" s.REG_ADDR_REQUIRED = "[% l('An address is required during registration.') %]" - + s.PATRON_BLOCKED_WHY = {}; s.PATRON_BLOCKED_WHY.D = "[% l('Patron has penalties') %]"; s.PATRON_BLOCKED_WHY.L = "[% l('Barcode is reported Lost') %]"; s.PATRON_BLOCKED_WHY.E = "[% l('Patron account is Expired') %]"; - s.PATRON_BLOCKED_WHY.B = "[% l('Patron account is Barred') %]"; + s.PATRON_BLOCKED_WHY.B = "[% l('Warning: as of [_1], this barcode ([_2]) was flagged Expired.', '{{formatted_date}}', '{{pbarcode}}') %]"; }]); diff --git a/Open-ILS/web/js/ui/default/staff/offline.js b/Open-ILS/web/js/ui/default/staff/offline.js index 21e10b0dd3..371d439dbf 100644 --- a/Open-ILS/web/js/ui/default/staff/offline.js +++ b/Open-ILS/web/js/ui/default/staff/offline.js @@ -255,10 +255,10 @@ function($routeProvider , $locationProvider , $compileProvider) { .controller('OfflineCtrl', ['$q','$scope','$window','$location','$rootScope','egCore', 'egLovefield','$routeParams','$timeout','$http','ngToast', - 'egConfirmDialog','egUnloadPrompt','egProgressDialog', + 'egConfirmDialog','egUnloadPrompt','egProgressDialog', '$filter', function($q , $scope , $window , $location , $rootScope , egCore , egLovefield , $routeParams , $timeout , $http , ngToast , - egConfirmDialog , egUnloadPrompt, egProgressDialog) { + egConfirmDialog , egUnloadPrompt, egProgressDialog, $filter) { // Immediately redirect if we're really offline if (!$window.navigator.onLine) { @@ -289,7 +289,6 @@ function($routeProvider , $locationProvider , $compileProvider) { $scope.do_print = Boolean($scope.active_tab == 'checkout'); $scope.do_print_changed = false; $scope.printed = false; - $scope.imported_pending_xacts = { data : '' }; $scope.xact_page = { checkin:[], checkout:[], renew:[], in_house_use:[] }; @@ -301,6 +300,17 @@ function($routeProvider , $locationProvider , $compileProvider) { $scope.in_house_use = {count : 1}; $scope.checkin = { backdate : new Date() }; + egLovefield.getOfflineBlockDate().then( + function(blockListDateResp) { + $scope.blockListDate = Math.round(blockListDateResp.getTime()/1000); + console.log("get blocklistdate="); + console.log($scope.blockListDate) + }, + function() { + console.log("Error when retrieving block list download date"); + } + ); + $scope.current_workstation_owning_lib = function () { return $scope.workstations.filter(function(w) { return $scope.workstation == w.id @@ -405,6 +415,7 @@ function($routeProvider , $locationProvider , $compileProvider) { egProgressDialog.open(); egLovefield.populateBlockList().then( function(){ + egLovefield.setOfflineBlockDate(); ngToast.create(egCore.strings.OFFLINE_BLOCKLIST_SUCCESS); }, function(){ @@ -592,21 +603,29 @@ function($routeProvider , $locationProvider , $compileProvider) { egLovefield.testOfflineBlock(pbarcode).then(function (blocked) { if (blocked) { egCore.audio.play('warning.offline.blocked_patron'); - egConfirmDialog.open( - egCore.strings.PATRON_BLOCKED, - egCore.strings.PATRON_BLOCKED_WHY[blocked], - {}, egCore.strings.ALLOW, egCore.strings.REJECT - ).result.then( - function(){ // forced - $scope.blocked_patron = null; - _add_impl(xtype,true) - if (next_focus) $('#'+next_focus).focus(); - },function(){ // stopped - $scope.blocked_patron = xtype; - if (next_focus) $('#'+next_focus).focus(); - return; - } - ); + var default_format = 'mediumDate'; + egCore.org.settings(['format.date']).then(function(set) { + if (set && set['format.date']) default_format = set['format.date']; + $scope.date_format = default_format; + var fBlockListDate = $filter('date')(($scope.blockListDate * 1000), $scope.date_format) + egConfirmDialog.open( + egCore.strings.PATRON_BLOCKED, + egCore.strings.PATRON_BLOCKED_WHY[blocked], + {formatted_date: fBlockListDate, pbarcode: pbarcode}, + egCore.strings.ALLOW, + egCore.strings.REJECT + ).result.then( + function(){ // forced + $scope.blocked_patron = null; + _add_impl(xtype,true) + if (next_focus) $('#'+next_focus).focus(); + },function(){ // stopped + $scope.blocked_patron = xtype; + if (next_focus) $('#'+next_focus).focus(); + return; + } + ); + }); } else { $scope.blocked_patron = null; _add_impl(xtype,true) diff --git a/Open-ILS/web/js/ui/default/staff/services/lovefield.js b/Open-ILS/web/js/ui/default/staff/services/lovefield.js index 683390aafd..ff281a5cbc 100644 --- a/Open-ILS/web/js/ui/default/staff/services/lovefield.js +++ b/Open-ILS/web/js/ui/default/staff/services/lovefield.js @@ -225,6 +225,27 @@ angular.module('egCoreMod') }); } + service.setOfflineBlockDate = function () { + return service.request({ + schema: 'cache', + table: 'CacheDate', + action: 'insertOrReplace', + rows: [{type: '_blocklistDownload', cachedate : new Date()}] + }); + } + + service.getOfflineBlockDate = function () { + return service.request({ + schema: 'cache', + table: 'CacheDate', + action: 'selectWhereEqual', + field: 'type', + value: '_blocklistDownload' + }).then(function(results) { + return results[0] ? results[0].cachedate : null; + }); + } + // Returns a promise with true for blocked, false for not blocked service.testOfflineBlock = function (barcode) { return service.request({ -- 2.11.0