EditPane.js API repairs
authorBill Erickson <berick@esilibrary.com>
Fri, 20 Jul 2012 15:15:25 +0000 (11:15 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 1 Aug 2012 18:23:28 +0000 (14:23 -0400)
By default, don't throw an exception from EditPane.getFieldValue when a
field is required and the value is null.  Otherwise, external code is
unable to use this method for inspecting the pane.  Make checkRequired
an additional method flag.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/web/js/dojo/openils/widget/EditPane.js

index d7c54b8..887015d 100644 (file)
@@ -222,15 +222,17 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                 }
             },
 
-            getFieldValue : function(field) {
+            getFieldValue : function(field, checkRequired) {
                 for(var i in this.fieldList) {
                     if(field == this.fieldList[i].name) {
                         var val = this.fieldList[i].widget.getFormattedValue();
-                        if (val == null && /* XXX stricter check needed? */
+                        if (checkRequired &&
+                            val == null && /* XXX stricter check needed? */
                             this.fieldList[i].widget.isRequired()) {
                             throw new Error("req");
                         }
                         return val;
+
                     }
                 }
             },
@@ -253,7 +255,7 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                 try {
                     for(var idx in fields) {
                         this.fmObject[fields[idx]](
-                            this.getFieldValue(fields[idx])
+                            this.getFieldValue(fields[idx], true)
                         );
                     }
                 } catch (E) {