add required IDL flag and validation regexp support
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 2 Jun 2010 02:43:32 +0000 (02:43 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 2 Jun 2010 02:43:32 +0000 (02:43 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16553 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/fm_IDL.xml
Open-ILS/examples/oils_obj.xsd
Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm
Open-ILS/web/js/dojo/fieldmapper/IDL.js

index db79806..f9fb10c 100644 (file)
@@ -3351,7 +3351,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Name" name="name" reporter:datatype="text" oils_persist:i18n="true"/>
                        <field reporter:label="Organizational Unit Type" name="ou_type" reporter:datatype="link"/>
                        <field reporter:label="Parent Organizational Unit" name="parent_ou" reporter:datatype="link"/>
-                       <field reporter:label="Short (Policy) Name" name="shortname" reporter:datatype="text"/>
+                       <field reporter:label="Short (Policy) Name" name="shortname" reporter:datatype="text" oils_obj:required="true" oils_obj:validate="^[A-Z]+$"/>
                        <field reporter:label="Email Address" name="email" reporter:datatype="text"/>
                        <field reporter:label="Phone Number" name="phone" reporter:datatype="text"/>
                        <field reporter:label="OPAC Visible" name="opac_visible" reporter:datatype="bool"/>
index f41ce8c..6061e56 100644 (file)
@@ -28,6 +28,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  attributeFormDefault="unqualified"
 >
 
+<xs:attribute name="required"/>
+<xs:attribute name="validate"/>
 <xs:attribute name="array_position" type="xs:nonNegativeInteger"/>
 <xs:attribute name="fieldmapper"/>
 
index ea782f7..77a1080 100644 (file)
@@ -79,6 +79,8 @@ sub load_fields {
                        
                        my $name     = get_attribute( $attribute_list, 'name' );
                        next if( $name eq 'isnew' || $name eq 'ischanged' || $name eq 'isdeleted' );
+                       my $required  = get_attribute( $attribute_list, 'oils_obj:required' );
+                       my $validate  = get_attribute( $attribute_list, 'oils_obj:validate' );
                        my $virtual  = get_attribute( $attribute_list, 'oils_persist:virtual' );
                        if( ! defined( $virtual ) ) {
                                $virtual = "false";
@@ -87,9 +89,12 @@ sub load_fields {
 
                        $$fieldmap{$fm}{fields}{ $name } =
                                { virtual => ( $virtual eq 'true' ) ? 1 : 0,
+                                 required => ( $required eq 'true' ) ? 1 : 0,
                                  position => $array_position,
                                };
 
+                       $$fieldmap{$fm}{fields}{ $name }{validate} = qr/$valudate/ if (defined($validate));
+
                        # The selector attribute, if present at all, attaches to only one
                        # of the fields in a given class.  So if we see it, we store it at
                        # the level of the enclosing class.
index b87e572..b0ee5ea 100644 (file)
@@ -76,10 +76,14 @@ if(!dojo._hasResource["fieldmapper.IDL"]) {
                     label   : fieldmapper._getAttributeNS(node,this.NS_REPORTS, 'label'),
                     restrict_primary   : fieldmapper._getAttributeNS(node,this.NS_PERSIST, 'restrict_primary'),
                     virtual : (fieldmapper._getAttributeNS(node,this.NS_PERSIST, 'virtual') == 'true'),
+                    required : (fieldmapper._getAttributeNS(node,this.NS_OBJ, 'required') == 'true'),
                     pkey    : fieldmapper._getAttributeNS(fields,this.NS_PERSIST, 'primary'),
                     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 permacrud = node.getElementsByTagName('permacrud')[0];
                 if(permacrud) {
                     var actions = ['create', 'retrieve', 'update', 'delete'];