LP1752356 Offline block list date addition
authorMike Risher <mrisher@catalyte.io>
Mon, 1 Jul 2019 15:56:17 +0000 (15:56 +0000)
committerBill Erickson <berickxx@gmail.com>
Wed, 3 Jul 2019 18:38:06 +0000 (14:38 -0400)
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 <mrisher@catalyte.io>
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 <berickxx@gmail.com>
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..dae9b17 100644 (file)
@@ -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}}') %]";
 
 }]);
 </script>
index 7d80de6..6198907 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) {
@@ -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)
index e7ec496..6d5269e 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({