LP#1522638 Patron search uses progress modal user/berick/lp1522638-progress-bar-holds-etc
authorBill Erickson <berickxx@gmail.com>
Fri, 24 Feb 2017 17:12:21 +0000 (12:12 -0500)
committerBill Erickson <berickxx@gmail.com>
Fri, 3 Mar 2017 15:45:48 +0000 (10:45 -0500)
Use the progress modal dialog in the web staff patron search UI for
consistency / code re-use.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Open-ILS/src/templates/staff/circ/patron/t_search_results.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/app.js

index a5a58af..cec4dd7 100644 (file)
@@ -1,19 +1,6 @@
 
-<!-- patron search progress bar -->
-<div class="row" ng-show="show_search_progress">
-  <div class="col-md-6">
-    <div class="progress progress-striped active">
-      <div class="progress-bar" role="progressbar" aria-valuenow="100"
-        aria-valuemin="0" aria-valuemax="100" style="width: 100%">
-        <span class="sr-only">[% l('Loading...') %]</span>
-      </div>
-    </div>
-  </div>
-</div>
-
 <!-- patron search results grid -->
 <eg-grid
-  ng-hide="show_search_progress"
   idl-class="au" id-field="id"
   features="-sort,-display,-multisort"
   main-label="[% l('Patron Search Results') %]"
index e075c4f..7108875 100644 (file)
@@ -816,10 +816,10 @@ function($scope , $location , egCore , egConfirmDialog , egUser , patronSvc) {
 .controller('PatronSearchCtrl',
        ['$scope','$q','$routeParams','$timeout','$window','$location','egCore',
        '$filter','egUser', 'patronSvc','egGridDataProvider','$document',
-       'egPatronMerge',
+       'egPatronMerge','egProgressDialog',
 function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
         $filter,  egUser,  patronSvc , egGridDataProvider , $document,
-        egPatronMerge) {
+        egPatronMerge , egProgressDialog) {
 
     $scope.initTab('search');
     $scope.focusMe = true;
@@ -968,8 +968,13 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
             return deferred.promise;
         }
 
-        // Dispay the search progress bar to indicate a search is in progress
-        $scope.show_search_progress = true;
+        if (!Object.keys(fullSearch.search).length) {
+            // Empty searches are rejected by the server.  Avoid 
+            // running the the empty search that runs on page load. 
+            return $q.when();
+        }
+
+        egProgressDialog.open(); // Indeterminate
 
         patronSvc.patrons = [];
         egCore.net.request(
@@ -986,19 +991,17 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
 
         ).then(
             function() {
-                // hide progress bar on 0-hits searches
-                $scope.show_search_progress = false;
                 deferred.resolve();
             },
             null, // onerror
             function(user) {
                 // hide progress bar as soon as the first result appears.
-                $scope.show_search_progress = false;
+                egProgressDialog.close();
                 patronSvc.localFlesh(user); // inline
                 patronSvc.patrons.push(user);
                 deferred.notify(user);
             }
-        );
+        )['finally'](egProgressDialog.close); // close on 0-hits or error
 
         return deferred.promise;
     };