Bugzilla – Attachment 126956 Details for
Bug 29331
Batch edit items.itemlost
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29331: Allow items.itemlost from batch item modification
Bug-29331-Allow-itemsitemlost-from-batch-item-modi.patch (text/plain), 8.09 KB, created by
Jonathan Druart
on 2021-10-27 08:22:51 UTC
(
hide
)
Description:
Bug 29331: Allow items.itemlost from batch item modification
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-10-27 08:22:51 UTC
Size:
8.09 KB
patch
obsolete
>From 33f7703a2548cf59c9f0103cec73b5320008bb12 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 27 Oct 2021 10:11:01 +0200 >Subject: [PATCH] Bug 29331: Allow items.itemlost from batch item modification > >Not done yet, call to LostItem from Koha::Items->batch_update needs to >be adjusted >--- > Koha/UI/Form/Builder/Item.pm | 53 +++++++++++++--------- > t/db_dependent/Koha/UI/Form/Builder/Item.t | 39 +++++++++++++++- > tools/batchMod.pl | 1 + > 3 files changed, 70 insertions(+), 23 deletions(-) > >diff --git a/Koha/UI/Form/Builder/Item.pm b/Koha/UI/Form/Builder/Item.pm >index d223b51dafb..d3afd76c2c9 100644 >--- a/Koha/UI/Form/Builder/Item.pm >+++ b/Koha/UI/Form/Builder/Item.pm >@@ -72,17 +72,18 @@ Generate subfield's info for given tag, subfieldtag, etc. > sub generate_subfield_form { > > my ($self, $params) = @_; >- my $tag = $params->{tag}; >- my $subfieldtag = $params->{subfieldtag}; >- my $value = $params->{value}; >- my $tagslib = $params->{tagslib}; >- my $libraries = $params->{libraries}; >- my $marc_record = $params->{marc_record}; >- my $restricted_edition = $params->{restricted_editition}; >+ my $tag = $params->{tag}; >+ my $subfieldtag = $params->{subfieldtag}; >+ my $value = $params->{value}; >+ my $tagslib = $params->{tagslib}; >+ my $libraries = $params->{libraries}; >+ my $marc_record = $params->{marc_record}; >+ 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 $readonly = $params->{readonly}; >+ my $branch_limit = $params->{branch_limit}; >+ my $default_branches_empty = $params->{default_branches_empty}; >+ my $readonly = $params->{readonly}; >+ my $do_not_respect_visibility = $params->{do_not_respect_visibility}; > > my $item = $self->{item}; > my $subfield = $tagslib->{$tag}{$subfieldtag}; >@@ -143,7 +144,8 @@ sub generate_subfield_form { > } > > $subfield_data{visibility} = "display:none;" >- if ( ( $subfield->{hidden} > 4 ) || ( $subfield->{hidden} <= -4 ) ); >+ if ! $do_not_respect_visibility >+ && ( ( $subfield->{hidden} > 4 ) || ( $subfield->{hidden} <= -4 ) ); > > my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); > if ( $prefill_with_default_values >@@ -255,7 +257,9 @@ sub generate_subfield_form { > } > } > >- if ( $subfield->{hidden} > 4 or $subfield->{hidden} <= -4 ) { >+ if ( !$do_not_respect_visibility >+ && ( $subfield->{hidden} > 4 or $subfield->{hidden} <= -4 ) ) >+ { > $subfield_data{marc_value} = { > type => 'hidden', > id => $subfield_data{id}, >@@ -452,6 +456,11 @@ Limit info depending on the library (so far only item types). > > Flag to add an empty option to the library list. > >+=item do_not_respect_visibility >+ >+If set the visibility defined in the framework will not be used to hide the input. >+Used by the batch item modification (for LOST for instance). >+ > =back > > =cut >@@ -459,15 +468,16 @@ Flag to add an empty option to the library list. > sub edit_form { > my ( $self, $params ) = @_; > >- my $branchcode = $params->{branchcode}; >- my $restricted_edition = $params->{restricted_editition}; >- my $subfields_to_prefill = $params->{subfields_to_prefill} || []; >- my $subfields_to_allow = $params->{subfields_to_allow} || []; >+ my $branchcode = $params->{branchcode}; >+ my $restricted_edition = $params->{restricted_editition}; >+ my $subfields_to_prefill = $params->{subfields_to_prefill} || []; >+ my $subfields_to_allow = $params->{subfields_to_allow} || []; > my $ignore_not_allowed_subfields = $params->{ignore_not_allowed_subfields}; >- my $kohafields_to_ignore = $params->{kohafields_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 $kohafields_to_ignore = $params->{kohafields_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 $do_not_respect_visibility = $params->{do_not_respect_visibility} || 0; > > my $libraries = > Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed; >@@ -551,7 +561,8 @@ sub edit_form { > prefill_with_default_values => $prefill_with_default_values, > branch_limit => $branch_limit, > default_branches_empty => $default_branches_empty, >- readonly => $readonly >+ readonly => $readonly, >+ do_not_respect_visibility => $do_not_respect_visibility, > } > ); > push @subfields, $subfield_data; >diff --git a/t/db_dependent/Koha/UI/Form/Builder/Item.t b/t/db_dependent/Koha/UI/Form/Builder/Item.t >index 386241c637f..a3c47dccf1c 100755 >--- a/t/db_dependent/Koha/UI/Form/Builder/Item.t >+++ b/t/db_dependent/Koha/UI/Form/Builder/Item.t >@@ -16,7 +16,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 6; >+use Test::More tests => 7; > use utf8; > > use List::MoreUtils qw( uniq ); >@@ -45,7 +45,7 @@ $cache->clear_from_cache("MarcSubfieldStructure-"); > setup_mss(); > > subtest 'authorised values' => sub { >- #plan tests => 1; >+ plan tests => 5; > > my $biblio = $builder->build_sample_biblio({ value => {frameworkcode => ''}}); > my $subfields = >@@ -258,6 +258,41 @@ subtest 'subfields_to_allow & ignore_not_allowed_subfields' => sub { > is( $subfield, undef, "subfield that is not in the allow list is not returned" ); > }; > >+subtest 'do_not_respect_visilibity' => sub { >+ plan tests => 4; >+ >+ my ( $tag_lost, $subtag_lost ) = C4::Biblio::GetMarcFromKohaField("items.itemlost"); >+ >+ my $m = Koha::MarcSubfieldStructures->find( >+ { >+ frameworkcode => '', >+ tagfield => $tag_lost, >+ tagsubfield => $subtag_lost, >+ >+ } >+ ); >+ >+ is( $m->hidden, -5, "Ensure that hidden for items.itemlost is set to -5" ); >+ >+ my $biblio = >+ $builder->build_sample_biblio( { value => { frameworkcode => '' } } ); >+ my $subfields = >+ Koha::UI::Form::Builder::Item->new( >+ { biblionumber => $biblio->biblionumber } )->edit_form; >+ >+ my ($subfield) = grep { $_->{kohafield} eq 'items.itemlost' } @$subfields; >+ is( $subfield->{visibility}, 'display:none;', 'itemlost is flagged as hidden if set at framework level' ); >+ >+ $subfields = >+ Koha::UI::Form::Builder::Item->new( >+ { biblionumber => $biblio->biblionumber } ) >+ ->edit_form( { do_not_respect_visibility => 1 } ); >+ >+ ($subfield) = grep { $_->{kohafield} eq 'items.itemlost' } @$subfields; >+ is( $subfield->{visibility}, undef, 'itemlost is not flagged as hidden even if set at framework level - do_not_respect_visibility is passed' ); >+ is( ref($subfield->{marc_value}->{values}), 'ARRAY', 'Values for LOST must have been filled' ) >+}; >+ > > $cache->clear_from_cache("MarcStructure-0-"); > $cache->clear_from_cache("MarcStructure-1-"); >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index 81745c3e6f3..4e634f00da3 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -281,6 +281,7 @@ if ($op eq "show"){ > kohafields_to_ignore => ['items.barcode'], > prefill_with_default_values => $use_default_values, > default_branches_empty => 1, >+ do_not_respect_visibility => 1, > } > ); > >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29331
: 126956