X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..2e847cf21b8ab9d15fa167b315ca5b2fa92638fc:/pkgs/direct-debug.js diff --git a/pkgs/direct-debug.js b/pkgs/direct-debug.js index 3db34916..dbabd6e0 100644 --- a/pkgs/direct-debug.js +++ b/pkgs/direct-debug.js @@ -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' */ directFn : undefined, - // protected + /** + * DirectProxy implementation of {@link Ext.data.DataProxy#doRequest} + * @param {String} action The crud action type (create, read, update, destroy) + * @param {Ext.data.Record/Ext.data.Record[]} rs If action is load, rs will be null + * @param {Object} params An object containing properties which are to be used as HTTP parameters + * for the request to the remote server. + * @param {Ext.data.DataReader} reader The Reader object which converts the data + * object into a block of Ext.data.Records. + * @param {Function} callback + *

A function to be called after the request. + * The callback is passed the following arguments:

+ * @param {Object} scope The scope (this reference) in which the callback function is executed. Defaults to the browser window. + * @param {Object} arg An optional argument which is passed to the callback as its second parameter. + * @protected + */ doRequest : function(action, rs, params, reader, callback, scope, options) { - var args = []; - var directFn = this.api[action] || this.directFn; + var args = [], + directFn = this.api[action] || this.directFn; switch (action) { case Ext.data.Api.actions.create: - args.push(params.jsonData[reader.meta.root]); // <-- create(Hash) + args.push(params.jsonData); // <-- create(Hash) break; case Ext.data.Api.actions.read: // If the method has no parameters, ignore the paramOrder/paramsAsHash. @@ -67,10 +84,10 @@ paramOrder: 'param1|param2|param' } break; case Ext.data.Api.actions.update: - args.push(params.jsonData[reader.meta.root]); // <-- update(Hash/Hash[]) + args.push(params.jsonData); // <-- update(Hash/Hash[]) break; case Ext.data.Api.actions.destroy: - args.push(params.jsonData[reader.meta.root]); // <-- destroy(Int/Int[]) + args.push(params.jsonData); // <-- destroy(Int/Int[]) break; } @@ -111,8 +128,9 @@ paramOrder: 'param1|param2|param' * Callback for read actions * @param {String} action [Ext.data.Api.actions.create|read|update|destroy] * @param {Object} trans The request transaction object + * @param {Object} result Data object picked out of the server-response. * @param {Object} res The server response - * @private + * @protected */ onRead : function(action, trans, result, res) { var records; @@ -132,13 +150,15 @@ paramOrder: 'param1|param2|param' }, /** * Callback for write actions - * @param {String} action [Ext.data.Api.actions.create|read|update|destroy] + * @param {String} action [{@link Ext.data.Api#actions create|read|update|destroy}] * @param {Object} trans The request transaction object + * @param {Object} result Data object picked out of the server-response. * @param {Object} res The server response - * @private + * @param {Ext.data.Record/[Ext.data.Record]} rs The Store resultset associated with the action. + * @protected */ onWrite : function(action, trans, result, res, rs) { - var data = trans.reader.extractData(result); + var data = trans.reader.extractData(result, false); this.fireEvent("write", this, action, data, res, rs, trans.request.arg); trans.request.callback.call(trans.request.scope, data, res, true); } @@ -179,16 +199,18 @@ paramOrder: 'param1|param2|param' * @constructor * @param {Object} config */ -Ext.data.DirectStore = function(c){ - // each transaction upon a singe record will generatie a distinct Direct transaction since Direct queues them into one Ajax request. - c.batchTransactions = false; - - Ext.data.DirectStore.superclass.constructor.call(this, Ext.apply(c, { - proxy: (typeof(c.proxy) == 'undefined') ? new Ext.data.DirectProxy(Ext.copyTo({}, c, 'paramOrder,paramsAsHash,directFn,api')) : c.proxy, - reader: (typeof(c.reader) == 'undefined' && typeof(c.fields) == 'object') ? new Ext.data.JsonReader(Ext.copyTo({}, c, 'totalProperty,root,idProperty'), c.fields) : c.reader - })); -}; -Ext.extend(Ext.data.DirectStore, Ext.data.Store, {}); +Ext.data.DirectStore = Ext.extend(Ext.data.Store, { + constructor : function(config){ + // each transaction upon a singe record will generate a distinct Direct transaction since Direct queues them into one Ajax request. + var c = Ext.apply({}, { + batchTransactions: false + }, config); + Ext.data.DirectStore.superclass.constructor.call(this, Ext.apply(c, { + proxy: Ext.isDefined(c.proxy) ? c.proxy : new Ext.data.DirectProxy(Ext.copyTo({}, c, 'paramOrder,paramsAsHash,directFn,api')), + reader: (!Ext.isDefined(c.reader) && c.fields) ? new Ext.data.JsonReader(Ext.copyTo({}, c, 'totalProperty,root,idProperty'), c.fields) : c.reader + })); + } +}); Ext.reg('directstore', Ext.data.DirectStore); /** * @class Ext.Direct