webstaff: Simplify logic of grouped items; Add mark missing/damaged; Add show item...
authorMike Rylander <mrylander@gmail.com>
Wed, 24 Jun 2015 13:39:46 +0000 (09:39 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Wed, 19 Aug 2015 17:39:18 +0000 (13:39 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

index ae7b2b8..1d9dfd8 100644 (file)
       label="[% l('Item Status (detail)') %]"></eg-grid-action>
     <eg-grid-action handler="selectedHoldingsItemStatusTgrEvt" group="[% l('Show') %]"
       label="[% l('Triggered Events') %]"></eg-grid-action>
+    <eg-grid-action handler="selectedHoldingsItemStatusHolds" group="[% l('Show') %]"
+      label="[% l('Item Holds') %]"></eg-grid-action>
+    <eg-grid-action handler="selectedHoldingsDamaged" group="[% l('Mark') %]"
+      label="[% l('Item as Damaged') %]"></eg-grid-action>
+    <eg-grid-action handler="selectedHoldingsMissing" group="[% l('Mark') %]"
+      label="[% l('Item as Missing') %]"></eg-grid-action>
 
     <eg-grid-field label="[% l('Owning Library') %]"  path="owner_label" flex="4" align="right" visible></eg-grid-field>
     <eg-grid-field label="[% l('Call Number') %]"     path="call_number.label" visible></eg-grid-field>
index 8f0ee40..708cc56 100644 (file)
@@ -147,9 +147,9 @@ function($scope , $routeParams , $location , $q , egCore ) {
 }])
 
 .controller('CatalogCtrl',
-       ['$scope','$routeParams','$location','$window','$q','egCore','egHolds',
+       ['$scope','$routeParams','$location','$window','$q','egCore','egHolds','egCirc',
         'egGridDataProvider','egHoldGridActions','$timeout','holdingsSvc',
-function($scope , $routeParams , $location , $window , $q , egCore , egHolds, 
+function($scope , $routeParams , $location , $window , $q , egCore , egHolds , egCirc
          egGridDataProvider , egHoldGridActions , $timeout , holdingsSvc) {
 
     // set record ID on page load if available...
@@ -313,50 +313,81 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds,
         $scope[item.checkbox + '_changed'](item.checked);
     }
 
-    $scope.selectedHoldingsItemStatus = function (){
+    function gatherSelectedHoldingsIds () {
         var cp_id_list = [];
         angular.forEach(
             $scope.holdingsGridControls.selectedItems(),
             function (item) { cp_id_list = cp_id_list.concat(item.id_list) }
         );
-        var url = egCore.env.basePath + 'cat/item/search/' + cp_id_list.join(',')
+        return cp_id_list;
+    }
+
+    $scope.selectedHoldingsItemStatus = function (){
+        var url = egCore.env.basePath + 'cat/item/search/' + gatherSelectedHoldingsIds().join(',')
         $timeout(function() { $window.open(url, '_blank') });
     }
 
     $scope.selectedHoldingsItemStatusDetail = function (){
-        var cp_id_list = [];
         angular.forEach(
-            $scope.holdingsGridControls.selectedItems(),
-            function (item) {
-                angular.forEach(
-                    item.id_list,
-                    function (cid) {
-                        var url = egCore.env.basePath +
-                                  'cat/item/' + cid;
-                        $timeout(function() { $window.open(url, '_blank') });
-                    }
-                )
+            gatherSelectedHoldingsIds(),
+            function (cid) {
+                var url = egCore.env.basePath +
+                          'cat/item/' + cid;
+                $timeout(function() { $window.open(url, '_blank') });
             }
         );
     }
 
     $scope.selectedHoldingsItemStatusTgrEvt = function (){
-        var cp_id_list = [];
         angular.forEach(
-            $scope.holdingsGridControls.selectedItems(),
-            function (item) {
-                angular.forEach(
-                    item.id_list,
-                    function (cid) {
-                        var url = egCore.env.basePath +
-                                  'cat/item/' + cid + '/triggered_events';
-                        $timeout(function() { $window.open(url, '_blank') });
-                    }
-                )
+            gatherSelectedHoldingsIds(),
+            function (cid) {
+                var url = egCore.env.basePath +
+                          'cat/item/' + cid + '/triggered_events';
+                $timeout(function() { $window.open(url, '_blank') });
             }
         );
     }
 
+    $scope.selectedHoldingsItemStatusHolds = function (){
+        angular.forEach(
+            gatherSelectedHoldingsIds(),
+            function (cid) {
+                var url = egCore.env.basePath +
+                          'cat/item/' + cid + '/holds';
+                $timeout(function() { $window.open(url, '_blank') });
+            }
+        );
+    }
+
+    $scope.selectedHoldingsDamaged = function () {
+        egCirc.mark_damaged(gatherSelectedHoldingsIds()).then(function() {
+            holdingsSvc.fetch({
+                rid : $scope.record_id,
+                org : $scope.holdings_ou,
+                copy: $scope.holdings_show_copies,
+                vol : $scope.holdings_show_vols,
+                empty: $scope.holdings_show_empty
+            }).then(function() {
+                $scope.holdingsGridDataProvider.refresh();
+            });
+        });
+    }
+
+    $scope.selectedHoldingsMissing = function () {
+        egCirc.mark_missing(gatherSelectedHoldingsIds()).then(function() {
+            holdingsSvc.fetch({
+                rid : $scope.record_id,
+                org : $scope.holdings_ou,
+                copy: $scope.holdings_show_copies,
+                vol : $scope.holdings_show_vols,
+                empty: $scope.holdings_show_empty
+            }).then(function() {
+                $scope.holdingsGridDataProvider.refresh();
+            });
+        });
+    }
+
 
     // ------------------------------------------------------------------
     // Holds