From 6508635894db20a6ff30e939b80959e0e4b7b0fb Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 4 Feb 2009 21:28:53 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.open-ils.org/ILS/trunk@12068 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/widget/EditPane.js | 34 +++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/EditPane.js b/Open-ILS/web/js/dojo/openils/widget/EditPane.js index b92c951321..3c4e712e35 100644 --- a/Open-ILS/web/js/dojo/openils/widget/EditPane.js +++ b/Open-ILS/web/js/dojo/openils/widget/EditPane.js @@ -12,12 +12,12 @@ if(!dojo._hasResource['openils.widget.EditPane']) { [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 @@ if(!dojo._hasResource['openils.widget.EditPane']) { }); widget.build(); this.fieldList.push({name:field.name, widget:widget}); + this.applySaveOnEnter(widget); } if(!this.hideActionButtons) this.buildActionButtons(tbody); @@ -67,6 +68,16 @@ if(!dojo._hasResource['openils.widget.EditPane']) { 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 @@ if(!dojo._hasResource['openils.widget.EditPane']) { 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 @@ if(!dojo._hasResource['openils.widget.EditPane']) { } }, + 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); } -- 2.11.0