From 1803e69b2f59b29fc1ea153054944cfecbcec909 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 19 Aug 2021 13:43:48 +0000 Subject: [PATCH] Bug 27461: Right pad with default elements for too short 008s Note that we treat the elements 18-34 as one block of elements, since its subdivision may vary. E.g. if you pass 24 characters to the form, it will use the first 18 chars (until the last complete element) and pad with default elements from position 18-39. Test plan: [1] Go to addbiblio. Make sure that 008 is connected to the plugin. [2] Backspace field 008 a bit, click on the plugin button. [3] Verify that the last elements come from the default. [4] Repeat for a few different lengths. Signed-off-by: Marcel de Rooy Signed-off-by: Phil Ringnalda Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- cataloguing/value_builder/marc21_field_008.pl | 4 +++- .../value_builder/marc21_field_008.tt | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cataloguing/value_builder/marc21_field_008.pl b/cataloguing/value_builder/marc21_field_008.pl index c9d6631465..4e722ffc46 100755 --- a/cataloguing/value_builder/marc21_field_008.pl +++ b/cataloguing/value_builder/marc21_field_008.pl @@ -67,8 +67,9 @@ my $launcher = sub { my ( $params ) = @_; my $input = $params->{cgi}; + my $default008 = biblio_008(); my $index = $input->param('index'); - my $result = $input->param('result') || biblio_008(); + my $result = $input->param('result') || $default008; my $leader = $input->param('leader'); my $material_configuration; @@ -149,6 +150,7 @@ my $launcher = sub { result => $result, errorXml => $errorXml, material_configuration => $material_configuration, + default008 => $default008, ); output_html_with_http_headers $input, $cookie, $template->output; }; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tt index 202dac95eb..b30076da74 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tt @@ -62,6 +62,8 @@ var h4_result; function loadXmlValues(){ + $("#result").val( fix_field_008( $("#result").val() ) ); // fix field before loading elements + [% IF ( errorXml ) %] alert("[% errorXml | html %]"); [% ELSE %] @@ -94,6 +96,20 @@ return false; } + function fix_field_008( myfield ) { + // If field length < 40, append from default008 starting at last complete data element + + var j, position = [ 6, 7, 11, 15, 18, 35, 38, 39, 40 ], defaultvalue = '[% default008 | $raw %]'; + for( j=0; j [% END %] -- 2.39.5