From: Mike Risher Date: Thu, 20 Aug 2020 18:05:15 +0000 (+0000) Subject: LP1752356 Offline expired patrons download date additions X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fmrisher%2Flp1752356-offline-block-patron-exp-date-v2;p=working%2FEvergreen.git LP1752356 Offline expired patrons download date additions In offline mode when checking out for an expired patron, change the error message so that the last date the blocklist was downloaded is displayed along with the patron barcode Signed-off-by: Mike Risher This code includes improvements made by Bill Erickson 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 --- diff --git a/Open-ILS/src/templates/staff/offline-interface.tt2 b/Open-ILS/src/templates/staff/offline-interface.tt2 index dc7b56ba9b..317b215eff 100644 --- a/Open-ILS/src/templates/staff/offline-interface.tt2 +++ b/Open-ILS/src/templates/staff/offline-interface.tt2 @@ -621,7 +621,7 @@ angular.module('egCoreMod').run(['egStrings', function(s) { 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: Barcode [_2] was flagged Expired in block list downloaded [_1].', '{{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..85aaa968c7 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) { @@ -301,6 +301,18 @@ function($routeProvider , $locationProvider , $compileProvider) { $scope.in_house_use = {count : 1}; $scope.checkin = { backdate : new Date() }; + egLovefield.getOfflineBlockDate().then( + function(blockListDateResp) { + if (blockListDateResp) { + $scope.blockListDate = + Math.round(blockListDateResp.getTime() / 1000); + } + }, + function() { + console.debug("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 +417,7 @@ function($routeProvider , $locationProvider , $compileProvider) { egProgressDialog.open(); egLovefield.populateBlockList().then( function(){ + egLovefield.setOfflineBlockDate(); ngToast.create(egCore.strings.OFFLINE_BLOCKLIST_SUCCESS); }, function(){ @@ -592,21 +605,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 0e7d2b3804..f304078e59 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({