[open-ils-commits] r16557 - trunk/Open-ILS/web/js/dojo/fieldmapper (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Jun 2 11:11:55 EDT 2010
Author: miker
Date: 2010-06-02 11:11:52 -0400 (Wed, 02 Jun 2010)
New Revision: 16557
Modified:
trunk/Open-ILS/web/js/dojo/fieldmapper/Fieldmapper.js
trunk/Open-ILS/web/js/dojo/fieldmapper/IDL.js
Log:
add class/instance methods for checking required-ness and validity of an object field in JS FM implementation
Modified: trunk/Open-ILS/web/js/dojo/fieldmapper/Fieldmapper.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/fieldmapper/Fieldmapper.js 2010-06-02 14:55:23 UTC (rev 16556)
+++ trunk/Open-ILS/web/js/dojo/fieldmapper/Fieldmapper.js 2010-06-02 15:11:52 UTC (rev 16557)
@@ -69,8 +69,27 @@
}
}
return obj;
- }
+ },
+ RequiredField : function (f) {
+ if (!f) return;
+ if (fieldmapper.IDL && fieldmapper.IDL.loaded)
+ return this.Structure.fields[f].required;
+ return;
+ },
+
+ ValidateField : function (f) {
+ if (!f) return;
+ if (fieldmapper.IDL && fieldmapper.IDL.loaded) {
+ if (this.Structure.fields[f] && this.Structure.fields[f].validate) {
+ return this.Structure.fields[f].validate.test(this[f]());
+ }
+ return true;
+ }
+ return;
+ }
+
+
/*
isnew : function(n) { if(arguments.length == 1) this.a[0] =n; return this.a[0]; },
Modified: trunk/Open-ILS/web/js/dojo/fieldmapper/IDL.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/fieldmapper/IDL.js 2010-06-02 14:55:23 UTC (rev 16556)
+++ trunk/Open-ILS/web/js/dojo/fieldmapper/IDL.js 2010-06-02 15:11:52 UTC (rev 16557)
@@ -81,8 +81,8 @@
pkey_sequence : fieldmapper._getAttributeNS(fields,this.NS_PERSIST, 'sequence')
};
- var valid = fieldmapper._getAttributeNS(node,this.NS_OBJ, 'validate');
- if (valid) obj.validate = new RegExp( valid );
+ var valid = fieldmapper._getAttributeNS(node,this.NS_OBJ, 'validate');
+ if (valid) obj.validate = new RegExp( valid.replace(/\\/g, '\\\\') );
var permacrud = node.getElementsByTagName('permacrud')[0];
if(permacrud) {
More information about the open-ils-commits
mailing list