From 68421705301de6113e40a6b4aa32f8ecc97c22ab 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 --- 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 4ba2171802e..b747508f705 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}; @@ -189,6 +190,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} } = @@ -470,6 +472,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; @@ -541,6 +544,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 2bdd0de2da9..27f119f8e58 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -405,16 +405,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 @@ -430,11 +425,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.20.1