LP#1527694 Webstaff clear last patron
authorBill Erickson <berickxx@gmail.com>
Thu, 4 Aug 2016 16:34:56 +0000 (12:34 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 18 Aug 2016 19:34:23 +0000 (15:34 -0400)
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 <berickxx@gmail.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Conflicts:
Open-ILS/web/js/ui/default/staff/bower.json

Open-ILS/src/templates/staff/base_js.tt2
Open-ILS/web/js/ui/default/staff/Gruntfile.js
Open-ILS/web/js/ui/default/staff/bower.json
Open-ILS/web/js/ui/default/staff/circ/patron/app.js
Open-ILS/web/js/ui/default/staff/services/core.js
Open-ILS/web/js/ui/default/staff/test/karma.conf.js

index bd3928f..af92b80 100644 (file)
@@ -12,6 +12,7 @@
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/angular-location-update.min.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/angular-animate.min.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/angular-sanitize.min.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/angular-cookies.min.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/ngToast.min.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/angular-tree-control.js"></script>
 
index 910d7e1..4bfb433 100644 (file)
@@ -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'
           ]
         }]
       },
index dcadeee..f332f3b 100644 (file)
@@ -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"
index 652a35f..d31afa2 100644 (file)
@@ -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;
index 94c4b46..dc5ef6c 100644 (file)
@@ -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']);
index 760fc3b..b8c1259 100644 (file)
@@ -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',