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

(-)a/Koha/UI/Form/Builder/Item.pm (-21 / +32 lines)
Lines 72-88 Generate subfield's info for given tag, subfieldtag, etc. Link Here
72
sub generate_subfield_form {
72
sub generate_subfield_form {
73
73
74
    my ($self, $params)    = @_;
74
    my ($self, $params)    = @_;
75
    my $tag         = $params->{tag};
75
    my $tag                         = $params->{tag};
76
    my $subfieldtag = $params->{subfieldtag};
76
    my $subfieldtag                 = $params->{subfieldtag};
77
    my $value       = $params->{value};
77
    my $value                       = $params->{value};
78
    my $tagslib     = $params->{tagslib};
78
    my $tagslib                     = $params->{tagslib};
79
    my $libraries   = $params->{libraries};
79
    my $libraries                   = $params->{libraries};
80
    my $marc_record = $params->{marc_record};
80
    my $marc_record                 = $params->{marc_record};
81
    my $restricted_edition = $params->{restricted_editition};
81
    my $restricted_edition          = $params->{restricted_editition};
82
    my $prefill_with_default_values = $params->{prefill_with_default_values};
82
    my $prefill_with_default_values = $params->{prefill_with_default_values};
83
    my $branch_limit = $params->{branch_limit};
83
    my $branch_limit                = $params->{branch_limit};
84
    my $default_branches_empty = $params->{default_branches_empty};
84
    my $default_branches_empty      = $params->{default_branches_empty};
85
    my $readonly = $params->{readonly};
85
    my $readonly                    = $params->{readonly};
86
    my $do_not_respect_visibility   = $params->{do_not_respect_visibility};
86
87
87
    my $item         = $self->{item};
88
    my $item         = $self->{item};
88
    my $subfield     = $tagslib->{$tag}{$subfieldtag};
89
    my $subfield     = $tagslib->{$tag}{$subfieldtag};
Lines 143-149 sub generate_subfield_form { Link Here
143
    }
144
    }
144
145
145
    $subfield_data{visibility} = "display:none;"
146
    $subfield_data{visibility} = "display:none;"
146
      if ( ( $subfield->{hidden} > 4 ) || ( $subfield->{hidden} <= -4 ) );
147
      if ! $do_not_respect_visibility
148
      && ( ( $subfield->{hidden} > 4 ) || ( $subfield->{hidden} <= -4 ) );
147
149
148
    my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
150
    my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
149
    if (  $prefill_with_default_values
151
    if (  $prefill_with_default_values
Lines 255-261 sub generate_subfield_form { Link Here
255
            }
257
            }
256
        }
258
        }
