webstaff: warning sound for empty patron search results
authorJason Etheridge <jason@esilibrary.com>
Thu, 23 Mar 2017 21:03:40 +0000 (17:03 -0400)
committerJason Etheridge <jason@esilibrary.com>
Mon, 27 Mar 2017 20:00:40 +0000 (16:00 -0400)
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/web/js/ui/default/staff/circ/patron/app.js

index 1dc380f..d9a4e9c 100644 (file)
@@ -822,6 +822,9 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
         home_ou : egCore.org.tree()
     };
 
+    // FIXME: kludgy; used to prevent sound effect on page load for empty search
+    var first_run = true;
+
     // last used patron search form element
     var lastFormElement;
 
@@ -981,12 +984,21 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
         ).then(
             function() {
                 // hide progress bar on 0-hits searches
+                if ($scope.show_search_progress && ! first_run) {
+                    egCore.audio.play('warning.patron.by_search');
+                }
+                first_run = false;
                 $scope.show_search_progress = false;
                 deferred.resolve();
             },
-            null, // onerror
+            function() { // onerror
+                egCore.audio.play('error.patron.by_search');
+            },
             function(user) {
                 // hide progress bar as soon as the first result appears.
+                if ($scope.show_search_progress) {
+                    egCore.audio.play('success.patron.by_search');
+                }
                 $scope.show_search_progress = false;
                 patronSvc.localFlesh(user); // inline
                 patronSvc.patrons.push(user);