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.

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Nick Clemens 2025-02-03 19:25:24 +00:00 committed by Katrin Fischer
parent 7752b0e7cf
commit 58ec1ed304
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -224,6 +224,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 = `<li><a class="dropdown-item" href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=${p["borrowernumber"]}">${p["name"]} (${p["card"]})</a></li>`;
$("#lastBorrowerList").prepend(el);
}
}
if ($("#hiddenborrowernumber").val()) {
// Remove this patron from the list if they are already there
previous_patrons = previous_patrons.filter(function (p) {
@ -245,24 +263,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 = `<li><a class="dropdown-item" href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=${p["borrowernumber"]}">${p["name"]} (${p["card"]})</a></li>`;
$("#lastBorrowerList").prepend(el);
}
}
}
if ($("#hiddenborrowernumber").val()) {