From cbdab5dd499cad1edd8908b1c392b54fb8b1fbb0 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 12 May 2016 11:20:44 +0200 Subject: [PATCH] Bug 13438: Fix report function in normarc_field_008 js Content-Type: text/plain; charset=utf-8 The report function did not deal well with undefined fields and did not respect the length of all elements. NOTE: This is a quick fix for something that is currently broken. A next (larger) step would be to bring it back to the approach in the marc21 counterpart. Test plan: Make sure that normarc_field_008.pl is connected to your field 008. Click tag editor for 008, save some values and go back to tag editor. Test different material types in the tag editor. --- .../cataloguing/value_builder/normarc_field_008.tt | 70 ++++++++++---------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/normarc_field_008.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/normarc_field_008.tt index 14101b1..05313f2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/normarc_field_008.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/normarc_field_008.tt @@ -4481,40 +4481,42 @@ function pad4(s) { } function report() { - var doc = opener.document; - var field = doc.getElementById("[% index %]"); - field.value = - document.f_pop.f1.value+ - document.f_pop.f6.value+ - // bug 2563 { - ( document.f_pop.f710.value.match(/^\s*$/) ? " " : pad4(document.f_pop.f710.value) )+ - ( document.f_pop.f1114.value.match(/^\s*$/) ? " " : pad4(document.f_pop.f1114.value) )+ - // } - document.f_pop.f1517.value+ - document.f_pop.f18.value+ - document.f_pop.f19.value+ - document.f_pop.f20.value+ - document.f_pop.f21.value+ - document.f_pop.f22.value+ - document.f_pop.f23.value+ - document.f_pop.f24.value+ - document.f_pop.f25.value+ - document.f_pop.f26.value+ - document.f_pop.f27.value+ - document.f_pop.f28.value+ - document.f_pop.f29.value+ - document.f_pop.f30.value+ - document.f_pop.f31.value+ - document.f_pop.f32.value+ - document.f_pop.f33.value+ - document.f_pop.f34.value+ - document.f_pop.f3537.value+ - document.f_pop.f38.value+ - document.f_pop.f39.value; - self.close(); - return false; - } - //]]> + var doc = opener.document; + var field = doc.getElementById("[% index %]"); + + document.f_pop.f710.value = document.f_pop.f710.value.match(/^\s*$/)? " ": pad4(document.f_pop.f710.value); + document.f_pop.f1114.value = document.f_pop.f1114.value.match(/^\s*$/)? " ": pad4(document.f_pop.f1114.value); + + var str = ''; + var loopfields = [ 'f1', 'f6', 'f710', 'f1114', 'f1517', 'f18', 'f19', + 'f20', 'f21', 'f22', 'f23', 'f24', 'f25', 'f26', 'f27', 'f28', 'f29', + 'f30', 'f31', 'f32', 'f33', 'f34', 'f3537', 'f38', 'f39' ]; + for( var i=0; i3 ) { + len = 1 + parseInt(str.substr(3,2)) - parseInt(str.substr(1,2)); + } + + if( document.f_pop.elements.namedItem(str) ) { + ret = document.getElementsByName(str)[0].value + ' '; + } else { + ret = ' '; + } + return ret.substr(0, len); +} +//]]> [% INCLUDE 'popup-bottom.inc' %] -- 1.7.10.4