From 04845b11929b47bbc455db751911699040195d31 Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 2 Jun 2010 02:43:32 +0000 Subject: [PATCH] add required IDL flag and validation regexp support git-svn-id: svn://svn.open-ils.org/ILS/trunk@16553 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/fm_IDL.xml | 2 +- Open-ILS/examples/oils_obj.xsd | 2 ++ Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm | 5 +++++ Open-ILS/web/js/dojo/fieldmapper/IDL.js | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index db798065dc..f9fb10c452 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3351,7 +3351,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + diff --git a/Open-ILS/examples/oils_obj.xsd b/Open-ILS/examples/oils_obj.xsd index f41ce8cc99..6061e5676a 100644 --- a/Open-ILS/examples/oils_obj.xsd +++ b/Open-ILS/examples/oils_obj.xsd @@ -28,6 +28,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA attributeFormDefault="unqualified" > + + diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm b/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm index ea782f7075..77a1080b6c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm @@ -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. diff --git a/Open-ILS/web/js/dojo/fieldmapper/IDL.js b/Open-ILS/web/js/dojo/fieldmapper/IDL.js index b87e572672..b0ee5ea3d4 100644 --- a/Open-ILS/web/js/dojo/fieldmapper/IDL.js +++ b/Open-ILS/web/js/dojo/fieldmapper/IDL.js @@ -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']; -- 2.11.0