[open-ils-commits] [GIT] Evergreen ILS branch master updated. 1e111dede283983bed2f031cb9ed86db0d2e100e

Evergreen Git git at git.evergreen-ils.org
Sun Dec 17 14:10:00 EST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  1e111dede283983bed2f031cb9ed86db0d2e100e (commit)
      from  9a7e27bbe1cef474f6ac1d9d51b87a05faa81fce (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1e111dede283983bed2f031cb9ed86db0d2e100e
Author: Cesar Velez <Cesar.Velez at equinoxinitiative.org>
Date:   Thu Sep 21 15:45:23 2017 +0100

    LP#1378383-WebStaff Fix Item circ history to obey max setting
    
    The circ.item_checkout_history.max lib setting should be respected
    in both Circ History tabs, and also check for the permission to
    VIEW_COPY_CHECKOUT_HISTORY for the current user.
    
    Also, There was ambiguity for the user to tell the difference
    (from the displayed message) if an item truly has no circulations,
    or if they see no circs due to the relevant permission setting
    being set to 0 (Maximum previous checkouts.) This changes the templates
    a bit to make that clearer.
    
    Signed-off by: Cesar Velez <cesar.velez at equinoxinitiative.org>
    
    Signed-off-by: Jason Etheridge <jason at EquinoxInitiative.org>

diff --git a/Open-ILS/src/templates/staff/cat/item/t_circ_list_pane.tt2 b/Open-ILS/src/templates/staff/cat/item/t_circ_list_pane.tt2
index 422830f..f4a3d0f 100644
--- a/Open-ILS/src/templates/staff/cat/item/t_circ_list_pane.tt2
+++ b/Open-ILS/src/templates/staff/cat/item/t_circ_list_pane.tt2
@@ -1,9 +1,14 @@
-<div class="col-md-12" ng-show="!circ_list.length">
+<div class="col-md-12" ng-show="!isMaxCircHistoryZero && circ_list.length == 0">
   <div class="alert alert-info">
     [% l('Item has not circulated.') %]
   </div>
 </div>
-<div class="row" ng-show="circ_list.length">
+<div class="col-md-12" ng-show="isMaxCircHistoryZero">
+  <div class="alert alert-info">
+    [% l('Circulation History not available for display.') %]
+  </div>
+</div>
+<div class="row" ng-show="!isMaxCircHistoryZero && circ_list.length">
   <div class="flex-row">
       <div class="flex-cell well">
           <button class="btn btn-default" ng-click="retrieveAllPatrons()">
@@ -14,7 +19,7 @@
 </div>
 
 
-<div class="row" ng-repeat="circ in circ_list">
+<div class="row" ng-show="!isMaxCircHistoryZero" ng-repeat="circ in circ_list">
   <div class="flex-row">
     <div class="flex-cell well">
       <a ng-if="circ.usr()" target="_self"
diff --git a/Open-ILS/src/templates/staff/cat/item/t_circs_pane.tt2 b/Open-ILS/src/templates/staff/cat/item/t_circs_pane.tt2
index be36803..200c59b 100644
--- a/Open-ILS/src/templates/staff/cat/item/t_circs_pane.tt2
+++ b/Open-ILS/src/templates/staff/cat/item/t_circs_pane.tt2
@@ -94,12 +94,17 @@
   </div>
 </div>
 
-<div class="col-md-6" ng-show="!circ">
+<div class="col-md-6" ng-show="!isMaxCircHistoryZero && !circ">
   <div class="alert alert-info">
     [% l('No Recent Circ Group') %]
   </div>
 </div>
-<div class="col-md-6" ng-show="circ">
+<div class="col-md-6" ng-show="isMaxCircHistoryZero">
+  <div class="alert alert-info">
+    [% l('Most Recent Circ Group not available for display.') %]
+  </div>
+</div>
+<div class="col-md-6" ng-show="!isMaxCircHistoryZero && circ">
   <div class="flex-row">
     <div class="flex-cell flex-2 strong-text-2">
       [% l('Most Recent Circ Group') %]
diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/app.js
index d1e8b5e..8b8f9ef 100644
--- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js
+++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js
@@ -625,63 +625,85 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
         return deferred.promise;
     }
 
