[open-ils-commits] r10321 -
trunk/Open-ILS/xul/staff_client/server/cat
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Aug 10 14:18:33 EDT 2008
Author: miker
Date: 2008-08-10 14:18:30 -0400 (Sun, 10 Aug 2008)
New Revision: 10321
Modified:
trunk/Open-ILS/xul/staff_client/server/cat/marcedit.js
trunk/Open-ILS/xul/staff_client/server/cat/marcedit.xul
Log:
validate all controlled subfields in a tag
Modified: trunk/Open-ILS/xul/staff_client/server/cat/marcedit.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/marcedit.js 2008-08-10 05:34:55 UTC (rev 10320)
+++ trunk/Open-ILS/xul/staff_client/server/cat/marcedit.js 2008-08-10 18:18:30 UTC (rev 10321)
@@ -1893,35 +1893,44 @@
var tag = row.firstChild;
if (!control_map[tag.value]) continue
+ button.setAttribute('label', label + ' - ' + tag.value);
var ind1 = tag.nextSibling;
var ind2 = ind1.nextSibling;
var subfields = ind2.nextSibling.childNodes;
+ var tags = {};
+
for (var j = 0; j < subfields.length; j++) {
var sf = subfields[j];
+ var sf_code = sf.childNodes[1].value;
+ var sf_value = sf.childNodes[1].value;
- if (!control_map[tag.value][sf.childNodes[1].value]) continue;
+ if (!control_map[tag.value][sf_code]) continue;
- button.setAttribute('label', label + ' - ' + tag.value + sf.childNodes[1].value);
-
var found = 0;
- for (var k in control_map[tag.value][sf.childNodes[1].value]) {
- var x = searchAuthority(sf.childNodes[2].value, k, control_map[tag.value][sf.childNodes[1].value][k], 1);
- var res = new XML( x.responseText );
-
- if (res.gw::payload.gw::array.gw::string.length()) {
- found = 1;
- break;
- }
+ for (var a_tag in control_map[tag.value][sf_code]) {
+ if (!tags[a_tag]) tags[a_tag] = [];
+ tags[a_tag].push({ term : sf_value, subfield : sf_code });
}
- if (!found) {
+ }
+
+ for (var val_tag in tags) {
+ var auth_data = validateBibField( [val_tag], tags[val_tag]);
+ var res = new XML( auth_data.responseText );
+ found = parseInt( res.gw::payload.gw::array.gw::string );
+ if (found) break;
+ }
+
+ for (var j = 0; j < subfields.length; j++) {
+ var sf = subfields[j];
+ if (!found) {
sf.childNodes[2].inputField.style.color = 'red';
} else {
sf.childNodes[2].inputField.style.color = 'black';
}
- }
+ }
}
button.setAttribute('label', label);
@@ -1930,6 +1939,19 @@
}
+function validateBibField (tags, searches) {
+ var url = "/gateway?input_format=json&format=xml&service=open-ils.search&method=open-ils.search.authority.validate.tag";
+ url += '¶m="tags"¶m=' + js2JSON(tags);
+ url += '¶m="searches"¶m=' + js2JSON(searches);
+
+
+ var req = new XMLHttpRequest();
+ req.open('GET',url,false);
+ req.send(null);
+
+ return req;
+
+}
function searchAuthority (term, tag, sf, limit) {
var url = "/gateway?input_format=json&format=xml&service=open-ils.search&method=open-ils.search.authority.fts";
url += '¶m="term"¶m="' + term + '"';
Modified: trunk/Open-ILS/xul/staff_client/server/cat/marcedit.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/marcedit.xul 2008-08-10 05:34:55 UTC (rev 10320)
+++ trunk/Open-ILS/xul/staff_client/server/cat/marcedit.xul 2008-08-10 18:18:30 UTC (rev 10321)
@@ -13,6 +13,7 @@
<script src="marcedit.js" type="application/x-javascript; e4x=1"/>
<script src="/opac/common/js/CGI.js" type="application/x-javascript; e4x=1"/>
+<script src="/opac/common/js/JSON_v1.js" type="application/x-javascript; e4x=1"/>
<messagecatalog id="catStrings" src="/xul/server/locale/<!--#echo var='locale'-->/cat.properties" />
<messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties" />
More information about the open-ils-commits
mailing list