Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / pkgs / direct-debug.js
index 3db3491..dbabd6e 100644 (file)
@@ -1,6 +1,6 @@
 /*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.1.1
+ * Copyright(c) 2006-2010 Ext JS, LLC
  * licensing@extjs.com
  * http://www.extjs.com/license
  */
@@ -45,14 +45,31 @@ paramOrder: 'param1|param2|param'
      */\r
     directFn : undefined,\r
 \r
-    // protected\r
+    /**\r
+     * DirectProxy implementation of {@link Ext.data.DataProxy#doRequest}\r
+     * @param {String} action The crud action type (create, read, update, destroy)\r
+     * @param {Ext.data.Record/Ext.data.Record[]} rs If action is load, rs will be null\r
+     * @param {Object} params An object containing properties which are to be used as HTTP parameters\r
+     * for the request to the remote server.\r
+     * @param {Ext.data.DataReader} reader The Reader object which converts the data\r
+     * object into a block of Ext.data.Records.\r
+     * @param {Function} callback\r
+     * <div class="sub-desc"><p>A function to be called after the request.\r
+     * The <tt>callback</tt> is passed the following arguments:<ul>\r
+     * <li><tt>r</tt> : Ext.data.Record[] The block of Ext.data.Records.</li>\r
+     * <li><tt>options</tt>: Options object from the action request</li>\r
+     * <li><tt>success</tt>: Boolean success indicator</li></ul></p></div>\r
+     * @param {Object} scope The scope (<code>this</code> reference) in which the callback function is executed. Defaults to the browser window.\r
+     * @param {Object} arg An optional argument which is passed to the callback as its second parameter.\r
+     * @protected\r
+     */\r
     doRequest : function(action, rs, params, reader, callback, scope, options) {\r
-        var args = [];\r
-        var directFn = this.api[action] || this.directFn;\r
+        var args = [],\r
+            directFn = this.api[action] || this.directFn;\r
 \r
         switch (action) {\r
             case Ext.data.Api.actions.create:\r
-                args.push(params.jsonData[reader.meta.root]);          // <-- create(Hash)\r
+                args.push(params.jsonData);            // <-- create(Hash)\r
                 break;\r
             case Ext.data.Api.actions.read:\r
                 // If the method has no parameters, ignore the paramOrder/paramsAsHash.\r
@@ -67,10 +84,10 @@ paramOrder: 'param1|param2|param'
                 }\r
                 break;\r
             case Ext.data.Api.actions.update:\r
-                args.push(params.jsonData[reader.meta.root]);        // <-- update(Hash/Hash[])\r
+                args.push(params.jsonData);        // <-- update(Hash/Hash[])\r
                 break;\r
             case Ext.data.Api.actions.destroy:\r
-                args.push(params.jsonData[reader.meta.root]);        // <-- destroy(Int/Int[])\r
+                args.push(params.jsonData);        // <-- destroy(Int/Int[])\r
                 break;\r
         }\r
 \r
@@ -111,8 +128,9 @@ paramOrder: 'param1|param2|param'
      * Callback for read actions\r
      * @param {String} action [Ext.data.Api.actions.create|read|update|destroy]\r
      * @param {Object} trans The request transaction object\r
+     * @param {Object} result Data object picked out of the server-response.\r
      * @param {Object} res The server response\r
-     * @private\r
+     * @protected\r
      */\r
     onRead : function(action, trans, result, res) {\r
         var records;\r
@@ -132,13 +150,15 @@ paramOrder: 'param1|param2|param'
     },\r
     /**\r
      * Callback for write actions\r
-     * @param {String} action [Ext.data.Api.actions.create|read|update|destroy]\r
+     * @param {String} action [{@link Ext.data.Api#actions create|read|update|destroy}]\r
      * @param {Object} trans The request transaction object\r
+     * @param {Object} result Data object picked out of the server-response.\r
      * @param {Object} res The server response\r
-     * @private\r
+     * @param {Ext.data.Record/[Ext.data.Record]} rs The Store resultset associated with the action.\r
+     * @protected\r
      */\r
     onWrite : function(action, trans, result, res, rs) {\r
-        var data = trans.reader.extractData(result);\r
+        var data = trans.reader.extractData(result, false);\r
         this.fireEvent("write", this, action, data, res, rs, trans.request.arg);\r
         trans.request.callback.call(trans.request.scope, data, res, true);\r
     }\r
@@ -179,16 +199,18 @@ paramOrder: 'param1|param2|param'
  * @constructor\r
  * @param {Object} config\r
  */\r
-Ext.data.DirectStore = function(c){\r
-    // each transaction upon a singe record will generatie a distinct Direct transaction since Direct queues them into one Ajax request.\r
-    c.batchTransactions = false;\r
-\r
-    Ext.data.DirectStore.superclass.constructor.call(this, Ext.apply(c, {\r
-        proxy: (typeof(c.proxy) == 'undefined') ? new Ext.data.DirectProxy(Ext.copyTo({}, c, 'paramOrder,paramsAsHash,directFn,api')) : c.proxy,\r
-        reader: (typeof(c.reader) == 'undefined' && typeof(c.fields) == 'object') ? new Ext.data.JsonReader(Ext.copyTo({}, c, 'totalProperty,root,idProperty'), c.fields) : c.reader\r
-    }));\r
-};\r
-Ext.extend(Ext.data.DirectStore, Ext.data.Store, {});\r
+Ext.data.DirectStore = Ext.extend(Ext.data.Store, {\r
+    constructor : function(config){\r
+        // each transaction upon a singe record will generate a distinct Direct transaction since Direct queues them into one Ajax request.\r
+        var c = Ext.apply({}, {\r
+            batchTransactions: false\r
+        }, config);\r
+        Ext.data.DirectStore.superclass.constructor.call(this, Ext.apply(c, {\r
+            proxy: Ext.isDefined(c.proxy) ? c.proxy : new Ext.data.DirectProxy(Ext.copyTo({}, c, 'paramOrder,paramsAsHash,directFn,api')),\r
+            reader: (!Ext.isDefined(c.reader) && c.fields) ? new Ext.data.JsonReader(Ext.copyTo({}, c, 'totalProperty,root,idProperty'), c.fields) : c.reader\r
+        }));\r
+    }\r
+});\r
 Ext.reg('directstore', Ext.data.DirectStore);
 /**\r
  * @class Ext.Direct\r