lp1760193 Add to Record Bucket from Item Status
authorKyle Huckins <khuckins@catalyte.io>
Tue, 28 Jan 2020 18:27:36 +0000 (18:27 +0000)
committerChris Sharp <csharp@georgialibraries.org>
Fri, 21 Feb 2020 18:30:01 +0000 (13:30 -0500)
- Add "Add Items to Record Bucket" option in Item Status
UI
- Refactor Add Copy to Bucket functionality to support
adding to Copy Buckets or to Record Buckets depending
on optional bucket_type parameter

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>

 Changes to be committed:
modified:   Open-ILS/src/templates/staff/cat/item/index.tt2
modified:   Open-ILS/src/templates/staff/cat/item/t_list.tt2
modified:   Open-ILS/web/js/ui/default/staff/cat/item/app.js
modified:   Open-ILS/web/js/ui/default/staff/circ/services/item.js

Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>

Open-ILS/src/templates/staff/cat/item/index.tt2
Open-ILS/src/templates/staff/cat/item/t_list.tt2
Open-ILS/web/js/ui/default/staff/cat/item/app.js
Open-ILS/web/js/ui/default/staff/circ/services/item.js

index 9cb8be8..7444838 100644 (file)
@@ -90,6 +90,7 @@
       </button>
       <ul uib-dropdown-menu class="scrollable-menu dropdown-menu-right">
         <li><a href ng-click="add_copies_to_bucket()">[% l('Add Items to Bucket') %]</a></li>
+        <li><a href ng-click="add_records_to_bucket()">[% l('Add Items to Record Bucket') %]</a></li>
         <li><a href ng-click="show_in_catalog()">[% l('Show in Catalog') %]</a></li>
         <li><a href ng-click="make_copies_bookable()">[% l('Make Items Bookable') %]</a></li>
         <li><a href ng-click="book_copies_now()">[% l('Book Item Now') %]</a></li>
index 3747835..64e88a7 100644 (file)
@@ -12,6 +12,8 @@
 
   <eg-grid-action handler="add_copies_to_bucket"
     label="[% l('Add Items to Bucket') %]"></eg-grid-action>
+  <eg-grid-action handler="add_records_to_bucket"
+    label="[% l('Add Item Records to Bucket') %]"></eg-grid-action>
   <eg-grid-action handler="show_in_catalog"
     label="[% l('Show in Catalog') %]"></eg-grid-action>
   <eg-grid-action handler="make_copies_bookable"
index 52d2d02..614db62 100644 (file)
@@ -86,6 +86,10 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD
         itemSvc.add_copies_to_bucket([$scope.args.copyId]);
     }
 
+    $scope.add_records_to_bucket = function() {
+        itemSvc.add_records_to_bucket([$scope.args.recordId], 'biblio');
+    }
+
     $scope.show_in_catalog = function() {
         window.open('/eg/staff/cat/catalog/record/' + $scope.args.recordId + '/catalog', '_blank');
     }
@@ -469,6 +473,17 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD
         return cp_id_list;
     }
 
+    function gatherSelectedHoldingsRecords() {
+        var record_id_list = [];
+        angular.forEach(
+            copyGrid.selectedItems(),
+            function (item) {
+                record_id_list.push(item['call_number.record.id']);
+            }
+        )
+        return record_id_list;
+    }
+
     $scope.refreshGridData = function() {
         var chain = $q.when();
         var all_items = itemSvc.copies.map(function(item) {
@@ -491,6 +506,11 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD
         itemSvc.add_copies_to_bucket(copy_list);
     }
 
+    $scope.add_records_to_bucket = function() {
+        var record_list = gatherSelectedHoldingsRecords();
+        itemSvc.add_copies_to_bucket(record_list, 'biblio');
+    }
+
     $scope.locateAcquisition = function() {
         if (gatherSelectedHoldingsIds) {
             var cp_list = gatherSelectedHoldingsIds();
index d07c598..c06b252 100644 (file)
@@ -224,8 +224,9 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast
         });
     }
 
-    service.add_copies_to_bucket = function(copy_list) {
-        if (copy_list.length == 0) return;
+    service.add_copies_to_bucket = function(list, bucket_type) {
+        if (list.length == 0) return;
+        if (!bucket_type) bucket_type = 'copy';
 
         return $uibModal.open({
             templateUrl: './cat/catalog/t_add_to_bucket',
@@ -244,20 +245,21 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast
                     'open-ils.actor',
                     'open-ils.actor.container.retrieve_by_class.authoritative',
                     egCore.auth.token(), egCore.auth.user().id(),
-                    'copy', 'staff_client'
+                    bucket_type, 'staff_client'
                 ).then(function(buckets) { $scope.allBuckets = buckets; });
 
                 $scope.add_to_bucket = function() {
                     var promises = [];
-                    angular.forEach(copy_list, function (cp) {
-                        var item = new egCore.idl.ccbi()
+                    angular.forEach(list, function (entry) {
+                        var item = bucket_type == 'copy' ? new egCore.idl.ccbi() : new egCore.idl.cbrebi();
                         item.bucket($scope.bucket_id);
-                        item.target_copy(cp);
+                        if (bucket_type == 'copy') item.target_copy(entry);
+                        if (bucket_type == 'biblio') item.target_biblio_record_entry(entry);
                         promises.push(
                             egCore.net.request(
                                 'open-ils.actor',
                                 'open-ils.actor.container.item.create',
-                                egCore.auth.token(), 'copy', item
+                                egCore.auth.token(), bucket_type, item
                             )
                         );
 
@@ -268,7 +270,7 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast
                 }
 
                 $scope.add_to_new_bucket = function() {
-                    var bucket = new egCore.idl.ccb();
+                    var bucket = bucket_type == 'copy' ? new egCore.idl.ccb() : new egCore.idl.cbreb();
                     bucket.owner(egCore.auth.user().id());
                     bucket.name($scope.newBucketName);
                     bucket.description('');
@@ -277,7 +279,7 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast
                     return egCore.net.request(
                         'open-ils.actor',
                         'open-ils.actor.container.create',
-                        egCore.auth.token(), 'copy', bucket
+                        egCore.auth.token(), bucket_type, bucket
                     ).then(function(bucket) {
                         $scope.bucket_id = bucket;
                         $scope.add_to_bucket();