summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/view_list.js
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2012-10-30 15:06:30 +0100
committerFabien Meghazi <fme@openerp.com>2012-10-30 15:06:30 +0100
commitca6c49becf9ce72e4f1a37f04bc89dae417be196 (patch)
treeed310de02126375971a7becd6bfc0aab58a13ef3 /addons/web/static/src/js/view_list.js
parenteb1c4d0f93bcaf77bfe00adea11df5d7d40c8c20 (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/view_list.js')
-rw-r--r--addons/web/static/src/js/view_list.js88
1 files changed, 45 insertions, 43 deletions
diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
index 5546105e901..86eb4c72674 100644
--- a/addons/web/static/src/js/view_list.js
+++ b/addons/web/static/src/js/view_list.js
@@ -508,7 +508,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
_.pluck(_(this.columns).filter(function (r) {
return r.tag === 'field';
}), 'name')
- ).then(function (records) {
+ ).done(function (records) {
_(records[0]).each(function (value, key) {
record.set(key, value, {silent: true});
});
@@ -553,7 +553,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
this.no_leaf = !!context['group_by_no_leaf'];
this.grouped = !!group_by;
- return this.load_view(context).pipe(
+ return this.load_view(context).then(
this.proxy('reload_content'));
},
/**
@@ -566,7 +566,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
return;
}
var self = this;
- return $.when(this.dataset.unlink(ids)).then(function () {
+ return $.when(this.dataset.unlink(ids)).done(function () {
_(ids).each(function (id) {
self.records.remove(self.records.get(id));
});
@@ -976,7 +976,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
// to get a correctly displayable value in the field
var model = ref_match[1],
id = parseInt(ref_match[2], 10);
- new instance.web.DataSet(this.view, model).name_get([id]).then(function(names) {
+ new instance.web.DataSet(this.view, model).name_get([id]).done(function(names) {
if (!names.length) { return; }
record.set(column.id, names[0][1]);
});
@@ -992,7 +992,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
// and let the various registered events handle refreshing the
// row
new instance.web.DataSet(this.view, column.relation)
- .name_get([value]).then(function (names) {
+ .name_get([value]).done(function (names) {
if (!names.length) { return; }
record.set(column.id, names[0]);
});
@@ -1015,7 +1015,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
ids = value;
}
new instance.web.Model(column.relation)
- .call('name_get', [ids]).then(function (names) {
+ .call('name_get', [ids]).done(function (names) {
record.set(column.id, _(names).pluck(1).join(', '));
})
}
@@ -1384,43 +1384,45 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
var fields = _.pluck(_.select(this.columns, function(x) {return x.tag == "field"}), 'name');
var options = { offset: page * limit, limit: limit, context: {bin_size: true} };
//TODO xmo: investigate why we need to put the setTimeout
- $.async_when().then(function() {dataset.read_slice(fields, options).then(function (records) {
- // FIXME: ignominious hacks, parents (aka form view) should not send two ListView#reload_content concurrently
- if (self.records.length) {
- self.records.reset(null, {silent: true});
- }
- if (!self.datagroup.openable) {
- view.configure_pager(dataset);
- } else {
- if (dataset.size() == records.length) {
- // only one page
- self.$row.find('td.oe_list_group_pagination').empty();
+ $.async_when().done(function() {
+ dataset.read_slice(fields, options).done(function (records) {
+ // FIXME: ignominious hacks, parents (aka form view) should not send two ListView#reload_content concurrently
+ if (self.records.length) {
+ self.records.reset(null, {silent: true});
+ }
+ if (!self.datagroup.openable) {
+ view.configure_pager(dataset);
} else {
- var pages = Math.ceil(dataset.size() / limit);
- self.$row
- .find('.oe_list_pager_state')
- .text(_.str.sprintf(_t("%(page)d/%(page_count)d"), {
- page: page + 1,
- page_count: pages
- }))
- .end()
- .find('button[data-pager-action=previous]')
- .css('visibility',
- page === 0 ? 'hidden' : '')
- .end()
- .find('button[data-pager-action=next]')
- .css('visibility',
- page === pages - 1 ? 'hidden' : '');
+ if (dataset.size() == records.length) {
+ // only one page
+ self.$row.find('td.oe_list_group_pagination').empty();
+ } else {
+ var pages = Math.ceil(dataset.size() / limit);
+ self.$row
+ .find('.oe_list_pager_state')
+ .text(_.str.sprintf(_t("%(page)d/%(page_count)d"), {
+ page: page + 1,
+ page_count: pages
+ }))
+ .end()
+ .find('button[data-pager-action=previous]')
+ .css('visibility',
+ page === 0 ? 'hidden' : '')
+ .end()
+ .find('button[data-pager-action=next]')
+ .css('visibility',
+ page === pages - 1 ? 'hidden' : '');
+ }
}
- }
- self.records.add(records, {silent: true});
- list.render();
- d.resolve(list);
- if (_.isEmpty(records)) {
- view.no_result();
- }
- });});
+ self.records.add(records, {silent: true});
+ list.render();
+ d.resolve(list);
+ if (_.isEmpty(records)) {
+ view.no_result();
+ }
+ });
+ });
return d.promise();
},
setup_resequence_rows: function (list, dataset) {
@@ -1476,7 +1478,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
// Accounting > Taxes > Taxes, child tax accounts)
// when synchronous (without setTimeout)
(function (dataset, id, seq) {
- $.async_when().then(function () {
+ $.async_when().done(function () {
var attrs = {};
attrs[seqname] = seq;
dataset.write(id, attrs);
@@ -1501,7 +1503,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
self.render_groups(groups));
if (post_render) { post_render(); }
}, function (dataset) {
- self.render_dataset(dataset).then(function (list) {
+ self.render_dataset(dataset).done(function (list) {
self.children[null] = list;
self.elements =
[list.$current.replaceAll($el)[0]];
@@ -1561,7 +1563,7 @@ var DataGroup = instance.web.CallbackEnabled.extend({
list: function (fields, ifGroups, ifRecords) {
var self = this;
var query = this.model.query(fields).order_by(this.sort).group_by(this.group_by);
- $.when(query).then(function (querygroups) {
+ $.when(query).done(function (querygroups) {
// leaf node
if (!querygroups) {
var ds = new instance.web.DataSetSearch(self, self.model.name, self.model.context(), self.model.domain());