From b52c7d7b3664b81b41bade88cbb3491dcdb81693 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 20 Jul 2021 17:44:20 +0200 Subject: [PATCH] Bug 28445: Start form with empty library for batch mod Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- Koha/UI/Form/Builder/Item.pm | 4 ++++ tools/batchMod.pl | 10 ++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Koha/UI/Form/Builder/Item.pm b/Koha/UI/Form/Builder/Item.pm index f0794decb0..0681d1d963 100644 --- a/Koha/UI/Form/Builder/Item.pm +++ b/Koha/UI/Form/Builder/Item.pm @@ -81,6 +81,7 @@ sub generate_subfield_form { my $restricted_edition = $params->{restricted_editition}; my $prefill_with_default_values = $params->{prefill_with_default_values}; my $branch_limit = $params->{branch_limit}; + my $default_branches_empty = $params->{default_branches_empty}; my $item = $self->{item}; my $subfield = $tagslib->{$tag}{$subfieldtag}; @@ -190,6 +191,7 @@ sub generate_subfield_form { } } elsif ( $subfield->{authorised_value} eq "branches" ) { + push @authorised_values, "" if $default_branches_empty; foreach my $thisbranch (@$libraries) { push @authorised_values, $thisbranch->{branchcode}; $authorised_lib{ $thisbranch->{branchcode} } = @@ -471,6 +473,7 @@ sub edit_form { my $subfields_to_ignore= $params->{subfields_to_ignore} || []; my $prefill_with_default_values = $params->{prefill_with_default_values}; my $branch_limit = $params->{branch_limit}; + my $default_branches_empty = $params->{default_branches_empty}; my $libraries = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed; @@ -542,6 +545,7 @@ sub edit_form { restricted_edition => $restricted_edition, prefill_with_default_values => $prefill_with_default_values, branch_limit => $branch_limit, + default_branches_empty => $default_branches_empty, } ); push @subfields, $subfield_data; diff --git a/tools/batchMod.pl b/tools/batchMod.pl index acbbf295a6..0988571b5d 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -404,16 +404,11 @@ if ($op eq "show"){ # Even if we do not display the items, we need the itemnumbers $template->param(itemnumbers_array => \@itemnumbers); } + # now, build the item form for entering a new item my @loop_data =(); my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; - my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;# build once ahead of time, instead of multiple times later. - - # Adding a default choice, in case the user does not want to modify the branch - my $nochange_branch = { branchname => '', value => '', selected => 1 }; - unshift (@$libraries, $nochange_branch); - my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); # Getting list of subfields to keep when restricted batchmod edit is enabled @@ -429,11 +424,10 @@ if ($op eq "show"){ ), subfields_to_ignore => ['items.barcode'], prefill_with_default_values => $use_default_values, + default_branches_empty => 1, } ); - - # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit. $template->param( subfields => $subfields, -- 2.39.5