added support for retrieving the formatted value from the widgets in a pane. all...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 12 Jan 2009 17:33:08 +0000 (17:33 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 12 Jan 2009 17:33:08 +0000 (17:33 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11798 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/widget/AutoWidget.js
Open-ILS/web/js/dojo/openils/widget/EditDialog.js
Open-ILS/web/js/dojo/openils/widget/EditPane.js

index c7834dd..343e957 100644 (file)
@@ -36,6 +36,21 @@ if(!dojo._hasResource['openils.widget.AutoWidget']) {
             }
         },
 
+        /**
+         * Turn the value from the dojo widget into a value oils understands
+         */
+        getFormattedValue : function() {
+            var value = this.widget.attr('value');
+            switch(this.idlField.datatype) {
+                case 'bool':
+                    return (value) ? 't' : 'f'
+                case 'timestamp':
+                    return dojo.date.stamp.toISOString(value);
+                default:
+                    return value;
+            }
+        },
+
         build : function(onload) {
             this.onload = onload;
             this.widgetValue = (this.fmObject) ? this.fmObject[this.idlField.name]() : null;
index 9aa5b4d..9f3c71c 100644 (file)
@@ -16,6 +16,12 @@ if(!dojo._hasResource['openils.widget.EditDialog']) {
             fmObject : null,
             mode : 'update',
             fieldOrder : null, // ordered list of field names, optional.
+            editPane : null,
+
+            constructor : function() {
+                //this.inherited(arguments);
+                this.editPane = new openils.widget.EditPane();
+            },
 
             /**
              * Builds a basic table of key / value pairs.  Keys are IDL display labels.
@@ -23,13 +29,8 @@ if(!dojo._hasResource['openils.widget.EditDialog']) {
              */
             startup : function() {
                 this.inherited(arguments);
-                var pane = new openils.widget.EditPane();
-                pane.mode = this.mode;
-                pane.fmClass = this.fmClass;
-                pane.fmObject = this.fmObject;
-                pane.fieldOrder = this.fieldOrder;
-                pane.startup();
-                this.domNode.appendChild(pane.domNode);
+                this.editPane.startup();
+                this.domNode.appendChild(this.editPane.domNode);
             }
         }
     );
index 595fb9f..f76f6ab 100644 (file)
@@ -15,6 +15,8 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
             fmObject : null,
             mode : 'update',
             fieldOrder : null, // ordered list of field names, optional.
+            fieldList : [], // holds the field name + associated widget
+            sortedFieldList : [], // holds the sorted IDL defs for our fields
 
             /**
              * Builds a basic table of key / value pairs.  Keys are IDL display labels.
@@ -49,17 +51,30 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                     row.appendChild(valTd);
                     tbody.appendChild(row);
 
-                    new openils.widget.AutoWidget({
+                    var widget = new openils.widget.AutoWidget({
                         idlField : field, 
                         fmObject : this.fmObject,
                         parentNode : valTd,
                         orgLimitPerms : this.limitPerms
-                    }).build();
+                    });
+                    widget.build();
+                    this.fieldList.push({name:field.name, widget:widget});
                 }
 
                 openils.Util.addCSSClass(table, 'oils-fm-edit-dialog');
             },
 
+            getFields : function() {
+                return this.fieldList.map(function(a) { return a.name });
+            },
+
+            getFieldValue : function(field) {
+                for(var i in this.fieldList) {
+                    if(field == this.fieldList[i].name)
+                        return this.fieldList[i].widget.getFormattedValue();
+                }
+            },
+
             _buildSortedFieldList : function() {
                 this.sortedFieldList = [];