257
259
258
        if ( $subfield->{hidden} > 4 or $subfield->{hidden} <= -4 ) {
260
        if ( !$do_not_respect_visibility
261
            && ( $subfield->{hidden} > 4 or $subfield->{hidden} <= -4 ) )
262
        {
259
            $subfield_data{marc_value} = {
263
            $subfield_data{marc_value} = {
260
                type      => 'hidden',
264
                type      => 'hidden',
261
                id        => $subfield_data{id},
265
                id        => $subfield_data{id},
Lines 452-457 Limit info depending on the library (so far only item types). Link Here
452
456
453
Flag to add an empty option to the library list.
457
Flag to add an empty option to the library list.
454
458
459
=item do_not_respect_visibility
460
461
If set the visibility defined in the framework will not be used to hide the input.
462
Used by the batch item modification (for LOST for instance).
463
455
=back
464
=back
456
465
457
=cut
466
=cut
Lines 459-473 Flag to add an empty option to the library list. Link Here
459
sub edit_form {
468
sub edit_form {
460
    my ( $self, $params ) = @_;
469
    my ( $self, $params ) = @_;
461
470
462
    my $branchcode         = $params->{branchcode};
471
    my $branchcode                   = $params->{branchcode};
463
    my $restricted_edition = $params->{restricted_editition};
472
    my $restricted_edition           = $params->{restricted_editition};
464
    my $subfields_to_prefill = $params->{subfields_to_prefill} || [];
473
    my $subfields_to_prefill         = $params->{subfields_to_prefill} || [];
465
    my $subfields_to_allow = $params->{subfields_to_allow} || [];
474
    my $subfields_to_allow           = $params->{subfields_to_allow} || [];
466
    my $ignore_not_allowed_subfields = $params->{ignore_not_allowed_subfields};
475
    my $ignore_not_allowed_subfields = $params->{ignore_not_allowed_subfields};
467
    my $kohafields_to_ignore = $params->{kohafields_to_ignore} || [];
476
    my $kohafields_to_ignore         = $params->{kohafields_to_ignore} || [];
468
    my $prefill_with_default_values = $params->{prefill_with_default_values};
477
    my $prefill_with_default_values  = $params->{prefill_with_default_values};
469
    my $branch_limit = $params->{branch_limit};
478
    my $branch_limit                 = $params->{branch_limit};
470
    my $default_branches_empty = $params->{default_branches_empty};
479
    my $default_branches_empty       = $params->{default_branches_empty};
480
    my $do_not_respect_visibility    = $params->{do_not_respect_visibility} || 0;
471
481
472
    my $libraries =
482
    my $libraries =
473
      Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
483
      Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
Lines 551-557 sub edit_form { Link Here
551
                        prefill_with_default_values => $prefill_with_default_values,
561
                        prefill_with_default_values => $prefill_with_default_values,
552
                        branch_limit       => $branch_limit,
562
                        branch_limit       => $branch_limit,
553
                        default_branches_empty => $default_branches_empty,
563
                        default_branches_empty => $default_branches_empty,
554
                        readonly           => $readonly
564
                        readonly           => $readonly,
565
                        do_not_respect_visibility => $do_not_respect_visibility,
555
                    }
566
                    }
556
                );
567
                );
557
                push @subfields, $subfield_data;
568
                push @subfields, $subfield_data;
(-)a/t/db_dependent/Koha/UI/Form/Builder/Item.t (-2 / +37 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 => 6;
19
use Test::More tests => 7;
20
use utf8;
20
use utf8;
21
21
22
use List::MoreUtils qw( uniq );
22
use List::MoreUtils qw( uniq );
Lines 45-51 $cache->clear_from_cache("MarcSubfieldStructure-"); Link Here
45
setup_mss();
45
setup_mss();
46
46
47
subtest 'authorised values' => sub {
47
subtest 'authorised values' => sub {
48
    #plan tests => 1;
48
    plan tests => 5;
49
49
50
    my $biblio = $builder->build_sample_biblio({ value => {frameworkcode => ''}});
50
    my $biblio = $builder->build_sample_biblio({ value => {frameworkcode => ''}});
51
    my $subfields =
51
    my $subfields =
Lines 258-263 subtest 'subfields_to_allow & ignore_not_allowed_subfields' => sub { Link Here
258
    is( $subfield, undef, "subfield that is not in the allow list is not returned" );
258
    is( $subfield, undef, "subfield that is not in the allow list is not returned" );
259
};
259
};
260
260
261
subtest 'do_not_respect_visilibity' => sub {
262
    plan tests => 4;
263
264
    my ( $tag_lost, $subtag_lost ) = C4::Biblio::GetMarcFromKohaField("items.itemlost");
265
266
    my $m = Koha::MarcSubfieldStructures->find(
267
        {
268
            frameworkcode => '',
269
            tagfield      => $tag_lost,
270
            tagsubfield   => $subtag_lost,
271
272
        }
273
    );
274
275
    is( $m->hidden, -5, "Ensure that hidden for items.itemlost is set to -5" );
276
277
    my $biblio =
278
      $builder->build_sample_biblio( { value => { frameworkcode => '' } } );
279
    my $subfields =
280
      Koha::UI::Form::Builder::Item->new(
281
        { biblionumber => $biblio->biblionumber } )->edit_form;
282
283
    my ($subfield) = grep { $_->{kohafield} eq 'items.itemlost' } @$subfields;
284
    is( $subfield->{visibility}, 'display:none;', 'itemlost is flagged as hidden if set at framework level' );
285
286
    $subfields =
287
      Koha::UI::Form::Builder::Item->new(
288
        { biblionumber => $biblio->biblionumber } )
289
      ->edit_form( { do_not_respect_visibility => 1 } );
290
291
    ($subfield) = grep { $_->{kohafield} eq 'items.itemlost' } @$subfields;
292
    is( $subfield->{visibility}, undef, 'itemlost is not flagged as hidden even if set at framework level - do_not_respect_visibility is passed' );
293
    is( ref($subfield->{marc_value}->{values}), 'ARRAY', 'Values for LOST must have been filled' )
294
};
295
261
296
262
$cache->clear_from_cache("MarcStructure-0-");
297
$cache->clear_from_cache("MarcStructure-0-");
263
$cache->clear_from_cache("MarcStructure-1-");
298
$cache->clear_from_cache("MarcStructure-1-");
(-)a/tools/batchMod.pl (-1 / +1 lines)
Lines 281-286 if ($op eq "show"){ Link Here
281
            kohafields_to_ignore         => ['items.barcode'],
281
            kohafields_to_ignore         => ['items.barcode'],
282
            prefill_with_default_values => $use_default_values,
282
            prefill_with_default_values => $use_default_values,
283
            default_branches_empty      => 1,
283
            default_branches_empty      => 1,
284
            do_not_respect_visibility   => 1,
284
        }
285
        }
285
    );
286
    );
286
287
287
- 

Return to bug 29331