teach the IDL about the existence of pkey sequences
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 9 Feb 2009 17:56:19 +0000 (17:56 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 9 Feb 2009 17:56:19 +0000 (17:56 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12117 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/fieldmapper/IDL.js
Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
Open-ILS/web/js/dojo/openils/widget/EditPane.js

index 3a0a3f4..69a1c78 100644 (file)
@@ -50,7 +50,8 @@ if(!dojo._hasResource["fieldmapper.IDL"]) {
                     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];
index 478ba4b..c7ce46a 100644 (file)
@@ -25,11 +25,16 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) {
             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 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) {
         _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);
         },
index 731069a..b6e2384 100644 (file)
@@ -57,6 +57,7 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                     var widget = new openils.widget.AutoFieldWidget({
                         idlField : field, 
                         fmObject : this.fmObject,
+                        fmClass : this.fmClass,
                         parentNode : valSpan,
                         orgLimitPerms : this.limitPerms
                     });
@@ -133,7 +134,7 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                     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);
             }