Bugzilla – Attachment 102249 Details for
Bug 24625
Phase out jquery.cookie.js: showLastPatron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24625: Store showLastPatron information using localStorage
Bug-24625-Store-showLastPatron-information-using-l.patch (text/plain), 5.63 KB, created by
Owen Leonard
on 2020-04-01 19:39:13 UTC
(
hide
)
Description:
Bug 24625: Store showLastPatron information using localStorage
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2020-04-01 19:39:13 UTC
Size:
5.63 KB
patch
obsolete
>From 39108300160ec1ecefd22888647c78311b5f81a6 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 1 Apr 2020 16:06:33 +0000 >Subject: [PATCH] Bug 24625: Store showLastPatron information using > localStorage > >This patch removes the use of jquery.cookie to store "last patron" >information, using localStorage instead. > >Because there is no "session only" option with localStorage, additional >handling of the showLastPatron data is added to the login page. That >takes care of "stale" last patron information if user didn't log out but >the session expired for some reason. > >To test apply the patch and enable the showLastPatron system preference. > > 1. Load a patron's account for checkout > 2. Load another patron's account for checkout > - There should now be a "Last patron" link in the breadcrumbs bar > which links to the patron in step 1. Hovering your mouse over the > link should display a tooltip containing the patron's name and > card number. > - Click the "X" to clear the last patron information. The last > patron link should go away. > 3. Log out and log back in. The last patron information should be gone. >--- > koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt | 2 ++ > koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 39 ++++++++++++------------- > 2 files changed, 21 insertions(+), 20 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt >index 4d73d26355..acdbeb327e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt >@@ -126,6 +126,8 @@ > if ( document.location.hash ) { > $( '#loginform' ).append( '<input name="auth_forwarded_hash" type="hidden" value="' + document.location.hash + '"/>' ); > } >+ // if showLastPatron information was not cleared during logout, clear it now >+ removeLastBorrower(); > }); > </script> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 4c6f96c92b..6b19ad218a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -91,36 +91,34 @@ $.fn.selectTabByID = function (tabID) { > $("#catalog-search-dropdown a").toggleClass("catalog-search-dropdown-hover"); > }); > >- if (typeof $.cookie("lastborrowernumber") !== "undefined" && $("#hiddenborrowernumber").val() != $.cookie("lastborrowernumber")) { >+ >+ if ( localStorage.getItem("lastborrowernumber") && $("#hiddenborrowernumber").val() != localStorage.getItem("lastborrowernumber")) { > $("#lastborrower-window").detach().appendTo("#breadcrumbs"); > $("#lastborrowerlink").show(); >- $("#lastborrowerlink").prop("title", $.cookie("lastborrowername") + " (" + $.cookie("lastborrowercard") + ")"); >- $("#lastborrowerlink").prop("href", "/cgi-bin/koha/circ/circulation.pl?borrowernumber=" + $.cookie("lastborrowernumber")); >+ $("#lastborrowerlink").prop("title", localStorage.getItem("lastborrowername") + " (" + localStorage.getItem("lastborrowercard") + ")"); >+ $("#lastborrowerlink").prop("href", "/cgi-bin/koha/circ/circulation.pl?borrowernumber=" + localStorage.getItem("lastborrowernumber")); > $("#lastborrower-window").css("display", "inline-block"); > } >- if ($("a#logout").length > 0) { >- $("a#logout").click(function() { >- delCookie("lastborrowernumber"); >- delCookie("lastborrowername"); >- delCookie("lastborrowercard"); >- delCookie("currentborrowernumber"); >- }); >- } >+ > $("#lastborrower-remove").click(function() { >- delCookie("lastborrowernumber"); >- delCookie("lastborrowername"); >- delCookie("lastborrowercard"); >- delCookie("currentborrowernumber"); >+ removeLastBorrower(); > $("#lastborrower-window").hide(); > }); >- if (typeof $.cookie("lastborrowernumber") === "undefined" || ($("#hiddenborrowernumber").val() != $.cookie("lastborrowernumber") && $.cookie("currentborrowernumber") != $("#hiddenborrowernumber").val())) { >- $.cookie("lastborrowernumber", $("#hiddenborrowernumber").val(), { path: "/" }); >- $.cookie("lastborrowername", $("#hiddenborrowername").val(), { path: "/" }); >- $.cookie("lastborrowercard", $("#hiddenborrowercard").val(), { path: "/" }); >+ if ( localStorage.getItem("lastborrowernumber") || ($("#hiddenborrowernumber").val() != localStorage.getItem("lastborrowernumber") && localStorage.getItem("currentborrowernumber") != $("#hiddenborrowernumber").val())) { >+ localStorage.setItem("lastborrowernumber", $("#hiddenborrowernumber").val() ); >+ localStorage.setItem("lastborrowername", $("#hiddenborrowername").val() ); >+ localStorage.setItem("lastborrowercard", $("#hiddenborrowercard").val() ); > } >- $.cookie("currentborrowernumber", $("#hiddenborrowernumber").val(), { path: "/" }); >+ localStorage.setItem("currentborrowernumber", $("#hiddenborrowernumber").val() ); > }); > >+function removeLastBorrower(){ >+ localStorage.removeItem("lastborrowernumber"); >+ localStorage.removeItem("lastborrowername"); >+ localStorage.removeItem("lastborrowercard"); >+ localStorage.removeItem("currentborrowernumber"); >+} >+ > // http://jennifermadden.com/javascript/stringEnterKeyDetector.html > function checkEnter(e){ //e is event object passed from function invocation > var characterCode; // literal character code will be stored in this variable >@@ -148,6 +146,7 @@ function logOut(){ > delBasket('main', true); > } > clearHoldFor(); >+ removeLastBorrower(); > } > > function openHelp(){ >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24625
:
102249
|
102256
|
105911
|
105946
|
106164
|
106514
|
106519