Bug 28445: Start form with empty library for batch mod
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 20 Jul 2021 15:44:20 +0000 (17:44 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 18 Oct 2021 09:28:40 +0000 (11:28 +0200)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/UI/Form/Builder/Item.pm
tools/batchMod.pl

index f0794de..0681d1d 100644 (file)
@@ -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;
index acbbf29..0988571 100755 (executable)
@@ -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,