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 <chrisc@catalyst.net.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Magnus Enger 2013-10-07 15:14:08 +02:00 committed by Galen Charlton
parent 53c4129027
commit 3ec4a02418
3 changed files with 5 additions and 4 deletions

View file

@ -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;

View file

@ -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 %]

View file

@ -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 %]