Bug 24625: Store showLastPatron information using localStorage
This patch removes the use of jquery.cookie to store "last patron"
information, using localStorage instead. jquery.cookie.js is obsolete.
See Bug 24624.
localStorage has been chosen as an alternative in this situation because
it does not require transmission between the client and the server. See
Bug 12410.
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. Navigate away from patron-related pages: Perform a catalog search
from the search header form and open the detail page from the search
results. Confirm that the correct last patron information still
shows.
3. 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.
4. Log out and log back in. The last patron information should be gone.
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
ee838b1716
commit
a512ae01fc
|
|
@ -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 %]
|
||||
|
|
|
|||
|
|
@ -99,34 +99,32 @@ $.fn.selectTabByID = function (tabID) {
|
|||
$("#catalog-search-dropdown a").toggleClass("catalog-search-dropdown-hover");
|
||||
});
|
||||
|
||||
if (typeof $.cookie("lastborrowernumber") !== "undefined" && $("#hiddenborrowernumber").val() != $.cookie("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"));
|
||||
$("#lastborrower-window").css("display", "inline-block");
|
||||
if ( localStorage.getItem("lastborrowernumber") ){
|
||||
if( $("#hiddenborrowernumber").val() != localStorage.getItem("lastborrowernumber") ) {
|
||||
$("#lastborrower-window").detach().appendTo("#breadcrumbs");
|
||||
$("#lastborrowerlink").show();
|
||||
$("#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");
|
||||
});
|
||||
|
||||
if( !localStorage.getItem("lastborrowernumber") || ( $("#hiddenborrowernumber").val() != localStorage.getItem("lastborrowernumber") && localStorage.getItem("currentborrowernumber") != $("#hiddenborrowernumber").val())) {
|
||||
if( $("#hiddenborrowernumber").val() ){
|
||||
localStorage.setItem("lastborrowernumber", $("#hiddenborrowernumber").val() );
|
||||
localStorage.setItem("lastborrowername", $("#hiddenborrowername").val() );
|
||||
localStorage.setItem("lastborrowercard", $("#hiddenborrowercard").val() );
|
||||
}
|
||||
}
|
||||
|
||||
if( $("#hiddenborrowernumber").val() ){
|
||||
localStorage.setItem("currentborrowernumber", $("#hiddenborrowernumber").val() );
|
||||
}
|
||||
|
||||
$("#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: "/" });
|
||||
}
|
||||
$.cookie("currentborrowernumber", $("#hiddenborrowernumber").val(), { path: "/" });
|
||||
|
||||
/* Search results browsing */
|
||||
/* forms with action leading to search */
|
||||
|
|
@ -144,6 +142,13 @@ $.fn.selectTabByID = function (tabID) {
|
|||
|
||||
});
|
||||
|
||||
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
|
||||
|
|
@ -171,6 +176,7 @@ function logOut(){
|
|||
delBasket('main', true);
|
||||
}
|
||||
clearHoldFor();
|
||||
removeLastBorrower();
|
||||
}
|
||||
|
||||
function openHelp(){
|
||||
|
|
|
|||
Loading…
Reference in New Issue