From 3abe3f1485c059fcfc37461db4c3c42625685cc1 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 16 Jul 2026 09:24:39 +0100 Subject: [PATCH] Bug 40206: (QA follow-up) Fix JS error and misleading message on disabled curbside pickups page The early-exit added for the CurbsidePickup syspref check left policy/curbside_pickups unset, but intranet-bottom.inc's jsinclude still referenced them unconditionally, causing a client-side TypeError on every render of the disabled state. Guard the whole jsinclude block with disabled_for_branch. Also distinguish the two reasons the page can be disabled: the CurbsidePickup syspref being off globally vs. this branch simply not having an enabled curbside pickup policy configured. The message and link now point staff to the correct admin page for each case, instead of always suggesting the syspref (which may already be on). Signed-off-by: Pedro Amorim --- circ/curbside_pickups.pl | 8 +- .../prog/en/modules/circ/curbside_pickups.tt | 444 +++++++++--------- 2 files changed, 231 insertions(+), 221 deletions(-) diff --git a/circ/curbside_pickups.pl b/circ/curbside_pickups.pl index 63ba9aa9cb..159163432c 100755 --- a/circ/curbside_pickups.pl +++ b/circ/curbside_pickups.pl @@ -47,12 +47,16 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $branchcode = C4::Context->userenv()->{'branch'}; my $policy; -if ( C4::Context->preference('CurbsidePickup') ) { +my $curbside_pickup_syspref_disabled = !C4::Context->preference('CurbsidePickup'); +unless ($curbside_pickup_syspref_disabled) { $policy = Koha::CurbsidePickupPolicies->find( { branchcode => $branchcode } ); } unless ( $policy && $policy->enabled ) { - $template->param( disabled_for_branch => 1 ); + $template->param( + disabled_for_branch => 1, + curbside_pickup_syspref_disabled => $curbside_pickup_syspref_disabled, + ); output_html_with_http_headers $input, $cookie, $template->output; exit; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt index f1355f2c5c..e3abf04754 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt @@ -453,244 +453,250 @@ [% END # /BLOCK enabled %] [% MACRO jsinclude BLOCK %] - [% Asset.js("lib/dayjs/plugin/isSameOrAfter.js") | $raw %] - - - [% INCLUDE 'calendar.inc' %] - [% INCLUDE 'datatables.inc' %] - + + [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'datatables.inc' %] + - + + function clear_intervals() { + if (refresh_interval_id) { + clearInterval(refresh_interval_id); + refresh_interval_id = 0; + } + if (countdown_interval_id) { + clearInterval(countdown_interval_id); + countdown_interval_id = 0; + } + } + + function set_interval_if_needed() { + const refresh_delay = $("#refresh_delay").val(); + const auto_refresh = $("#auto_refresh").is(":checked"); + + if (auto_refresh && refresh_delay) { + set_interval(refresh_delay * 1000); + } else { + clear_intervals(); + } + } + + [% END # /UNLESS disabled_for_branch %] [% END %] [% BLOCK curbside_pickups_disabled %]

Curbside pickups

-
Curbside pickups are not enabled. Enable the CurbsidePickup system preference to use this feature.
+ [% IF curbside_pickup_syspref_disabled %] +
Curbside pickups are not enabled. Enable the CurbsidePickup system preference to use this feature.
+ [% ELSE %] +
Curbside pickups are not enabled for your library. Configure a curbside pickup policy for this library to use this feature.
+ [% END %] [% END # /BLOCK disabled %] [% SET aside = Koha.Preference('CircSidebar') ? 'circ-nav' : '' %]