Bug 17072: 006 not filling in with existing values
authorJacek Ablewicz <abl@biblos.pk.edu.pl>
Thu, 1 Sep 2016 16:13:50 +0000 (18:13 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Thu, 8 Sep 2016 11:58:39 +0000 (11:58 +0000)
When you use the 006 builder to view the existing values in the 006
tag, Koha is not pulling these existing values into the builder
window. Instead, Koha appears to be using defaults.

To reproduce:

1. Open a record in the editor
2. Switch from BKS to another material type.
3. Change as many settings as possible.
4. Close plugin.
5. Reopen plugin - notice your selections are not shown.

Trivial patch, heavilly inspired by Bug 9093.

To test:

1. Apply patch
2. Ensure that issue described above is no longer reproductible

Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
Works as advertised

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
cataloguing/value_builder/marc21_field_006.pl
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.tt

index a773d9c..aeb5df1 100755 (executable)
@@ -66,6 +66,17 @@ my $launcher = sub {
         }
     );
     $result = "a|||||r|||| 00| 0 " unless $result;
+    my $material_form_mapping = {
+        a => 'BKS', t => 'BKS',
+        c => 'MU', d => 'MU', i => 'MU', j => 'MU',
+        e => 'MP', f => 'MP',
+        g => 'VM', k => 'VM', o => 'VM', r => 'VM',
+        m => 'CF',
+        p => 'MX',
+        s => 'CR',
+    };
+    my $material_code = substr(($result // ' '), 0, 1);
+    my $material_configuration = $material_form_mapping->{$material_code};
 
     my $errorXml = '';
     # Check if the xml, xsd exists and is validated
@@ -86,8 +97,9 @@ my $launcher = sub {
             index => $index,
             result => $result,
             errorXml => $errorXml,
+            material_configuration => $material_configuration,
     );
     output_html_with_http_headers $input, $cookie, $template->output;
 };
 
-return { builder => $builder, launcher => $launcher };
\ No newline at end of file
+return { builder => $builder, launcher => $launcher };
index 52acf80..2124634 100644 (file)
@@ -17,6 +17,9 @@
         h4_result = document.getElementById("h4_result");
         tr_result = document.getElementById("tr_result");
         objXmlControlField = new xmlControlField('[% tagfield %]', 'f_pop', document.getElementById('material_type'), document.getElementById('table_material_types'), 'h4_result', 'tr_result', '', '[% themelang %]', '[% marcflavour %]');
+        [% IF ( material_configuration ) %]
+        objXmlControlField.idMaterial = "[% material_configuration %]";
+        [% END %]
         objXmlControlField.loadXmlValues();
         renderResult(tr_result, (form.result.value != "")?form.result.value:returnValueParam("result"));
         [% END %]