From cecdc193696c6c91560128da5954681aa7ce610f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Wed, 6 Apr 2011 10:14:29 +0200 Subject: [PATCH] Bug 4374 Improve biblio data entry form regarding hidden/mandatory fields MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Biblio framework has 3 entry points controlling if input box are displayed by default in data entry form: - 'mandatory' flag at field level - 'mandatory' flag at subfield level - 'hidden' flag at subfield level It doesn't work as it should (?): - All subfields are expanded (shown) if their field is mandatory - A subfield containing anything is always expanded whatever it contains - A mandatory subfield is always expanded - An hidden subfield isn't expanded. Default framework having 0 in all marc_subfield_structure.hidden, by default all subfields will be expanded. TO BE INTEGRATED IN RELEASE NOTES: Koha sysadmin should have to edit its frameworks to add hidden=1 in appropriate subfields. Signed-off-by: Stéphane Delaune Signed-off-by: Chris Cormack --- cataloguing/addbiblio.pl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 038878f399..4bb2012fa0 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -341,14 +341,14 @@ sub create_input { if(exists $mandatory_z3950->{$tag.$subfield}){ $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield}; } - # decide if the subfield must be expanded (visible) by default or not - # if it is mandatory, then expand. If it is hidden explicitly by the hidden flag, hidden anyway + # Subfield is hidden depending of hidden and mandatory flag, and is always + # shown if it contains anything or if its field is mandatory. + my $tdef = $tagslib->{$tag}; $subfield_data{visibility} = "display:none;" - if ( ($tagslib->{$tag}->{$subfield}->{hidden} % 2 == 1) and $value ne '' - or ($value eq '' and !$tagslib->{$tag}->{$subfield}->{mandatory}) - ); - # always expand all subfields of a mandatory field - $subfield_data{visibility} = "" if $tagslib->{$tag}->{mandatory}; + if $tdef->{$subfield}->{hidden} % 2 == 1 && + $value eq '' && + !$tdef->{$subfield}->{mandatory} && + !$tdef->{mandatory}; # it's an authorised field if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) { $subfield_data{marc_value} = -- 2.39.5