[open-ils-commits] r12336 - trunk/Open-ILS/web/js/dojo/openils/widget (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Mar 1 15:36:27 EST 2009


Author: erickson
Date: 2009-03-01 15:36:23 -0500 (Sun, 01 Mar 2009)
New Revision: 12336

Modified:
   trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
Log:
edit/create pane can now be loaded as a inline grid deck-swap in addition to dialog

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-03-01 20:10:55 UTC (rev 12335)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-03-01 20:36:23 UTC (rev 12336)
@@ -107,7 +107,7 @@
                 );
             },
 
-            _makeEditPane : function(storeItem, rowIndex) {
+            _makeEditPane : function(storeItem, rowIndex, onPostSubmit, onCancel) {
                 var grid = this;
                 var fmObject = new fieldmapper[this.fmClass]().fromStoreItem(storeItem);
                 var idents = grid.store.getIdentityAttributes();
@@ -122,11 +122,8 @@
                                 continue; // don't try to edit an identifier field
                             grid.store.setValue(storeItem, field, fmObject[field]());
                         }
-                        pane.destroy();
-
                         if(self.onPostUpdate)
                             self.onPostUpdate(storeItem, rowIndex);
-
                         setTimeout(
                             function(){
                                 try { 
@@ -134,10 +131,12 @@
                                 } catch (E) {}
                             },200
                         );
+                        if(onPostSubmit) onPostSubmit();
                     },
                     onCancel : function() {
                         setTimeout(function(){
                             grid.views.views[0].getCellNode(rowIndex, 0).focus();},200);
+                        if(onCancel) onCancel();
                     }
                 });
 
@@ -146,7 +145,7 @@
                 return pane;
             },
 
-            _makeCreatePane : function() {
+            _makeCreatePane : function(onPostSubmit, onCancel) {
                 var grid = this;
                 var pane = new openils.widget.EditPane({
                     fmClass : this.fmClass,
@@ -155,7 +154,6 @@
                         var fmObject = openils.Util.readResponse(r);
                         if(fmObject) 
                             grid.store.newItem(fmObject.toStoreItem());
-                        dialog.destroy();
                         if(grid.onPostCreate)
                             grid.onPostCreate(fmObject);
                         setTimeout(function(){
@@ -164,7 +162,12 @@
                                 grid.views.views[0].getCellNode(grid.rowCount-1, 1).focus();
                             } catch (E) {}
                         },200);
+                        if(onPostSubmit)
+                            onPostSubmit();
                     },
+                    onCancel : function() {
+                        if(onCancel) onCancel();
+                    }
                 });
                 pane.fieldOrder = this.fieldOrder;
                 pane.mode = 'create';
@@ -173,18 +176,44 @@
 
 
             _drawEditDialog : function(storeItem, rowIndex) {
-                var pane = this._makeEditPane(storeItem, rowIndex);
-                var dialog = new openils.widget.EditDialog({editPane:pane});
-                dialog.startup();
-                dialog.show();
+                var self = this;
+                var done = function() { self.hideDialog(); };
+                var pane = this._makeEditPane(storeItem, rowIndex, done, done);
+                this.editDialog = new openils.widget.EditDialog({editPane:pane});
+                this.editDialog.startup();
+                this.editDialog.show();
             },
 
             showCreateDialog : function() {
-                var pane = this._makeCreatePane();
-                var dialog = new openils.widget.EditDialog({editPane:pane});
-                dialog.startup();
-                dialog.show();
+                var self = this;
+                var done = function() { self.hideDialog(); };
+                var pane = this._makeCreatePane(done, done);
+                this.editDialog = new openils.widget.EditDialog({editPane:pane});
+                this.editDialog.startup();
+                this.editDialog.show();
             },
+
+            showCreatePane : function() {
+                var self = this;
+                var done = function() { self.hidePane(); };
+                this.editPane = this._makeCreatePane(done, done);
+                this.editPane.startup();
+                this.domNode.parentNode.insertBefore(this.editPane.domNode, this.domNode);
+                dojo.style(this.domNode, 'display', 'none');
+            },
+
+            hideDialog : function() {
+                this.editDialog.hide(); 
+                this.editDialog.destroy(); 
+                delete this.editDialog;
+            },
+
+            hidePane : function() {
+                this.domNode.parentNode.removeChild(this.editPane.domNode);
+                this.editPane.destroy();
+                delete this.editPane;
+                dojo.style(this.domNode, 'display', 'block');
+            },
             
             resetStore : function() {
                 this.setStore(this.buildAutoStore());



More information about the open-ils-commits mailing list