From e8e53ddc7bb4c05e83233c05e763f1cc7b261b1a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 12 Apr 2019 13:50:32 -0400 Subject: [PATCH] Bug 15496: Delete Bib After Moving Item Librarians have requested the ability to delete records with no items quickly and easily from the "Attach item" results page as items are moved from one record to another. Test Plan: 1) Apply this patch 2) Create 2 records with 2 items each 3) Move one item from record A to record B 4) You should see no change from pre-patch behavior 5) Move the second item from record A to record B 6) You should now see a "Delete record" button 7) Click the button 8) Note the record in question has been deleted Signed-off-by: Liz Rea Signed-off-by: Josef Moravec Signed-off-by: Tomas Cohen Arazi --- Koha/Biblio.pm | 9 ++--- cataloguing/moveitem.pl | 5 ++- .../prog/en/modules/cataloguing/moveitem.tt | 39 +++++++++++++++++++ 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 56f91859d5..5ab41cd936 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -351,20 +351,17 @@ sub article_requests_finished { =head3 items -my @items = $biblio->items(); my $items = $biblio->items(); -Returns the related Koha::Items object for this biblio in scalar context, -or list of Koha::Item objects in list context. +Returns the related Koha::Items object for this biblio =cut sub items { my ($self) = @_; - $self->{_items} ||= Koha::Items->search( { biblionumber => $self->biblionumber() } ); - - return wantarray ? $self->{_items}->as_list : $self->{_items}; + my $items_rs = $self->_result->items; + return Koha::Items->_new_from_dbic( $items_rs ); } =head3 itemtype diff --git a/cataloguing/moveitem.pl b/cataloguing/moveitem.pl index 49641f45e2..697057ef03 100755 --- a/cataloguing/moveitem.pl +++ b/cataloguing/moveitem.pl @@ -77,7 +77,10 @@ if ( $barcode && $biblionumber ) { my $moveresult = MoveItemFromBiblio( $itemnumber, $frombiblionumber, $biblionumber ); if ($moveresult) { - $template->param( success => 1 ); + $template->param( + success => 1, + from_biblio => scalar Koha::Biblios->find($frombiblionumber), + ); } else { $template->param( diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/moveitem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/moveitem.tt index b5470f4191..cc163c0335 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/moveitem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/moveitem.tt @@ -1,3 +1,4 @@ +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Cataloging › Attach an item to [% bibliotitle | html %] [% INCLUDE 'doc-head-close.inc' %] @@ -51,6 +52,19 @@ [% ELSE %] [% IF ( success ) %] + [% IF from_biblio.items.count == 0 %] +
+ The record [% from_biblio.title | html %] has [% from_biblio.items.count | html %] attached items. +

+ + + +

+
+
+ [% END %] +
The item has successfully been attached to [% INCLUDE 'biblio-default-view.inc' %][% bibliotitle | html %].

[% INCLUDE actions %] @@ -62,6 +76,7 @@

+
[% ELSE %] [% IF ( missingparameter ) %] @@ -97,4 +112,28 @@ +[% MACRO jsinclude BLOCK %] + +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] -- 2.21.0