[open-ils-commits] r12117 - in trunk/Open-ILS/web/js/dojo: fieldmapper openils/widget (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Feb 9 12:56:21 EST 2009


Author: erickson
Date: 2009-02-09 12:56:19 -0500 (Mon, 09 Feb 2009)
New Revision: 12117

Modified:
   trunk/Open-ILS/web/js/dojo/fieldmapper/IDL.js
   trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
   trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
Log:
teach the IDL about the existence of pkey sequences

Modified: trunk/Open-ILS/web/js/dojo/fieldmapper/IDL.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/fieldmapper/IDL.js	2009-02-09 15:45:49 UTC (rev 12116)
+++ trunk/Open-ILS/web/js/dojo/fieldmapper/IDL.js	2009-02-09 17:56:19 UTC (rev 12117)
@@ -50,7 +50,8 @@
                     label   : node.getAttributeNS(this.NS_REPORTS, 'label'),
                     restrict_primary   : node.getAttributeNS(this.NS_PERSIST, 'restrict_primary'),
                     virtual : (node.getAttributeNS(this.NS_PERSIST, 'virtual') == 'true'),
-                    pkey    : fields.getAttributeNS(this.NS_PERSIST, 'primary')
+                    pkey    : fields.getAttributeNS(this.NS_PERSIST, 'primary'),
+                    pkey_sequence : fields.getAttributeNS(this.NS_PERSIST, 'sequence')
                 };
 
                 var permacrud = node.getElementsByTagName('permacrud')[0];

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js	2009-02-09 15:45:49 UTC (rev 12116)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js	2009-02-09 17:56:19 UTC (rev 12117)
@@ -25,11 +25,16 @@
             for(var k in args)
                 this[k] = args[k];
 
+            console.log(this.fmClass + ' : ' + this.fmObject + ' : ' + this.idlField);
+
             // find the field description in the IDL if not provided
+            if(this.fmObject) 
+                this.fmClass = this.fmObject.classname;
+            this.fmIDL = fieldmapper.IDL.fmclasses[this.fmClass];
+
             if(!this.idlField) {
-                if(this.fmObject)
-                    this.fmClass = this.fmObject.classname;
-                var fields = fieldmapper.IDL.fmclasses[this.fmClass].fields;
+                this.fmIDL = fieldmapper.IDL.fmclasses[this.fmClass];
+                var fields = this.fmIDL.fields;
                 for(var f in fields) 
                     if(fields[f].name == this.fmField)
                         this.idlField = fields[f];
@@ -166,6 +171,8 @@
         _widgetLoaded : function(value) {
             if(this.widgetValue != null) 
                 this.widget.attr('value', this.widgetValue);
+            if(this.idlField.name == this.fmIDL.pkey && this.fmIDL.pkey_sequence)
+                this.widget.attr('disabled', true); 
             if(this.onload)
                 this.onload(this.widget, self);
         },

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2009-02-09 15:45:49 UTC (rev 12116)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2009-02-09 17:56:19 UTC (rev 12117)
@@ -57,6 +57,7 @@
                     var widget = new openils.widget.AutoFieldWidget({
                         idlField : field, 
                         fmObject : this.fmObject,
+                        fmClass : this.fmClass,
                         parentNode : valSpan,
                         orgLimitPerms : this.limitPerms
                     });
@@ -133,7 +134,7 @@
                     this.fmObject = new fieldmapper[this.fmClass]();
                 for(var idx in fields)  
                     this.fmObject[fields[idx]](this.getFieldValue(fields[idx]));
-                if(this.mode == 'create')
+                if(this.mode == 'create' && this.fmIDL.pkey_sequence)
                     this.fmObject[fieldmapper[this.fmClass].Identifier](null);
                 pcrud[this.mode](this.fmObject, opts);
             }



More information about the open-ils-commits mailing list