[open-ils-commits] r12063 - trunk/Open-ILS/web/js/dojo/openils/widget
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Feb 4 11:43:05 EST 2009
Author: erickson
Date: 2009-02-04 11:43:03 -0500 (Wed, 04 Feb 2009)
New Revision: 12063
Modified:
trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
Log:
auto-grid now has the ability to pop up an edit dialog for the given fieldmapper object
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js 2009-02-04 16:12:52 UTC (rev 12062)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js 2009-02-04 16:43:03 UTC (rev 12063)
@@ -3,12 +3,21 @@
dojo.require('dojox.grid.DataGrid');
dojo.require('openils.widget.AutoWidget');
dojo.require('openils.widget.AutoFieldWidget');
+ dojo.require('openils.widget.EditDialog');
dojo.require('openils.Util');
dojo.declare(
'openils.widget.AutoGrid',
[dojox.grid.DataGrid, openils.widget.AutoWidget],
{
+
+ /* if true, pop up an edit dialog when user hits Enter on a give row */
+ editOnEnter : false,
+
+ /* maps dojo store items to fieldmapper objects, since the
+ * grid may not have access to all fm objects */
+ storeItemObjectMapper : null,
+
startup : function() {
this.inherited(arguments);
this.initAutoEnv();
@@ -27,7 +36,43 @@
}
this.setStructure([{cells: [fields]}]);
this.setStore(this.buildAutoStore());
+ if(this.editOnEnter)
+ this._applyEditOnEnter();
},
+
+ /* capture keydown and launch edit dialog on enter */
+ _applyEditOnEnter : function() {
+ dojo.connect(this, 'onKeyDown',
+ function(e) {
+ if(e.keyCode == dojo.keys.ENTER) {
+ this.selection.deselectAll();
+ this.selection.select(this.focus.rowIndex);
+ this._drawEditDialog(this.selection.getFirstSelected());
+ }
+ }
+ );
+ },
+
+ _drawEditDialog : function(storeItem) {
+ var grid = this;
+ var fmObject = this.storeItemObjectMapper(storeItem);
+ var idents = grid.store.getIdentityAttributes();
+ var dialog = new openils.widget.EditDialog({
+ fmObject:fmObject,
+ onPostApply : function() {
+ // update the grid store
+ for(var i in fmObject._fields) {
+ var field = fmObject._fields[i];
+ if(idents.filter(function(j){return (j == field)})[0])
+ continue; // don't try to edit an identifier field
+ grid.store.setValue(storeItem, field, fmObject[field]());
+ }
+ }
+ });
+ dialog.editPane.fieldOrder = this.fieldOrder;
+ dialog.startup();
+ dialog.show();
+ }
}
);
openils.widget.AutoGrid.markupFactory = dojox.grid.DataGrid.markupFactory;
More information about the open-ils-commits
mailing list