From 350500afb00a0a2b244ef93d5cabb9549ffa59cd Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 4 Aug 2016 12:34:56 -0400 Subject: [PATCH] LP#1527694 Webstaff clear last patron Store most recent patron ID via cookie instead of localStorage so the value can expire when then browser is closed. Adds angular-cookies (ngCookies) dependency. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander Conflicts: Open-ILS/web/js/ui/default/staff/bower.json --- Open-ILS/src/templates/staff/base_js.tt2 | 1 + Open-ILS/web/js/ui/default/staff/Gruntfile.js | 2 ++ Open-ILS/web/js/ui/default/staff/bower.json | 3 ++- Open-ILS/web/js/ui/default/staff/circ/patron/app.js | 12 ++++++------ Open-ILS/web/js/ui/default/staff/services/core.js | 2 +- Open-ILS/web/js/ui/default/staff/test/karma.conf.js | 1 + 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/templates/staff/base_js.tt2 b/Open-ILS/src/templates/staff/base_js.tt2 index bd3928f597..af92b80715 100644 --- a/Open-ILS/src/templates/staff/base_js.tt2 +++ b/Open-ILS/src/templates/staff/base_js.tt2 @@ -12,6 +12,7 @@ + diff --git a/Open-ILS/web/js/ui/default/staff/Gruntfile.js b/Open-ILS/web/js/ui/default/staff/Gruntfile.js index 910d7e146f..4bfb43316e 100644 --- a/Open-ILS/web/js/ui/default/staff/Gruntfile.js +++ b/Open-ILS/web/js/ui/default/staff/Gruntfile.js @@ -31,6 +31,8 @@ module.exports = function(grunt) { 'bower_components/angular-tree-control/angular-tree-control.js', 'bower_components/ngtoast/dist/ngToast.min.js', 'bower_components/jquery/dist/jquery.min.js', + 'bower_components/angular-cookies/angular-cookies.min.js', + 'bower_components/angular-cookies/angular-cookies.min.js.map' ] }] }, diff --git a/Open-ILS/web/js/ui/default/staff/bower.json b/Open-ILS/web/js/ui/default/staff/bower.json index dcadeee3a5..f332f3b55e 100644 --- a/Open-ILS/web/js/ui/default/staff/bower.json +++ b/Open-ILS/web/js/ui/default/staff/bower.json @@ -29,7 +29,8 @@ "ngtoast": "~2.0.0", "angular-tree-control": "~0.2.28", "angular-animate": "~1.5.3", - "angular-hotkeys": "cfp-angular-hotkeys#^1.7.0" + "angular-hotkeys": "cfp-angular-hotkeys#^1.7.0", + "angular-cookies": "^1.5.8" }, "resolutions": { "angular": "~1.5.5" 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 652a35f6dc..d31afa268f 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 @@ -207,8 +207,8 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap', * Patron service */ .factory('patronSvc', - ['$q','$timeout','$location','egCore','egUser','$locale', -function($q , $timeout , $location , egCore, egUser , $locale) { + ['$q','$timeout','$location','$cookies','egCore','egUser','$locale', +function($q , $timeout , $location , $cookies , egCore, egUser , $locale) { var service = { // cached patron search results @@ -271,7 +271,7 @@ function($q , $timeout , $location , egCore, egUser , $locale) { // when loading a new patron, update the last patron setting if (!service.current || service.current.id() != user_id) - egCore.hatch.setLocalItem('eg.circ.last_patron', user_id); + $cookies.put('eg.circ.last_patron', user_id); // avoid running multiple retrievals for the same patron, which // can happen during dbl-click by maintaining a single running @@ -1553,10 +1553,10 @@ function($scope, $routeParams , $q , egCore , patronSvc) { }]) .controller('PatronFetchLastCtrl', - ['$scope','$location','egCore', -function($scope , $location , egCore) { + ['$scope','$location','$cookies','egCore', +function($scope , $location , $cookies, egCore) { - var id = egCore.hatch.getLocalItem('eg.circ.last_patron'); + var id = $cookies.get('eg.circ.last_patron'); if (id) return $location.path('/circ/patron/' + id + '/checkout'); $scope.no_last = true; diff --git a/Open-ILS/web/js/ui/default/staff/services/core.js b/Open-ILS/web/js/ui/default/staff/services/core.js index 94c4b46aac..dc5ef6ceda 100644 --- a/Open-ILS/web/js/ui/default/staff/services/core.js +++ b/Open-ILS/web/js/ui/default/staff/services/core.js @@ -3,4 +3,4 @@ * egCoreMod houses all of the services, etc. required by all pages * for basic functionality. */ -angular.module('egCoreMod', ['cfp.hotkeys', 'ngFileSaver']); +angular.module('egCoreMod', ['cfp.hotkeys', 'ngFileSaver', 'ngCookies']); diff --git a/Open-ILS/web/js/ui/default/staff/test/karma.conf.js b/Open-ILS/web/js/ui/default/staff/test/karma.conf.js index 760fc3b8f2..b8c1259f94 100644 --- a/Open-ILS/web/js/ui/default/staff/test/karma.conf.js +++ b/Open-ILS/web/js/ui/default/staff/test/karma.conf.js @@ -12,6 +12,7 @@ module.exports = function(config){ 'bower_components/angular-file-saver/dist/angular-file-saver.bundle.min.js', 'build/js/ui-bootstrap.min.js', 'build/js/hotkeys.min.js', + 'build/js/angular-cookies.min.js', /* OpenSRF must be installed first */ '/openils/lib/javascript/md5.js', '/openils/lib/javascript/JSON_v1.js', -- 2.11.0