webstaff: Allow editing of empty volumes
authorMike Rylander <mrylander@gmail.com>
Tue, 6 Oct 2015 17:56:45 +0000 (13:56 -0400)
committerKathy Lussier <klussier@masslnc.org>
Tue, 2 Feb 2016 19:58:48 +0000 (14:58 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js
Open-ILS/web/js/ui/default/staff/cat/services/holdings.js
Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js

index bdcacfc..a933876 100644 (file)
@@ -796,6 +796,18 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         return cp_list;
     }
 
+    function gatherSelectedEmptyVolumeIds () {
+        var cn_id_list = [];
+        angular.forEach(
+            $scope.holdingsGridControls.selectedItems(),
+            function (item) {
+                if (item.copy_count == 0)
+                    cn_id_list.push(item.call_number.id)
+            }
+        );
+        return cn_id_list;
+    }
+
     function gatherSelectedVolumeIds () {
         var cn_id_list = [];
         angular.forEach(
@@ -919,6 +931,9 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
             null, 'edit-these-copies', {
                 record_id: $scope.record_id,
                 copies: gatherSelectedHoldingsIds(),
+                raw: gatherSelectedEmptyVolumeIds().map(
+                    function(v){ return { callnumber : v } }
+                ),
                 hide_vols : hide_vols,
                 hide_copies : hide_copies
             }
index 0bebe6c..a0806c5 100644 (file)
@@ -259,6 +259,7 @@ function(egCore , $q) {
                     svc.copies = svc.copies.concat(flat);
                 } else if (empty) {
                     svc.copies.push({
+                        id_list    : [],
                         owner_id   : owner_id,
                         owner_list : owner_name_list,
                         call_number: egCore.idl.toHash(cn),
index 013b744..d76847f 100644 (file)
@@ -974,11 +974,8 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
 
                 $scope.record_id = data.record_id;
 
-                if (data.copies && data.copies.length)
-                    return itemSvc.fetchIds(data.copies);
-
-                if (data.raw && data.raw.length) {
-                    $scope.dirty = true;
+                function fetchRaw () {
+                    if (!$scope.only_vols) $scope.dirty = true;
                     $scope.add_vols_copies = true;
 
                     /* data.raw data structure looks like this:
@@ -1001,7 +998,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
                                     var cp = new egCore.idl.acp();
                                     cp.call_number( cn );
                                     cp.id( --itemSvc.new_cp_id );
-                                    cp.isnew( true );
+                                    if (!$scope.only_vols) cp.isnew( true );
                                     cp.circ_lib( proto.owner || egCore.auth.user().ws_ou() );
 
                                     cp.deposit(0);
@@ -1059,6 +1056,12 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
 
                     return itemSvc.copies;
                 }
+
+                if (data.copies && data.copies.length)
+                    return itemSvc.fetchIds(data.copies).then(fetchRaw);
+
+                return fetchRaw();
+
             }
 
         }).then( function() {