-    // if loadPrev load the two most recent circulations
-    function loadCurrentCirc(loadPrev) {
+    // load the two most recent circulations in /circs tab
+    function loadCurrentCirc() {
         delete $scope.circ;
         delete $scope.circ_summary;
         delete $scope.prev_circ_summary;
         delete $scope.prev_circ_usr;
         if (!copyId) return;
         
-        egCore.pcrud.search('aacs', 
-            {target_copy : copyId},
-            {   flesh : 2,
-                flesh_fields : {
-                    aacs : [
-                        'usr',
-                        'workstation',                                         
-                        'checkin_workstation',                                 
-                        'duration_rule',                                       
-                        'max_fine_rule',                                       
-                        'recurring_fine_rule'   
-                    ],
-                    au : ['card']
-                },
-                order_by : {aacs : 'xact_start desc'}, 
-                limit :  1
+        var copy_org =
+            itemSvc.copy.call_number().id() == -1 ?
+            itemSvc.copy.circ_lib().id() :
+            itemSvc.copy.call_number().owning_lib().id();
+
+        // since a user can still view patron checkout history here, check perms
+        egCore.perm.hasPermAt('VIEW_COPY_CHECKOUT_HISTORY', true)
+        .then(function(orgIds){
+            if(orgIds.indexOf(copy_org) == -1){
+                console.warn('User is not allowed to view circ history!');
+                $q.when(0);
             }
 
-        ).then(null, null, function(circ) {
-            $scope.circ = circ;
+            return fetchMaxCircHistory();
+        })
+        .then(function(maxHistCount){
 
-            // load the chain for this circ
-            egCore.net.request(
-                'open-ils.circ',
-                'open-ils.circ.renewal_chain.retrieve_by_circ.summary',
-                egCore.auth.token(), $scope.circ.id()
-            ).then(function(summary) {
-                $scope.circ_summary = summary;
-            });
+            if (!maxHistCount) $scope.isMaxCircHistoryZero = true;
+
+            egCore.pcrud.search('aacs',
+                {target_copy : copyId},
+                {   flesh : 2,
+                    flesh_fields : {
+                        aacs : [
+                            'usr',
+                            'workstation',
+                            'checkin_workstation',
+                            'duration_rule',
+                            'max_fine_rule',
+                            'recurring_fine_rule'
+                        ],
+                        au : ['card']
+                    },
+                    order_by : {aacs : 'xact_start desc'},
+                    limit :  1
+                }
 
-            if (!loadPrev) return;
+            ).then(null, null, function(circ) {
+                $scope.circ = circ;
 
-            // load the chain for the previous circ, plus the user
-            egCore.net.request(
-                'open-ils.circ',
-                'open-ils.circ.prev_renewal_chain.retrieve_by_circ.summary',
-                egCore.auth.token(), $scope.circ.id()
+                if (!circ) return $q.when();
 
-            ).then(null, null, function(summary) {
-                $scope.prev_circ_summary = summary.summary;
+                // load the chain for this circ
+                egCore.net.request(
+                    'open-ils.circ',
+                    'open-ils.circ.renewal_chain.retrieve_by_circ.summary',
+                    egCore.auth.token(), $scope.circ.id()
+                ).then(function(summary) {
+                    $scope.circ_summary = summary;
+                });
 
-                if (summary.usr) { // aged circs have no 'usr'.
-                    egCore.pcrud.retrieve('au', summary.usr,
-                        {flesh : 1, flesh_fields : {au : ['card']}})
+                if (maxHistCount <= 1) return;
 
-                    .then(function(user) { $scope.prev_circ_usr = user });
-                }
+                // load the chain for the previous circ, plus the user
+                egCore.net.request(
+                    'open-ils.circ',
+                    'open-ils.circ.prev_renewal_chain.retrieve_by_circ.summary',
+                    egCore.auth.token(), $scope.circ.id()
+
+                ).then(null, null, function(summary) {
+                    $scope.prev_circ_summary = summary.summary;
+
+                    if (summary.usr) { // aged circs have no 'usr'.
+                        egCore.pcrud.retrieve('au', summary.usr,
+                            {flesh : 1, flesh_fields : {au : ['card']}})
+
+                        .then(function(user) { $scope.prev_circ_usr = user });
+                    }
+                });
             });
-        });
+        })
     }
 
     var maxHistory;
@@ -691,7 +713,7 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
             'circ.item_checkout_history.max')
         .then(function(set) {
             maxHistory = set['circ.item_checkout_history.max'] || 4;
-            return maxHistory;
+            return Number(maxHistory);
         });
     }
 
@@ -718,13 +740,14 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
         });
     }
 
+    // load data for /circ_list tab
     function loadCircHistory() {
         $scope.circ_list = [];
 
         var copy_org = 
             itemSvc.copy.call_number().id() == -1 ?
             itemSvc.copy.circ_lib().id() :
-            itemSvc.copy.call_number().owning_lib().id()
+            itemSvc.copy.call_number().owning_lib().id();
 
         // there is an extra layer of permissibility over circ
         // history views
@@ -738,26 +761,31 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
 
             return fetchMaxCircHistory();
 
-        }).then(function(count) {
+        }).then(function(maxHistCount) {
+
+            if(!maxHistCount) $scope.isMaxCircHistoryZero = true;
 
-            egCore.pcrud.search('aacs', 
+            egCore.pcrud.search('aacs',
                 {target_copy : copyId},
                 {   flesh : 2,
                     flesh_fields : {
                         aacs : [
                             'usr',
-                            'workstation',                                         
-                            'checkin_workstation',                                 
-                            'recurring_fine_rule'   
+                            'workstation',
+                            'checkin_workstation',
+                            'recurring_fine_rule'
                         ],
                         au : ['card']
                     },
-                    order_by : {aacs : 'xact_start desc'}, 
-                    limit :  count
+                    order_by : {aacs : 'xact_start desc'},
+                    // fetch at least one to see if copy ever circulated
+                    limit : $scope.isMaxCircHistoryZero ? 1 : maxHistCount
                 }
 
             ).then(null, null, function(circ) {
 
+                $scope.circ = circ;
+
                 // flesh circ_lib locally
                 circ.circ_lib(egCore.org.get(circ.circ_lib()));
                 circ.checkin_lib(egCore.org.get(circ.checkin_lib()));
@@ -855,7 +883,7 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
                 break;
 
             case 'circs':
-                loadCurrentCirc(true);
+                loadCurrentCirc();
                 break;
 
             case 'circ_list':

-----------------------------------------------------------------------

Summary of changes:
 .../templates/staff/cat/item/t_circ_list_pane.tt2  |   11 ++-
 .../src/templates/staff/cat/item/t_circs_pane.tt2  |    9 +-
 Open-ILS/web/js/ui/default/staff/cat/item/app.js   |  132 ++++++++++++--------
 3 files changed, 95 insertions(+), 57 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list