LP1752356 Offline expired patrons download date additions user/mrisher/lp1752356-offline-block-patron-exp-date-v2
authorMike Risher <mrisher@catalyte.io>
Thu, 20 Aug 2020 18:05:15 +0000 (18:05 +0000)
committerMike Risher <mrisher@catalyte.io>
Thu, 20 Aug 2020 18:05:15 +0000 (18:05 +0000)
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 <mrisher@catalyte.io>
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

Open-ILS/src/templates/staff/offline-interface.tt2
Open-ILS/web/js/ui/default/staff/offline.js
Open-ILS/web/js/ui/default/staff/services/lovefield.js

index dc7b56b..317b215 100644 (file)
@@ -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}}') %]";
 
 }]);
 </script>
index 21e10b0..85aaa96 100644 (file)
@@ -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)
index 0e7d2b3..f304078 100644 (file)
@@ -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({