[open-ils-commits] [GIT] Evergreen ILS branch master updated. 549d6a0847f4a7a68db5d41270290c24f16c9aa1

Evergreen Git git at git.evergreen-ils.org
Tue Mar 14 16:53:28 EDT 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  549d6a0847f4a7a68db5d41270290c24f16c9aa1 (commit)
      from  c17e66ae30fb4dcca0a59c3fdbbfba0c4e1b0e76 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 549d6a0847f4a7a68db5d41270290c24f16c9aa1
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Fri Mar 10 13:05:50 2017 -0500

    webstaff: Make Items Bookable and Book Item Now for Holdings View
    
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2
index 4a5181e..c7247c7 100644
--- a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2
+++ b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2
@@ -35,6 +35,11 @@
 
     <eg-grid-action handler="add_copies_to_bucket"
       label="[% l('Add Items to Bucket') %]"></eg-grid-action>
+    <eg-grid-action handler="make_copies_bookable"
+      label="[% l('Make Items Bookable') %]"></eg-grid-action>
+    <eg-grid-action handler="book_copies_now"
+      disabled="need_one_selected"
+      label="[% l('Book Item Now') %]"></eg-grid-action>
     <eg-grid-action handler="requestItems"
       label="[% l('Request Items') %]"></eg-grid-action>
     <eg-grid-action handler="view_place_orders"
diff --git a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js
index 0517970..1f1ac58 100644
--- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js
+++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js
@@ -635,6 +635,140 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         });
     }
 
+    // TODO: refactor common code between cat/catalog/app.js and cat/item/app.js 
+
+    $scope.need_one_selected = function() {
+        var items = $scope.holdingsGridControls.selectedItems();
+        if (items.length == 1) return false;
+        return true;
+    };
+
+    $scope.make_copies_bookable = function() {
+
+        var copies_by_record = {};
+        var record_list = [];
+        angular.forEach(
+            $scope.holdingsGridControls.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_results = [];
+        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['brsrc']) {
+                        combined_results = combined_results.concat(results['brsrc']);
+                    }
+                })
+            );
+        });
+
+        $q.all(promises).then(function() {
+            if (combined_results.length > 0) {
+                $uibModal.open({
+                    template: '<eg-embed-frame url="booking_admin_url" handlers="funcs"></eg-embed-frame>',
+                    animation: true,
+                    size: 'md',
+                    controller:
+                           ['$scope','$location','egCore','$uibModalInstance',
+                    function($scope , $location , egCore , $uibModalInstance) {
+
+                        $scope.funcs = {
+                            ses : egCore.auth.token(),
+                            resultant_brsrc : combined_results.map(function(o) { return o[0]; })
+                        }
+
+                        var booking_path = '/eg/conify/global/booking/resource';
+
+                        $scope.booking_admin_url =
+                            $location.absUrl().replace(/\/eg\/staff.*/, booking_path);
+                    }]
+                });
+            }
+        });
+    }
+
+    $scope.book_copies_now = function() {
+        var copies_by_record = {};
+        var record_list = [];
+        angular.forEach(
+            $scope.holdingsGridControls.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: '<eg-embed-frame url="booking_admin_url" handlers="funcs"></eg-embed-frame>',
+                    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);
+
+                    }]
+                });
+            }
+        });
+    }
+
+
     $scope.requestItems = function() {
         var copy_list = gatherSelectedHoldingsIds();
         if (copy_list.length == 0) return;

-----------------------------------------------------------------------

Summary of changes:
 .../src/templates/staff/cat/catalog/t_holdings.tt2 |    5 +
 .../web/js/ui/default/staff/cat/catalog/app.js     |  134 ++++++++++++++++++++
 2 files changed, 139 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list