[open-ils-commits] r12068 - trunk/Open-ILS/web/js/dojo/openils/widget

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Feb 4 16:28:57 EST 2009


Author: erickson
Date: 2009-02-04 16:28:53 -0500 (Wed, 04 Feb 2009)
New Revision: 12068

Modified:
   trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
Log:
fixed bug where subsequent dialogs were appending to the the class-level fieldList array.  can now hit Enter to save instead of having to click Save

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2009-02-04 21:27:44 UTC (rev 12067)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2009-02-04 21:28:53 UTC (rev 12068)
@@ -12,12 +12,12 @@
         [dijit.layout.ContentPane, openils.widget.AutoWidget],
         {
             mode : 'update',
-            fieldList : [], // holds the field name + associated widget
             onPostApply : null, // apply callback
             onCancel : null, // cancel callback
             hideActionButtons : false,
 
             constructor : function(args) {
+                this.fieldList = [];
                 for(var k in args)
                     this[k] = args[k];
             },
@@ -60,6 +60,7 @@
                     });
                     widget.build();
                     this.fieldList.push({name:field.name, widget:widget});
+                    this.applySaveOnEnter(widget);
                 }
                 if(!this.hideActionButtons)
                     this.buildActionButtons(tbody);
@@ -67,6 +68,16 @@
                 openils.Util.addCSSClass(table, 'oils-fm-edit-dialog');
             },
 
+            applySaveOnEnter : function(widget) {
+                var self = this;
+                dojo.connect(this, 'onKeyDown',
+                    function(e) {
+                        if(e.keyCode == dojo.keys.ENTER) 
+                            self.performAutoEditAction();
+                    }
+                );
+            },
+
             buildActionButtons : function(tbody) {
                 var row = document.createElement('tr');
                 var cancelTd = document.createElement('td');
@@ -83,14 +94,7 @@
 
                 new dijit.form.Button({
                     label:'Save',  // XXX
-                    onClick: function() {
-                        self.performEditAction({
-                            oncomplete:function() {
-                                if(self.onPostApply)
-                                    self.onPostApply();
-                            }
-                        });
-                    }
+                    onClick: function() {self.performAutoEditAction();}
                 }, applyTd);
             },
 
@@ -105,12 +109,22 @@
                 }
             },
 
+            performAutoEditAction : function() {
+                var self = this;
+                self.performEditAction({
+                    oncomplete:function() {
+                        if(self.onPostApply)
+                            self.onPostApply();
+                    }
+                });
+            },
+
             performEditAction : function(opts) {
                 var pcrud = new openils.PermaCrud();
                 var fields = this.getFields();
                 if(this.mode == 'create')
                     this.fmObject = new fieldmapper[this.fmClass]();
-                for(var idx in fields) 
+                for(var idx in fields)  
                     this.fmObject[fields[idx]](this.getFieldValue(fields[idx]));
                 pcrud[this.mode](this.fmObject, opts);
             }



More information about the open-ils-commits mailing list