From 55539067c552107ada2f8be66a83265b0250572e Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Wed, 16 Jan 2019 08:57:26 -0500 Subject: [PATCH] LP1794588 Web client edit single call number changes all when multiple items attached This patch tweaks the behavior Cat.pm's fleshed_volume_update, aka open-ils.cat.asset.volume.fleshed.batch.update Previously, if a volume label was edited, all items attached to that volume would be essentially affected. Now, if only a sub-set of items for the original volume being edited are being edited along with the volume, then a new volume is potentially created instead, leaving the original volume (and its unedited copies) untouched. Auto-merging of volumes may still happen in both of these scenarios. Signed-off-by: Jason Etheridge --- .../src/perlmods/lib/OpenILS/Application/Cat.pm | 32 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm index dd8c730ccf..9cbfdb4c5e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm @@ -1176,9 +1176,35 @@ sub fleshed_volume_update { } elsif( $vol->ischanged ) { $logger->info("vol-update: update volume"); - my $resp = update_volume($vol, $editor, ($oargs->{all} or grep { $_ eq 'VOLUME_LABEL_EXISTS' } @{$oargs->{events}} or $auto_merge_vols)); - return $resp->{evt} if $resp->{evt}; - $vol = $resp->{merge_vol} if $resp->{merge_vol}; + + # check to see if we're editing all existing copies + my $editing_all_copies = 1; + my $all_copies = $editor->search_asset_copy({ + call_number => $vol->id, + deleted => 'f' + }); + my $edit_map = {}; + foreach my $id (map { $_->id } @$copies) { + $edit_map->{$id} = 1; + } + foreach my $id (map { $_->id } @$all_copies) { + if (! $edit_map->{$id}) { + $editing_all_copies = 0; + } + } + + if ($editing_all_copies) { # edit existing volume (and potentially auto-merge) + + my $resp = update_volume($vol, $editor, ($oargs->{all} or grep { $_ eq 'VOLUME_LABEL_EXISTS' } @{$oargs->{events}} or $auto_merge_vols)); + return $resp->{evt} if $resp->{evt}; + $vol = $resp->{merge_vol} if $resp->{merge_vol}; + + } else { # create new volume (and potentially auto-merge) + + ($vol,$evt) = $assetcom->create_volume( $auto_merge_vols ? { all => 1} : $oargs, $editor, $vol ); + return $evt if $evt; + + } } # now update any attached copies -- 2.11.0