Bug 40206: Fix wrong layout in curbside pickups when 'CircSidebar' enabled
This patch solves the following issues:
* Template flow issue: the template called STOP which prevented the
WRAPPER to complete and affected how things were rendered.
* Redirect to 404 if feature disabled. This is common practice in other
modules. The fact things can be executed even with the feature
disabled is not ok (syspref).
* Shortcircuit earlier. Similar to the above, if the feature is
disabled for the current branch, no DB queries and stuff should take
place. Notice the lack of checks actually makes the controller perform
the actions. It is just that it is not displayed afterwards!
To test:
1. Enable the `CurbsidePickup` syspref.
2. 'Activate' the `CircSidebar` syspref.
3. Be on a branch that doesn't have them enabled
4. Go to Circulation > Check in
=> SUCCESS: A nice left-hand sidebar is displayed with access to
Circulation actions
5. Click on 'Curbside pickups'
=> FAIL: The sidebar doesn't display. boo!
6. Apply this patch
7. Restart plack
$ ktd --shell
$ koha-plack --restart kohadev
8. Repeat 4
=> SUCCESS: It renders much better!
9. Sign off :-D
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
2f227048ae
commit
c68bacc5c2
|
|
@ -45,7 +45,19 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
|||
);
|
||||
|
||||
my $branchcode = C4::Context->userenv()->{'branch'};
|
||||
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchname'] } );
|
||||
|
||||
my $policy;
|
||||
if ( C4::Context->preference('CurbsidePickup') ) {
|
||||
$policy = Koha::CurbsidePickupPolicies->find( { branchcode => $branchcode } );
|
||||
}
|
||||
|
||||
unless ( $policy && $policy->enabled ) {
|
||||
$template->param( disabled_for_branch => 1 );
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
exit;
|
||||
}
|
||||
|
||||
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchname'] } );
|
||||
if ( $op eq 'find-patron' ) {
|
||||
my $borrowernumber = $input->param('borrowernumber');
|
||||
|
||||
|
|
@ -150,7 +162,7 @@ $template->param(
|
|||
tab => $tab,
|
||||
auto_refresh => $auto_refresh,
|
||||
refresh_delay => $refresh_delay,
|
||||
policy => Koha::CurbsidePickupPolicies->find( { branchcode => $branchcode } ),
|
||||
policy => $policy,
|
||||
curbside_pickups => Koha::CurbsidePickups->search(
|
||||
{
|
||||
branchcode => $branchcode,
|
||||
|
|
|
|||
|
|
@ -84,16 +84,9 @@
|
|||
[% END %]
|
||||
[% END %]
|
||||
|
||||
[% SET aside = Koha.Preference('CircSidebar') ? 'circ-nav' : '' %]
|
||||
[% WRAPPER 'main-container.inc' aside=aside %]
|
||||
[% BLOCK curbside_pickups_enabled %]
|
||||
<h1>Curbside pickups</h1>
|
||||
|
||||
[% UNLESS policy.enabled %]
|
||||
<div class="alert alert-warning"> Curbside pickups are not enabled for your library. </div>
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
||||
[% STOP %]
|
||||
[% END %]
|
||||
|
||||
[% FOR m IN messages %]
|
||||
<div class="alert alert-[% m.type | html %]">
|
||||
[% SWITCH m.code %]
|
||||
|
|
@ -457,7 +450,7 @@
|
|||
[% END # /tab_panel %]
|
||||
[% END # /WRAPPER tab_panels %]
|
||||
[% END # /WRAPPER tabs %]
|
||||
[% END %]
|
||||
[% END # /BLOCK enabled %]
|
||||
|
||||
[% MACRO jsinclude BLOCK %]
|
||||
[% Asset.js("lib/dayjs/plugin/isSameOrAfter.js") | $raw %]
|
||||
|
|
@ -695,4 +688,18 @@
|
|||
</script>
|
||||
[% END %]
|
||||
|
||||
[% BLOCK curbside_pickups_disabled %]
|
||||
<h1>Curbside pickups</h1>
|
||||
<div class="alert alert-info">Curbside pickups are not enabled. Enable the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=CurbsidePickup">CurbsidePickup</a> system preference to use this feature.</div>
|
||||
[% END # /BLOCK disabled %]
|
||||
|
||||
[% SET aside = Koha.Preference('CircSidebar') ? 'circ-nav' : '' %]
|
||||
[% WRAPPER 'main-container.inc' aside=aside %]
|
||||
[% IF !disabled_for_branch %]
|
||||
[% PROCESS curbside_pickups_enabled %]
|
||||
[% ELSE %]
|
||||
[% PROCESS curbside_pickups_disabled %]
|
||||
[% END %]
|
||||
[% END # /WRAPPER %]
|
||||
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
||||
|
|
|
|||
Loading…
Reference in New Issue