bug 2563: could not input into marc 008, fields 7-10 and 11-14
authorJohn Beppu <john.beppu@liblime.com>
Wed, 5 Nov 2008 16:51:32 +0000 (10:51 -0600)
committerGalen Charlton <galen.charlton@liblime.com>
Thu, 6 Nov 2008 21:53:24 +0000 (15:53 -0600)
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)

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
cataloguing/value_builder/marc21_field_008.pl
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_008.tmpl

index 02af66c..793f013 100755 (executable)
@@ -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;
 }
index 302fd60..276fd8f 100644 (file)
 </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+