[open-ils-commits] r12077 - in trunk/Open-ILS/web: js/dojo/openils/widget templates/default/conify/global/acq

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Feb 5 09:36:43 EST 2009


Author: erickson
Date: 2009-02-05 09:36:42 -0500 (Thu, 05 Feb 2009)
New Revision: 12077

Modified:
   trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
   trunk/Open-ILS/web/js/dojo/openils/widget/EditDialog.js
   trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
   trunk/Open-ILS/web/templates/default/conify/global/acq/exchange_rate.tt2
Log:
added option to launch creation dialog from auto grid.  passing final pcrud response to onPostSubmit handler

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-02-05 06:33:07 UTC (rev 12076)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-02-05 14:36:42 UTC (rev 12077)
@@ -26,7 +26,8 @@
                 for(var f in this.sortedFieldList) {
                     var field = this.sortedFieldList[f];
                     if(!field || field.virtual) continue;
-                    var entry = existing.filter(function(i){return (i.field == field.name)})[0];
+                    var entry = existing.filter(
+                        function(i){return (i.field == field.name)})[0];
                     if(entry) entry.name = field.label;
                     else entry = {field:field.name, name:field.label};
                     fields.push(entry);
@@ -67,7 +68,7 @@
                 var idents = grid.store.getIdentityAttributes();
                 var dialog = new openils.widget.EditDialog({
                     fmObject:fmObject,
-                    onPostApply : function() {
+                    onPostSubmit : function() {
                         for(var i in fmObject._fields) {
                             var field = fmObject._fields[i];
                             if(idents.filter(function(j){return (j == field)})[0])
@@ -79,10 +80,30 @@
                     }
                 });
                 dialog.editPane.fieldOrder = this.fieldOrder;
+                dialog.editPane.mode = 'update';
                 dialog.startup();
                 dialog.show();
+            },
+
+            showCreateDialog : function() {
+                var grid = this;
+                var dialog = new openils.widget.EditDialog({
+                    fmClass : this.fmClass,
+                    onPostSubmit : function(r) {
+                        var fmObject = openils.Util.readResponse(r);
+                        if(fmObject) {
+                            grid.store.newItem(fmObject.toStoreItem());
+                            grid.update();
+                        }
+                        dialog.destroy();
+                    }
+                });
+                dialog.editPane.fieldOrder = this.fieldOrder;
+                dialog.editPane.mode = 'create';
+                dialog.startup();
+                dialog.show();
             }
-        }
+        } 
     );
     openils.widget.AutoGrid.markupFactory = dojox.grid.DataGrid.markupFactory;
 

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/EditDialog.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditDialog.js	2009-02-05 06:33:07 UTC (rev 12076)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditDialog.js	2009-02-05 14:36:42 UTC (rev 12077)
@@ -34,10 +34,10 @@
                     self.hide(); 
                 }
 
-                this.editPane.onPostApply = function() { 
+                this.editPane.onPostSubmit = function(r) { 
                     self.hide(); 
-                    if(args.onPostApply)
-                        args.onPostApply();
+                    if(args.onPostSubmit)
+                        args.onPostSubmit(r);
                 }
             },
 

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2009-02-05 06:33:07 UTC (rev 12076)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2009-02-05 14:36:42 UTC (rev 12077)
@@ -12,7 +12,7 @@
         [dijit.layout.ContentPane, openils.widget.AutoWidget],
         {
             mode : 'update',
-            onPostApply : null, // apply callback
+            onPostSubmit : null, // apply callback
             onCancel : null, // cancel callback
             hideActionButtons : false,
 
@@ -58,6 +58,7 @@
                         parentNode : valTd,
                         orgLimitPerms : this.limitPerms
                     });
+
                     widget.build();
                     this.fieldList.push({name:field.name, widget:widget});
                     this.applySaveOnEnter(widget);
@@ -112,9 +113,9 @@
             performAutoEditAction : function() {
                 var self = this;
                 self.performEditAction({
-                    oncomplete:function() {
-                        if(self.onPostApply)
-                            self.onPostApply();
+                    oncomplete:function(r) {
+                        if(self.onPostSubmit)
+                            self.onPostSubmit(r);
                     }
                 });
             },
@@ -126,6 +127,8 @@
                     this.fmObject = new fieldmapper[this.fmClass]();
                 for(var idx in fields)  
                     this.fmObject[fields[idx]](this.getFieldValue(fields[idx]));
+                if(this.mode == 'create')
+                    this.fmObject[fieldmapper[this.fmClass].Identifier](null);
                 pcrud[this.mode](this.fmObject, opts);
             }
         }

Modified: trunk/Open-ILS/web/templates/default/conify/global/acq/exchange_rate.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/conify/global/acq/exchange_rate.tt2	2009-02-05 06:33:07 UTC (rev 12076)
+++ trunk/Open-ILS/web/templates/default/conify/global/acq/exchange_rate.tt2	2009-02-05 14:36:42 UTC (rev 12077)
@@ -23,6 +23,7 @@
     }
     openils.Util.addOnLoad(renderGrid);
 </script>
+<button dojoType='dijit.form.Button' onClick='erGrid.showCreateDialog()'>Create</button>
 <div dojoType="dijit.layout.ContentPane" layoutAlign="top" style='height:600px;'>
     <table jsId="erGrid" dojoType="openils.widget.AutoGrid" 
             fieldOrder="['id', 'from_currency', 'to_currency', 'ratio']" 



More information about the open-ils-commits mailing list