From b939ea9ca7fff1342636b8c68fb4fcedfa2fd4a9 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 1 Sep 2009 18:39:42 +0000 Subject: [PATCH] pass the clone object to the postsubmit handler. allow caller to specificy post-clone handler. added some docs git-svn-id: svn://svn.open-ils.org/ILS/trunk@13940 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/widget/AutoGrid.js | 26 ++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js index 78628a12f4..af7bafb76f 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js @@ -385,7 +385,8 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { } catch (E) {} },200 ); - if(onPostSubmit) onPostSubmit(); + if(onPostSubmit) + onPostSubmit(); }, onCancel : function() { setTimeout(function(){ @@ -419,7 +420,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { } catch (E) {} },200); if(onPostSubmit) - onPostSubmit(); + onPostSubmit(fmObject); }, onCancel : function() { if(onCancel) onCancel(); @@ -430,7 +431,15 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { return pane; }, - // .startup() is called within + /** + * Creates an EditPane with a copy of the data from the provided store + * item for cloning said item + * @param {Object} storeItem Dojo data item + * @param {Number} rowIndex The Grid row index of the item to be cloned + * @param {Function} onPostSubmit Optional callback for post-submit behavior + * @param {Function} onCancel Optional callback for clone cancelation + * @return {Object} The clone EditPane + */ _makeClonePane : function(storeItem, rowIndex, onPostSubmit, onCancel) { var clonePane = this._makeCreatePane(onPostSubmit, onCancel); var origPane = this._makeEditPane(storeItem, rowIndex); @@ -478,13 +487,20 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { if(this.onEditPane) this.onEditPane(this.editPane); }, - showClonePane : function() { + showClonePane : function(onPostSubmit) { var self = this; var done = function() { self.hidePane(); }; + + var row = this.getFirstSelectedRow(); if(!row) return; + + var postSubmit = (onPostSubmit) ? + function(result) { onPostSubmit(self.getItem(row), result); self.hidePane(); } : + done; + dojo.style(this.domNode, 'display', 'none'); - this.editPane = this._makeClonePane(this.getItem(row), row, done, done); + this.editPane = this._makeClonePane(this.getItem(row), row, postSubmit, done); this.domNode.parentNode.insertBefore(this.editPane.domNode, this.domNode); if(this.onEditPane) this.onEditPane(this.editPane); }, -- 2.11.0