View | Details | Raw Unified | Return to bug 31179
Collapse All | Expand All

(-)a/Koha/UI/Form/Builder/Item.pm (-1 / +13 lines)
Lines 455-460 Flag to add an empty option to the library list. Link Here
455
455
456
=back
456
=back
457
457
458
=item ignore_invisible_subfields
459
460
Skip the subfields that are not visible on the editor.
461
462
When duplicating an item we do not want to retrieve the subfields that are hidden.
463
464
=back
465
458
=cut
466
=cut
459
467
460
sub edit_form {
468
sub edit_form {
Lines 469-474 sub edit_form { Link Here
469
    my $prefill_with_default_values = $params->{prefill_with_default_values};
477
    my $prefill_with_default_values = $params->{prefill_with_default_values};
470
    my $branch_limit = $params->{branch_limit};
478
    my $branch_limit = $params->{branch_limit};
471
    my $default_branches_empty = $params->{default_branches_empty};
479
    my $default_branches_empty = $params->{default_branches_empty};
480
    my $ignore_invisible_subfields = $params->{ignore_invisible_subfields} || 0;
472
481
473
    my $libraries =
482
    my $libraries =
474
      Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
483
      Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
Lines 500-505 sub edit_form { Link Here
500
              if grep { $subfield->{kohafield} && $subfield->{kohafield} eq $_ }
509
              if grep { $subfield->{kohafield} && $subfield->{kohafield} eq $_ }
501
              @$kohafields_to_ignore;
510
              @$kohafields_to_ignore;
502
511
512
            next
513
              if $ignore_invisible_subfields
514
              && ( $subfield->{hidden} > 4 || $subfield->{hidden} <= -4 );
515
503
            my $readonly;
516
            my $readonly;
504
            if (
517
            if (
505
                @$subfields_to_allow && !grep {
518
                @$subfields_to_allow && !grep {
Lines 507-513 sub edit_form { Link Here
507
                } @$subfields_to_allow
520
                } @$subfields_to_allow
508
              )
521
              )
509
            {
522
            {
510
511
                next if $ignore_not_allowed_subfields;
523
                next if $ignore_not_allowed_subfields;
512
                $readonly = 1 if $restricted_edition;
524
                $readonly = 1 if $restricted_edition;
513
            }
525
            }
(-)a/cataloguing/additem.pl (+5 lines)
Lines 626-631 my $subfields = Link Here
626
        ),
626
        ),
627
        prefill_with_default_values => 1,
627
        prefill_with_default_values => 1,
628
        branch_limit => C4::Context->userenv->{"branch"},
628
        branch_limit => C4::Context->userenv->{"branch"},
629
        (
630
            $op eq 'dupeitem'
631
            ? ( ignore_invisible_subfields => 1 )
632
            : ()
633
        ),
629
    }
634
    }
630
);
635
);
631
636
(-)a/t/db_dependent/Koha/UI/Form/Builder/Item.t (-2 / +36 lines)
Lines 16-22 Link Here
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
use Test::More tests => 7;
19
use Test::More tests => 8;
20
use Data::Dumper qw( Dumper );
20
use Data::Dumper qw( Dumper );
21
use utf8;
21
use utf8;
22
22
Lines 298-303 subtest 'subfields_to_allow & ignore_not_allowed_subfields' => sub { Link Here
298
    is( $subfield, undef, "subfield that is not in the allow list is not returned" );
298
    is( $subfield, undef, "subfield that is not in the allow list is not returned" );
299
};
299
};
300
300
301
subtest 'ignore_invisible_subfields' => sub {
302
    plan tests => 2;
303
304
    my $biblio =
305
      $builder->build_sample_biblio( { value => { frameworkcode => '' } } );
306
    my $item = $builder->build_sample_item(
307
        {
308
            issues => 42,
309
        }
310
    );
311
312
    # items.issues is mapped with 952$l
313
    my $subfields = Koha::UI::Form::Builder::Item->new(
314
        {
315
            biblionumber => $biblio->biblionumber,
316
            item         => $item->unblessed,
317
        }
318
    )->edit_form;
319
    ( my $subfield ) = grep { $_->{subfield} eq 'l' } @$subfields;
320
    is( $subfield->{marc_value}->{value}, 42, 'items.issues copied' );
321
322
    $subfields = Koha::UI::Form::Builder::Item->new(
323
        {
324
            biblionumber => $biblio->biblionumber,
325
            item         => $item->unblessed,
326
        }
327
    )->edit_form(
328
        {
329
            ignore_invisible_subfields => 1
330
        }
331
    );
332
    ($subfield) = grep { $_->{subfield} eq 'l' } @$subfields;
333
    is( $subfield->{marc_value}->{value},
334
        undef, 'items.issues not copied if ignore_invisible_subfields is passed' );
335
};
301
336
302
$cache->clear_from_cache("MarcStructure-0-");
337
$cache->clear_from_cache("MarcStructure-0-");
303
$cache->clear_from_cache("MarcStructure-1-");
338
$cache->clear_from_cache("MarcStructure-1-");
304
- 

Return to bug 31179