diff options
| author | Fabien Meghazi <fme@openerp.com> | 2012-10-30 15:06:30 +0100 |
|---|---|---|
| committer | Fabien Meghazi <fme@openerp.com> | 2012-10-30 15:06:30 +0100 |
| commit | ca6c49becf9ce72e4f1a37f04bc89dae417be196 (patch) | |
| tree | ed310de02126375971a7becd6bfc0aab58a13ef3 /addons/web/static/src/js/data.js | |
| parent | eb1c4d0f93bcaf77bfe00adea11df5d7d40c8c20 (diff) | |
[IMP] jQuery deferred API changes refactoring. Changed 'then's in 'done'/'fail' and 'pipe's in 'then'
bzr revid: fme@openerp.com-20121030140630-gf20ye8fou1ebxft
Diffstat (limited to 'addons/web/static/src/js/data.js')
| -rw-r--r-- | addons/web/static/src/js/data.js | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index e279ade6fb3..467b74040c7 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -66,7 +66,7 @@ instance.web.Query = instance.web.Class.extend({ offset: this._offset, limit: this._limit, sort: instance.web.serialize_sort(this._order_by) - }).pipe(function (results) { + }).then(function (results) { self._count = results.length; return results.records; }, null); @@ -78,7 +78,7 @@ instance.web.Query = instance.web.Class.extend({ */ first: function () { var self = this; - return this.clone({limit: 1})._execute().pipe(function (records) { + return this.clone({limit: 1})._execute().then(function (records) { delete self._count; if (records.length) { return records[0]; } return null; @@ -132,7 +132,7 @@ instance.web.Query = instance.web.Class.extend({ offset: this._offset, limit: this._limit, orderby: instance.web.serialize_sort(this._order_by) || false - }).pipe(function (results) { + }).then(function (results) { return _(results).map(function (result) { // FIX: querygroup initialization result.__context = result.__context || {}; @@ -443,7 +443,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ return this._model.query(fields) .limit(options.limit || false) .offset(options.offset || 0) - .all().then(function (records) { + .all().done(function (records) { self.ids = _(records).pluck('id'); }); }, @@ -456,7 +456,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ */ read_index: function (fields, options) { options = options || {}; - return this.read_ids([this.ids[this.index]], fields, options).pipe(function (records) { + return this.read_ids([this.ids[this.index]], fields, options).then(function (records) { if (_.isEmpty(records)) { return $.Deferred().reject().promise(); } return records[0]; }); @@ -493,7 +493,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ */ write: function (id, data, options) { options = options || {}; - return this._model.call('write', [[id], data], {context: this._model.context(options.context)}).then(this.trigger('dataset_changed', id, data, options)); + return this._model.call('write', [[id], data], {context: this._model.context(options.context)}).done(this.trigger('dataset_changed', id, data, options)); }, /** * Deletes an existing record from the database @@ -501,7 +501,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ * @param {Number|String} ids identifier of the record to delete */ unlink: function(ids) { - return this._model.call('unlink', [ids], {context: this._model.context()}).then(this.trigger('dataset_changed', ids)); + return this._model.call('unlink', [ids], {context: this._model.context()}).done(this.trigger('dataset_changed', ids)); }, /** * Calls an arbitrary RPC method @@ -607,7 +607,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ model: this.model, ids: ids, context: this._model.context(options.context), - }).pipe(function (results) { + }).then(function (results) { return results; }); }, @@ -682,9 +682,9 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({ .limit(options.limit || false); q = q.order_by.apply(q, this._sort); - return q.all().then(function (records) { + return q.all().done(function (records) { // FIXME: not sure about that one, *could* have discarded count - q.count().then(function (count) { self._length = count; }); + q.count().done(function (count) { self._length = count; }); self.ids = _(records).pluck('id'); }); }, @@ -693,7 +693,7 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({ }, unlink: function(ids, callback, error_callback) { var self = this; - return this._super(ids).then(function(result) { + return this._super(ids).done(function(result) { self.ids = _(self.ids).difference(ids); if (self._length) { self._length -= 1; @@ -722,7 +722,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ this.last_default_get = {}; }, default_get: function(fields, options) { - return this._super(fields, options).then(this.on_default_get); + return this._super(fields, options).done(this.on_default_get); }, on_default_get: function(res) { this.last_default_get = res; @@ -774,7 +774,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ this.cache = _.reject(this.cache, function(x) { return _.include(ids, x.id);}); this.set_ids(_.without.apply(_, [this.ids].concat(ids))); this.trigger("dataset_changed", ids, callback, error_callback); - return $.async_when({result: true}).then(callback); + return $.async_when({result: true}).done(callback); }, reset_ids: function(ids) { this.set_ids(ids); @@ -836,7 +836,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ completion.resolve(records); }; if(to_get.length > 0) { - var rpc_promise = this._super(to_get, fields, options).then(function(records) { + var rpc_promise = this._super(to_get, fields, options).done(function(records) { _.each(records, function(record, index) { var id = to_get[index]; var cached = _.detect(self.cache, function(x) {return x.id === id;}); @@ -991,14 +991,14 @@ instance.web.DropMisordered = instance.web.Class.extend({ var res = $.Deferred(); var self = this, seq = this.lsn++; - deferred.then(function () { + deferred.done(function () { if (seq > self.rsn) { self.rsn = seq; res.resolve.apply(res, arguments); } else if (self.failMisordered) { res.reject(); } - }, function () { + }).fail(function () { res.reject.apply(res, arguments); }); |
