LP#1676608: copy alert and suppression matrix
[working/Evergreen.git] / Open-ILS / web / js / ui / default / staff / circ / services / item.js
index 44c9aa1..02a58d9 100644 (file)
@@ -16,7 +16,7 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog
         flesh : 3, 
         flesh_fields : {
             acp : ['call_number','location','status','location','floating','circ_modifier',
-                'age_protect','circ_lib'],
+                'age_protect','circ_lib','copy_alerts'],
             acn : ['record','prefix','suffix','label_class'],
             bre : ['simple_record','creator','editor']
         },
@@ -30,7 +30,7 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog
     service.circFlesh = {
         flesh : 2,
         flesh_fields : {
-            circ : [
+            combcirc : [
                 'usr',
                 'workstation',
                 'checkin_workstation',
@@ -41,7 +41,7 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog
             ],
             au : ['card']
         },
-        order_by : {circ : 'xact_start desc'},
+        order_by : {combcirc : 'xact_start desc'},
         limit :  1
     }
 
@@ -152,6 +152,10 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog
                     flatCopy._duration = copyData.circ.duration();
                 }
                 flatCopy.index = service.index++;
+                flatCopy.copy_alert_count = copyData.copy.copy_alerts().filter(function(aca) {
+                    return !aca.ack_time();
+                }).length;
+
                 service.copies.unshift(flatCopy);
             }
 
@@ -579,8 +583,14 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog
     }
 
     service.selectedHoldingsDamaged = function (items) {
-        egCirc.mark_damaged(items.map(function(el){return el.id;})).then(function(){
-            angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
+        angular.forEach(items, function(cp) {
+            if (cp) {
+                egCirc.mark_damaged({
+                    id: cp.id,
+                    barcode: cp.barcode,
+                    refresh: cp.refresh
+                });
+            }
         });
     }
 
@@ -668,26 +678,30 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog
     }
 
     service.spawnHoldingsEdit = function (items,hide_vols,hide_copies){
-        angular.forEach(service.gatherSelectedRecordIds(items), function (r) {
-            egCore.net.request(
-                'open-ils.actor',
-                'open-ils.actor.anon_cache.set_value',
-                null, 'edit-these-copies', {
-                    record_id: r,
-                    copies: service.gatherSelectedHoldingsIds(items,r),
-                    raw: {},
-                    hide_vols : hide_vols,
-                    hide_copies : hide_copies
-                }
-            ).then(function(key) {
-                if (key) {
-                    var url = egCore.env.basePath + 'cat/volcopy/' + key;
-                    $timeout(function() { $window.open(url, '_blank') });
-                } else {
-                    alert('Could not create anonymous cache key!');
-                }
-            });
+        var item_ids = [];
+        angular.forEach(items, function(i){
+           item_ids.push(i.id);
         });
+       
+       egCore.net.request(
+           'open-ils.actor',
+           'open-ils.actor.anon_cache.set_value',
+           null,
+           'edit-these-copies',
+           {
+               record_id: 0,  // disables record summary
+               copies: item_ids,
+               raw: {},
+               hide_vols : hide_vols,
+               hide_copies : hide_copies
+            }).then(function(key) {
+               if (key) {
+                   var url = egCore.env.basePath + 'cat/volcopy/' + key;
+                   $timeout(function() { $window.open(url, '_blank') });
+               } else {
+                   alert('Could not create anonymous cache key!');
+               }
+           });
     }
 
     service.replaceBarcodes = function(items) {