implemented 'clone selected row'
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 2 Mar 2009 15:41:04 +0000 (15:41 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 2 Mar 2009 15:41:04 +0000 (15:41 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12344 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/widget/AutoGrid.js

index 28d69fa..6994284 100644 (file)
@@ -189,6 +189,25 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                 return pane;
             },
 
+            // .startup() is called within
+            _makeClonePane : function(storeItem, rowIndex, onPostSubmit, onCancel) {
+                var clonePane = this._makeCreatePane(onPostSubmit, onCancel);
+                var origPane = this._makeEditPane(this.selection.getFirstSelected(), this.focus.rowIndex);
+                clonePane.startup();
+                origPane.startup();
+                dojo.forEach(origPane.fieldList,
+                    function(field) {
+                        if(field.widget.widget.attr('disabled')) return;
+                        var w = clonePane.fieldList.filter(
+                            function(i) { return (i.name == field.name) })[0];
+                        w.widget.baseWidgetValue(field.widget.widgetValue); // sync widgets
+                        w.widget.onload = function(){w.widget.baseWidgetValue(field.widget.widgetValue)}; // async widgets
+                    }
+                );
+                origPane.destroy();
+                return clonePane;
+            },
+
 
             _drawEditDialog : function(storeItem, rowIndex) {
                 var self = this;
@@ -217,6 +236,14 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                 dojo.style(this.domNode, 'display', 'none');
             },
 
+            showClonePane : function(storeItem, rowIndex) {
+                var self = this;
+                var done = function() { self.hidePane(); };
+                this.editPane = this._makeClonePane(storeItem, rowIndex, done, done);
+                this.domNode.parentNode.insertBefore(this.editPane.domNode, this.domNode);
+                dojo.style(this.domNode, 'display', 'none');
+            },
+
             showCreatePane : function() {
                 var self = this;
                 var done = function() { self.hidePane(); };