webstaff: sound effects for patron search
authorJason Etheridge <jason@esilibrary.com>
Mon, 17 Apr 2017 19:43:43 +0000 (15:43 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 17 Apr 2017 20:00:31 +0000 (16:00 -0400)
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/web/js/ui/default/staff/circ/patron/app.js

index 8a8e326..7f0e0d8 100644 (file)
@@ -989,6 +989,7 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
         egProgressDialog.open(); // Indeterminate
 
         patronSvc.patrons = [];
+        var which_sound = 'success';
         egCore.net.request(
             'open-ils.actor',
             'open-ils.actor.patron.search.advanced.fleshed',
@@ -1005,7 +1006,9 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
             function() {
                 deferred.resolve();
             },
-            null, // onerror
+            function() { // onerror
+                which_sound = 'error';
+            },
             function(user) {
                 // hide progress bar as soon as the first result appears.
                 egProgressDialog.close();
@@ -1013,7 +1016,13 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
                 patronSvc.patrons.push(user);
                 deferred.notify(user);
             }
-        )['finally'](egProgressDialog.close); // close on 0-hits or error
+        )['finally'](function() { // close on 0-hits or error
+            if (which_sound == 'success' && patronSvc.patrons.length == 0) {
+                which_sound = 'warning';
+            }
+            egCore.audio.play(which_sound + '.patron.by_search');
+            egProgressDialog.close();
+        });
 
         return deferred.promise;
     };