From 851e4f8af03122207add721b41abfd3ec853b8c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20=E2=80=9Etadzik=E2=80=9D=20So=C5=9Bnierz?= Date: Wed, 14 Jan 2026 12:56:12 +0100 Subject: [PATCH] Bug 41612: Await API responses when marking circulation notes as seen/not seen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test plan (specifics for KTD): 1. Enable checkout notes at /cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=checkout+notes 2. Checkout a book at /cgi-bin/koha/circ/circulation.pl?findborrower=42, e.g. barcode 39999000011418 3. Navigate to OPAC, add a note to your checkout 4. Navigate to intranet's /cgi-bin/koha/circ/checkout-notes.pl 5. Try clicking Mark seen/Mark not seen, observe status not changing instantly and error messages popping up 6. Apply the patch 7. Observe the buttons working instantly and no error messsage showing up Sponsored-by: Steiermärkische Landesbibliothek --- .../prog/en/modules/circ/checkout-notes.tt | 64 +++++++++++-------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/checkout-notes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/checkout-notes.tt index 5130a113e9..2c61b27df5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/checkout-notes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/checkout-notes.tt @@ -165,39 +165,47 @@ const client = APIClient.circulation; if (op == "seen") { - client.checkouts.mark_as_seen(issue_id).then( - success => { - if (success.seen) { - $("#status_" + issue_id).text(_("Seen")); - $(event.target).parent().siblings(".seen0").removeClass("seen0").addClass("seen1"); - $(event.target).siblings(".notseen").prop("disabled", false); - $(event.target).prop("disabled", true); - } else { + client.checkouts + .mark_as_seen(issue_id) + .then(response => response.text()) + .then(response => JSON.parse(response)) + .then( + success => { + if (success.seen) { + $("#status_" + issue_id).text(_("Seen")); + $(event.target).parent().siblings(".seen0").removeClass("seen0").addClass("seen1"); + $(event.target).siblings(".notseen").prop("disabled", false); + $(event.target).prop("disabled", true); + } else { + show_error(); + } + }, + error => { + console.warn("Something wrong happened: %s".format(error)); show_error(); } - }, - error => { - console.warn("Something wrong happened: %s".format(error)); - show_error(); - } - ); + ); } else { - client.checkouts.mark_as_not_seen(issue_id).then( - success => { - if (!success.seen) { - $("#status_" + issue_id).text(_("Not seen")); - $(event.target).parent().siblings(".seen1").removeClass("seen1").addClass("seen0"); - $(event.target).siblings(".seen").prop("disabled", false); - $(event.target).prop("disabled", true); - } else { + client.checkouts + .mark_as_not_seen(issue_id) + .then(response => response.text()) + .then(response => JSON.parse(response)) + .then( + success => { + if (!success.seen) { + $("#status_" + issue_id).text(_("Not seen")); + $(event.target).parent().siblings(".seen1").removeClass("seen1").addClass("seen0"); + $(event.target).siblings(".seen").prop("disabled", false); + $(event.target).prop("disabled", true); + } else { + show_error(); + } + }, + error => { + console.warn("Something wrong happened: %s".format(error)); show_error(); } - }, - error => { - console.warn("Something wrong happened: %s".format(error)); - show_error(); - } - ); + ); } }); }); -- 2.51.0