From ce436afdfce553baa4ae60405a3dcec8e73da203 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 13 Feb 2017 11:49:58 -0500 Subject: [PATCH] webstaff: Book Items Now from Item Status FIXME We can't do what we did with Make Items Bookable, consolidating the items into one call and invoking a single interface; we get "Can't book multiple resource types at once". Easiest solution may be to disable the menu entry if multiple items are selected. Alternately, we could open the first resource in the modal UI and open new tabs for the extras, but then we're stuck using query params instead of xulG Signed-off-by: Jason Etheridge --- Open-ILS/web/js/ui/default/staff/cat/item/app.js | 69 ++++++++++++++++++++++++ 1 file changed, 69 insertions(+) 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 8958081051..1476dd5cf8 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 @@ -393,6 +393,75 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore , }); } + $scope.book_copies_now = function() { + var copies_by_record = {}; + var record_list = []; + angular.forEach( + copyGrid.selectedItems(), + function (item) { + var record_id = item['call_number.record.id']; + if (typeof copies_by_record[ record_id ] == 'undefined') { + copies_by_record[ record_id ] = []; + record_list.push( record_id ); + } + copies_by_record[ record_id ].push(item.id); + } + ); + + var promises = []; + var combined_brt = []; + var combined_brsrc = []; + angular.forEach(record_list, function(record_id) { + promises.push( + egCore.net.request( + 'open-ils.booking', + 'open-ils.booking.resources.create_from_copies', + egCore.auth.token(), + copies_by_record[record_id] + ).then(function(results) { + if (results && results['brt']) { + combined_brt = combined_brt.concat(results['brt']); + } + if (results && results['brsrc']) { + combined_brsrc = combined_brsrc.concat(results['brsrc']); + } + }) + ); + }); + + $q.all(promises).then(function() { + if (combined_brt.length > 0 || combined_brsrc.length > 0) { + $uibModal.open({ + template: '', + animation: true, + size: 'md', + controller: + ['$scope','$location','egCore','$uibModalInstance', + function($scope , $location , egCore , $uibModalInstance) { + + $scope.funcs = { + ses : egCore.auth.token(), + bresv_interface_opts : { + booking_results : { + brt : combined_brt + ,brsrc : combined_brsrc + } + } + } + + var booking_path = '/eg/booking/reservation'; + + $scope.booking_admin_url = + $location.absUrl().replace(/\/eg\/staff.*/, booking_path); + + console.log('Loading Admin Booking URL: ' + $scope.booking_admin_url); + console.log('funcs = ',$scope.funcs); + + }] + }); + } + }); + } $scope.requestItems = function() { var copy_list = gatherSelectedHoldingsIds(); -- 2.11.0