Bug 29788: Fix batch delete item

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Jonathan Druart 2022-01-05 10:27:30 +01:00 committed by Fridolin Somers
parent 21bc236e57
commit 06f1a24297
5 changed files with 13 additions and 7 deletions

View file

@ -131,7 +131,7 @@ sub cancel {
$self->add_message(
{
message => 'error_delitem',
payload => { item => $item, reason => @{$deleted->messages}[0]->messages }
payload => { item => $item, reason => @{$deleted->messages}[0]->message }
}
);
}

View file

@ -119,7 +119,7 @@ sub process {
code => 'item_not_deleted',
biblionumber => $biblionumber,
itemnumber => $item->itemnumber,
error => @{$deleted->messages}[0]->messages,
error => @{$deleted->messages}[0]->message,
};
$schema->storage->txn_rollback;
$job->progress( ++$job_progress )->store;

View file

@ -126,7 +126,7 @@ sub process {
biblionumber => $item->biblionumber,
barcode => $item->barcode,
title => $item->biblio->title,
reason => $return,
reason => @{$return->messages}[0]->message,
};
next;

View file

@ -108,7 +108,13 @@ sub _build_headers {
my @witness_attributes = uniq map {
my $item = $_;
map { defined $item->{$_} && $item->{$_} ne "" ? $_ : () } keys %$item
map {
defined $item->{$_}
&& !ref( $item->{$_} ) # biblio and safe_to_delete are objects
&& $item->{$_} ne ""
? $_
: ()
} keys %$item
} @$items;
my ( $itemtag, $itemsubfield ) =

View file

@ -261,18 +261,18 @@
[% UNLESS can_be_edited %]
<td class="error">Cannot delete</td>
[% ELSE %]
[% IF item.safe_to_delete == 1 %]
[% IF item.safe_to_delete %]
<td><input type="checkbox" name="itemnumber" value="[% item.itemnumber | html %]" id="row[% item.itemnumber | html %]" checked="checked" /></td>
[% ELSE %]
[% SET messages = item.safe_to_delete.messages %]
[% FOR m IN messages %]
[% SWITCH m %]
[% SWITCH m.message %]
[% CASE "book_on_loan" %][% SET cannot_delete_reason = t("Item is checked out") %]
[% CASE "not_same_branch" %][% SET cannot_delete_reason = t("Item does not belong to your library") %]
[% CASE "book_reserved" %][% SET cannot_delete_reason = t("Item has a waiting hold") %]
[% CASE "linked_analytics" %][% SET cannot_delete_reason = t("Item has linked analytics") %]
[% CASE "last_item_for_hold" %][% SET cannot_delete_reason = t("Last item for bibliographic record with biblio-level hold on it") %]
[% CASE %][% SET cannot_delete_reason = t("Unknown reason") _ '(' _ item.safe_to_delete _ ')' %]
[% CASE %][% SET cannot_delete_reason = t("Unknown reason") _ '(' _ m.message _ ')' %]
[% END %]
[% END %]