From 3ec4a02418a9c3372c590b8eb614e8c6466ff45e Mon Sep 17 00:00:00 2001 From: Magnus Enger Date: Mon, 7 Oct 2013 15:14:08 +0200 Subject: [PATCH] Bug 11004: Make xmlControlfield.js use the marcflavour syspref to look for XML files Currently, xmlControlfield.js is hard coded to look for XML files for MARC21: url: this.themelang + "/data/marc21_field_" + this.tagfield + ".xml", This patch makes this code use the value from the marcflavour syspref, as a preparation for making the NORMARC value builders use the XML technique employed by the MARC21 value builders for 006 and 008. To test: - Make sure you have a MARC21 installation - Set marcflavour = NORMARC - Go to Cataloguing and start a new record with the default framework - Open the value builders for 006 and 008 and observe that they still work, showing the coded values for MARC21 - Apply this patch - Check the value builders for 006 and 008 and observe that you get a truncated view with an empty "Select a type of material" dropdown - Use e.g. the Net console in Firebug to observe requests to http://localhost/intranet-tmpl/prog/en/data/normarc_field_008.xml that result in a 404 status - Set marcflavour = MARC21 - Observe that the value builders for 006 and 008 are now fully working - 006 and 008 should be the only value builders affected by this change, since they are the only ones using xmlControlfield.js, but please also verify that other value builders are still working as expected Signed-off-by: Chris Cormack Signed-off-by: Jonathan Druart Signed-off-by: Galen Charlton --- koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js | 5 +++-- .../en/modules/cataloguing/value_builder/marc21_field_006.tt | 2 +- .../en/modules/cataloguing/value_builder/marc21_field_008.tt | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js b/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js index c02e700db2..89e8e9780d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js @@ -168,7 +168,7 @@ function changeH4Result(form, h4_result, tr_result, pos, value) (function() { - xmlControlField = function(tagfield, form_id, select, table, h4_result, tr_result, idMaterial, themelang) + xmlControlField = function(tagfield, form_id, select, table, h4_result, tr_result, idMaterial, themelang, marcflavour) { this.tagfield = tagfield; this.idMaterial = idMaterial; @@ -179,6 +179,7 @@ function changeH4Result(form, h4_result, tr_result, pos, value) this.h4_result = h4_result; this.tr_result = tr_result; this.themelang = themelang; + this.marcflavour = marcflavour.toLowerCase(); };//xmlControlField @@ -205,7 +206,7 @@ function changeH4Result(form, h4_result, tr_result, pos, value) { this.xmlDoc = $.ajax({ type: "GET", - url: this.themelang + "/data/marc21_field_" + this.tagfield + ".xml", + url: this.themelang + "/data/" + this.marcflavour + "_field_" + this.tagfield + ".xml", dataType: "xml", async: false }).responseXML; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.tt index 2824577541..4a2263aedb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_006.tt @@ -16,7 +16,7 @@ var form = document.f_pop; 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 %]'); + objXmlControlField = new xmlControlField('[% tagfield %]', 'f_pop', document.getElementById('material_type'), document.getElementById('table_material_types'), 'h4_result', 'tr_result', '', '[% themelang %]', '[% marcflavour %]'); objXmlControlField.loadXmlValues(); renderResult(tr_result, (form.result.value != "")?form.result.value:returnValueParam("result")); [% END %] 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 b2929913bb..6e5acb9a72 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 @@ -16,7 +16,7 @@ var form = document.f_pop; 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 %]'); + objXmlControlField = new xmlControlField('[% tagfield %]', 'f_pop', document.getElementById('material_type'), document.getElementById('table_material_types'), 'h4_result', 'tr_result', '', '[% themelang %]', '[% marcflavour %]'); objXmlControlField.loadXmlValues(); renderResult(tr_result, (form.result.value != "")?form.result.value:returnValueParam("result")); [% END %] -- 2.39.5