From 03b5589998a21db7101a3091c9f9fa990add7070 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 3 Feb 2025 19:25:24 +0000 Subject: [PATCH] Bug 39022: Display the current previous patron list before updating stored values This patch just reverses the order so we display the list, then update it. To test: 1 - Enable showLastPatron system preference and set showLastPatronCount to 1 2 - Go to a patron, say Ronnie Ballard 3 - Note you have a link to 'Last patron' - hover or click split dropdown and see it is the patron you are viewing 4 - Search for another patron, Edna Acosta 5 - Note the 'Last patron' links point to Edna, and not Ronnie 6 - Apply patch 7 - Reload Edna, note last patron lists Edna 8 - Search for Ronnie 9 - Confirm previous patron is linked to Edna 10 - Click the link to go to Edna 11 - Confirm last patron now links to Ronnie 12 - Instead of following link, click on another tab for patron 13 - Now the link is updated to current patron, this was behaviour before 21246 as well 14 - Sign off. --- .../intranet-tmpl/prog/js/staff-global.js | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index 1e050dc4d83..8221a8c3eee 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -213,6 +213,24 @@ $(document).ready(function () { ); } + if (previous_patrons.length) { + let p = previous_patrons[0]; + $("#lastborrowerlink").show(); + $("#lastborrowerlink").prop("title", `${p["name"]} (${p["card"]})`); + $("#lastborrowerlink").prop( + "href", + `/cgi-bin/koha/circ/circulation.pl?borrowernumber=${p["borrowernumber"]}` + ); + $("#lastborrower-window").css("display", "inline-flex"); + + previous_patrons.reverse(); + for (i in previous_patrons) { + p = previous_patrons[i]; + const el = `
  • ${p["name"]} (${p["card"]})
  • `; + $("#lastBorrowerList").prepend(el); + } + } + if ($("#hiddenborrowernumber").val()) { // Remove this patron from the list if they are already there previous_patrons = previous_patrons.filter(function (p) { @@ -234,24 +252,6 @@ $(document).ready(function () { JSON.stringify(previous_patrons) ); } - - if (previous_patrons.length) { - let p = previous_patrons[0]; - $("#lastborrowerlink").show(); - $("#lastborrowerlink").prop("title", `${p["name"]} (${p["card"]})`); - $("#lastborrowerlink").prop( - "href", - `/cgi-bin/koha/circ/circulation.pl?borrowernumber=${p["borrowernumber"]}` - ); - $("#lastborrower-window").css("display", "inline-flex"); - - previous_patrons.reverse(); - for (i in previous_patrons) { - p = previous_patrons[i]; - const el = `
  • ${p["name"]} (${p["card"]})
  • `; - $("#lastBorrowerList").prepend(el); - } - } } if ($("#hiddenborrowernumber").val()) { -- 2.39.5