From 2ccc67ff691150b5d3137246dda97510e5d3e333 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 15 Jul 2014 09:48:44 -0400 Subject: [PATCH] patron search supports url params; patron edit now has spawn_search plugin Signed-off-by: Bill Erickson --- .../web/js/ui/default/staff/circ/patron/app.js | 72 ++++++++++++++++------ .../js/ui/default/staff/circ/patron/register.js | 1 - .../web/js/ui/default/staff/services/lframe.js | 34 ++++++++-- 3 files changed, 84 insertions(+), 23 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index c282068a6b..20f1f9664a 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -674,7 +674,10 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, $scope.initTab('search'); $scope.focusMe = true; - $scope.searchArgs = {}; + $scope.searchArgs = { + // default to searching globally + home_ou : egCore.org.tree() + }; $scope.gridControls = { activateItem : function(item) { @@ -683,9 +686,26 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, selectedItems : function() {return []} } + // Handle URL-encoded searches + if ($location.search().search) { + patronSvc.urlSearch = {search : JSON2js($location.search().search)}; + + // why the double-JSON encoded sort? + patronSvc.urlSearch.sort = + JSON2js(patronSvc.urlSearch.search.search_sort); + delete patronSvc.urlSearch.search.search_sort; + } + + var propagate; if (patronSvc.lastSearch) { - // populate the search form with our cached search info - angular.forEach(patronSvc.lastSearch.search, function(val, key) { + propagate = patronSvc.lastSearch.search; + } else if (patronSvc.urlSearch) { + propagate = patronSvc.urlSearch.search; + } + + if (propagate) { + // populate the search form with our cached / preexisting search info + angular.forEach(propagate, function(val, key) { $scope.searchArgs[key] = val.value; }); } @@ -704,22 +724,32 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, provider.get = function(offset, count) { var deferred = $q.defer(); - var search = compileSearch($scope.searchArgs); - if (Object.keys(search) == 0) return $q.when(); + var fullSearch; + if (patronSvc.urlSearch) { + fullSearch = patronSvc.urlSearch; + // enusre the urlSearch only runs once. + delete patronSvc.urlSearch; + + } else { - var home_ou = search.home_ou; - delete search.home_ou; - var inactive = search.inactive; - delete search.inactive; + var search = compileSearch($scope.searchArgs); + if (Object.keys(search) == 0) return $q.when(); - var fullSearch = { - search : search, - count : count, - sort : compileSort(), - inactive : inactive, - home_ou : home_ou, - offset : offset - }; + var home_ou = search.home_ou; + delete search.home_ou; + var inactive = search.inactive; + delete search.inactive; + + fullSearch = { + search : search, + sort : compileSort(), + inactive : inactive, + home_ou : home_ou, + }; + } + + fullSearch.count = count; + fullSearch.offset = offset; if (patronSvc.lastSearch) { // search repeated, return the cached results @@ -767,7 +797,7 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, fullSearch.count, fullSearch.sort, fullSearch.inactive, - fullSearch.home_ou || egCore.org.tree().id(), + fullSearch.home_ou, egUser.defaultFleshFields, fullSearch.offset @@ -887,6 +917,12 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, $scope.onPatronDblClick = function($event, user) { $location.path('/circ/patron/' + user.id() + '/checkout'); } + + if (patronSvc.urlSearch) { + // force the grid to load the url-based search on page load + provider.refresh(); + } + }]) /** diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/register.js b/Open-ILS/web/js/ui/default/staff/circ/patron/register.js index 705c4cc5ca..0550be565e 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/register.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/register.js @@ -66,7 +66,6 @@ function($scope , $routeParams , $location , $filter , egCore) { url += '&clone=' + encodeURIComponent($routeParams.clone_id); } - console.log('URL = ' + url); $scope.reg_url = url; }]) diff --git a/Open-ILS/web/js/ui/default/staff/services/lframe.js b/Open-ILS/web/js/ui/default/staff/services/lframe.js index a5ea654caa..053cb453f8 100644 --- a/Open-ILS/web/js/ui/default/staff/services/lframe.js +++ b/Open-ILS/web/js/ui/default/staff/services/lframe.js @@ -1,23 +1,49 @@ angular.module('egCoreMod') /* - * Iframe container for legacy interfaces + * Iframe container for legacy embedded interfaces */ .directive('egLegacyFrame', function() { return { restrict : 'AE', + replace : true, scope : { url : '=' }, - template : '', + template : '', - controller : ['$scope','$window', function($scope, $window) { + controller : + ['$scope','$window','$location', + function($scope , $window , $location) { // Set the iframe height to just under the window height. // leave room for the navbar, padding, margins, etc. $scope.height = $window.outerHeight - 250; + + + // define our own xulG functions to be inserted into the + // iframe. NOTE: window-level functions are bad. Though + // there is probably a way, I was unable to correctly wire + // upda the iframe onload handler within the + // way. In any event, the code below is meant as a stop-gap + // for porting dojo, etc. apps to angular apps and should + // eventually go away. + $window.egLegacyFrameLoader = function(iframe) { + + iframe.contentWindow.xulG = { + + // patron search + spawn_search : function(search) { + $window.open( + $location.path('/circ/patron/search'). + search({search : js2JSON(search)}).absUrl(), + '_blank' + ).focus(); + } + } + } }] } }) -- 2.11.0