From 997a30a6973b9161c7336a086534c41810665f50 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 4 Aug 2016 15:22:22 -0400 Subject: [PATCH] LP#1464350 Webstaff home page catalog search 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? E.g. /eg/staff/cat/catalog/results?query=scores&qtype=subject Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- Open-ILS/src/templates/staff/t_splash.tt2 | 13 +++++++++++++ Open-ILS/web/js/ui/default/staff/app.js | 16 ++++++++++++---- Open-ILS/web/js/ui/default/staff/cat/catalog/app.js | 21 +++++++++++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/templates/staff/t_splash.tt2 b/Open-ILS/src/templates/staff/t_splash.tt2 index 1ca0ea2c4c..2f2eb5daac 100644 --- a/Open-ILS/src/templates/staff/t_splash.tt2 +++ b/Open-ILS/src/templates/staff/t_splash.tt2 @@ -35,6 +35,19 @@
[% l('Item Search and Cataloging') %]
+
+
+ +
+
+ +
+
[% l('Record Buckets') %] diff --git a/Open-ILS/web/js/ui/default/staff/app.js b/Open-ILS/web/js/ui/default/staff/app.js index 5c155a90b2..41910b9bec 100644 --- a/Open-ILS/web/js/ui/default/staff/app.js +++ b/Open-ILS/web/js/ui/default/staff/app.js @@ -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); } -]); +}]); diff --git a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js index 729469bab8..2272ae7c98 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js @@ -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; } -- 2.11.0