Bug 23112: (follow-up) Conditionally prevent checkout

As mentioned by Nick in comment #69, the checkout button displays even
for requests without a biblio attached (such as chapters). This patch
fixes that.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Andrew Isherwood 2020-03-05 09:27:32 +00:00 committed by Martin Renvoize
parent 3cd9d847f7
commit b49656fa31
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
2 changed files with 31 additions and 4 deletions

View File

@ -495,6 +495,8 @@ sub _core_status_graph {
ui_method_name => 'Check out',
needs_prefs => [ 'CirculateILL' ],
needs_perms => [ 'user_circulate_circulate_remaining_permissions' ],
# An array of functions that all must return true
needs_all => [ sub { my $r = shift; return $r->biblio; } ],
method => 'check_out',
next_actions => [ ],
ui_method_icon => 'fa-upload',
@ -1049,6 +1051,25 @@ sub requires_moderation {
return $require_moderation->{$self->status};
}
=head3 biblio
my $biblio = $request->biblio;
For a given request, return the biblio associated with it,
or undef if none exists
=cut
sub biblio {
my ( $self ) = @_;
return if !$self->biblio_id;
return Koha::Biblios->find({
biblionumber => $self->biblio_id
});
}
=head3 check_out
my $stage_summary = $request->check_out;
@ -1072,9 +1093,8 @@ sub check_out {
{},
{ order_by => ['branchcode'] }
);
my $biblio = Koha::Biblios->find({
biblionumber => $self->biblio_id
});
my $biblio = $self->biblio;
# Find all statistical patrons
my $statistical_patrons = Koha::Patrons->search(
{ 'category_type' => 'x' },

View File

@ -441,8 +441,10 @@
[% FOREACH action IN request.available_actions %]
[% needs_prefs = action.needs_prefs.size ? action.needs_prefs : [] %]
[% needs_perms = action.needs_perms.size ? action.needs_perms : [] %]
[% needs_all = action.needs_all.size ? action.needs_all : [] %]
[% has_prefs_count = 0 %]
[% has_perms_count = 0 %]
[% has_all_count = 0 %]
[% FOREACH pref IN needs_prefs %]
[% IF Koha.Preference(pref) %]
[% has_prefs_count = has_prefs_count + 1 %]
@ -454,7 +456,12 @@
[% has_perms_count = has_perms_count + 1 %]
[% END %]
[% END %]
[% NEXT IF has_prefs_count < needs_prefs.size || has_perms_count < needs_perms.size %]
[% FOREACH func IN needs_all %]
[% IF func(request) %]
[% has_all_count = has_all_count + 1 %]
[% END %]
[% END %]
[% NEXT IF has_prefs_count < needs_prefs.size || has_perms_count < needs_perms.size || has_all_count < needs_all.size %]
[% IF action.method == 'migrate' %]
[% IF backends.size > 2 %]
<div class="dropdown btn-group">