LP#1464350 Webstaff home page catalog search
authorBill Erickson <berickxx@gmail.com>
Thu, 4 Aug 2016 19:22:22 +0000 (15:22 -0400)
committerMike Rylander <mrylander@gmail.com>
Wed, 17 Aug 2016 20:04:00 +0000 (16:04 -0400)
Search the catalog directly from the home/splash page in the browser
client.

A side effect of this commit is that it's now possible to jump directly
to a set of search results in the embedded catalog by going to:

/eg/staff/cat/catalog/results?<query-params>

E.g.

/eg/staff/cat/catalog/results?query=scores&qtype=subject

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates/staff/t_splash.tt2
Open-ILS/web/js/ui/default/staff/app.js
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

index 1ca0ea2..2f2eb5d 100644 (file)
           <div class="panel-title text-center">[% l('Item Search and Cataloging') %]</div>
         </div>
         <div class="panel-body">
+          <div class="row">
+            <div class="col-md-8">
+                <input focus-me="focus_search" 
+                    class="form-control" ng-model="cat_query" type="text" 
+                    ng-keypress="catalog_search($event)"
+                    placeholder="[% l('Search catalog for...') %]"/>
+            </div>
+            <div class="col-md-4">
+                <button class='btn btn-default' ng-click="catalog_search()">
+                    [% l('Search') %]
+                </button>
+            </div>
+          </div>
           <div>
             <img src="/xul/server/skin/media/images/portal/bucket.png"/>
             <a target="_self" href="./cat/bucket/record/">[% l('Record Buckets') %]</a>
index 5c155a9..41910b9 100644 (file)
@@ -117,9 +117,17 @@ function($routeProvider , $locationProvider) {
 /**
  * Splash page dynamic content.
  */
-.controller('SplashCtrl', ['$scope',
-    function($scope) {
-        console.log('SplashCtrl');
+.controller('SplashCtrl', ['$scope', '$window', function($scope, $window) {
+    console.log('SplashCtrl');
+    $scope.focus_search = true;
+
+    $scope.catalog_search = function($event) {
+        $scope.focus_search = true;
+        if (!$scope.cat_query) return;
+        if ($event && $event.keyCode != 13) return; // input ng-keypress
+        $window.location.href = 
+            '/eg/staff/cat/catalog/results?query=' + 
+            encodeURIComponent($scope.cat_query);
     }
-]);
+}]);
 
index 729469b..2272ae7 100644 (file)
@@ -40,6 +40,14 @@ angular.module('egCatalogApp', ['ui.bootstrap','ngRoute','ngLocationUpdate','egC
         resolve : resolver
     });
 
+    // Jump directly to the results page.  Any URL parameter 
+    // supported by the embedded catalog is supported here.
+    $routeProvider.when('/cat/catalog/results', {
+        templateUrl: './cat/catalog/t_catalog',
+        controller: 'CatalogCtrl',
+        resolve : resolver
+    });
+
     $routeProvider.when('/cat/catalog/retrieve_by_id', {
         templateUrl: './cat/catalog/t_retrieve_by_id',
         controller: 'CatalogRecordRetrieve',
@@ -1419,6 +1427,19 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
             url = url.replace(/advanced/, '/record/' + $scope.record_id);
         }
 
+        // Jumping directly to the results page by passing a search
+        // query via the URL.  Copy all URL params to the iframe url.
+        if ($location.path().match(/catalog\/results/)) {
+            url = url.replace(/advanced/, '/results?');
+            var first = true;
+            angular.forEach($location.search(), function(val, key) {
+                if (!first) url += '&';
+                first = false;
+                url += encodeURIComponent(key) 
+                    + '=' + encodeURIComponent(val);
+            });
+        }
+
         $scope.catalog_url = url;
     }