LP#1701001: add search-to-hold to catalog app
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 28 Jul 2017 20:55:22 +0000 (16:55 -0400)
committerJason Etheridge <jason@EquinoxInitiative.org>
Mon, 14 Aug 2017 19:58:15 +0000 (15:58 -0400)
This patch teaches the web staff client's catalog app how
to activate the patron search button in the embedded catalog's
place hold form. It also adds a handler for the button action
to display a modal to allow the staff member to search
for and select a patron, then injects the patron's barcode
into the form.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Jason Etheridge <jason@EquinoxInitiative.org>
Open-ILS/src/templates/staff/cat/catalog/index.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

index c2df10e..b98c3f1 100644 (file)
@@ -8,6 +8,7 @@
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/marcrecord.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/grid.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/eframe.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/patron_search.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/services/record.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/services/tagtable.js"></script>
 [% INCLUDE 'staff/cat/share/marcedit_strings.tt2' %]
index d73224a..8b541f5 100644 (file)
@@ -7,7 +7,7 @@
  *
  */
 
-angular.module('egCatalogApp', ['ui.bootstrap','ngRoute','ngLocationUpdate','egCoreMod','egGridMod', 'egMarcMod', 'egUserMod', 'egHoldingsMod', 'ngToast'])
+angular.module('egCatalogApp', ['ui.bootstrap','ngRoute','ngLocationUpdate','egCoreMod','egGridMod', 'egMarcMod', 'egUserMod', 'egHoldingsMod', 'ngToast','egPatronSearchMod'])
 
 .config(['ngToastProvider', function(ngToastProvider) {
   ngToastProvider.configure({
@@ -426,6 +426,36 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         return record_id;
     }
 
+    patron_search_dialog = function() {
+        return $uibModal.open({
+            templateUrl: './share/t_patron_selector',
+            size: 'lg',
+            animation: true,
+            controller:
+                   ['$scope','$uibModalInstance','$controller',
+            function($scope , $uibModalInstance , $controller) {
+                angular.extend(this, $controller('BasePatronSearchCtrl', {$scope : $scope}));
+                $scope.clearForm();
+                $scope.need_one_selected = function() {
+                    var items = $scope.gridControls.selectedItems();
+                    return (items.length == 1) ? false : true
+                }
+                $scope.ok = function() {
+                    var items = $scope.gridControls.selectedItems();
+                    if (items.length == 1) {
+                        $uibModalInstance.close(items[0].card().barcode());
+                    } else {
+                        $uibModalInstance.close()
+                    }
+                }
+                $scope.cancel = function($event) {
+                    $uibModalInstance.dismiss();
+                    $event.preventDefault();
+                }
+            }]
+        });
+    }
+
     // also set it when the iframe changes to a new record
     $scope.handle_page = function(url) {
 
@@ -464,6 +494,18 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         } else {
             $scope.in_opac_call = false;
         }
+
+        if ($scope.opac_iframe && $location.path().match(/cat\/catalog/)) {
+            var doc = $scope.opac_iframe.dom.contentWindow.document;
+            $(doc).find('#hold_usr_search').show();
+            $(doc).find('#hold_usr_search').on('click', function() {
+                patron_search_dialog().result.then(function(barc) {
+                    $(doc).find('#hold_usr_input').val(barc);
+                    $(doc).find('#hold_usr_input').change();
+                });
+            })
+        }
+
     }
 
     // xulG catalog handlers