[Koha-patches] [PATCH] bug 2563: could not input into marc 008, fields 7-10 and 11-14

John Beppu john.beppu at liblime.com
Wed Nov 5 17:51:32 CET 2008


You actually *could* input data into those fields, but it wasn't
immediately obvious, because the field size was "4" and the
value was "    ".  You couldn't type anything in until you
backspaced over the spaces that were there by default.

UPDATE 2008-11-05:  Make absolutely sure that those values
are 4 chars long (via JavaScript)
---
 cataloguing/value_builder/marc21_field_008.pl      |    4 +++
 .../value_builder/marc21_field_008.tmpl            |   24 +++++++++++++++++--
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/cataloguing/value_builder/marc21_field_008.pl b/cataloguing/value_builder/marc21_field_008.pl
index 02af66c..793f013 100755
--- a/cataloguing/value_builder/marc21_field_008.pl
+++ b/cataloguing/value_builder/marc21_field_008.pl
@@ -111,6 +111,10 @@ sub plugin {
 	my $f38 = substr($result,38,1);
 	my $f39 = substr($result,39,1);
 
+	# bug 2563
+	$f710  = "" if ($f710  =~ /^\s*$/);
+	$f1114 = "" if ($f1114 =~ /^\s*$/);
+
 if ((!$f1) ||($f1 =~ m/ /)){
 	$f1=$dateentered;
 }
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tmpl
index 302fd60..276fd8f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tmpl
@@ -607,15 +607,33 @@
 </table>
 </form>
 <script>
+
+// Pad the string with spaces so that it is 4 characters long.
+// Also, truncate strings that are longer than 4 characters.
+function pad4(s) {
+	var pad = "";
+	if (s.length < 4) {
+		var padLength = 4 - s.length;
+		for (var i = 0; i < 4 - s.length; i++) {
+			pad += " ";
+		}
+		s += pad;
+	} else {
+		s = s.substring(0, 4);
+	}
+	return s;
+}
+
 function report() {
             var doc   = opener.document; 
             var field = doc.getElementById("<!-- TMPL_VAR NAME='index'-->");
-        
             field.value = 
 			document.f_pop.f1.value+
 			document.f_pop.f6.value+
-			document.f_pop.f710.value+
-			document.f_pop.f1114.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.f1821.value+
 			document.f_pop.f22.value+
-- 
1.6.0.3




More information about the Koha-patches mailing list