From 7d2938394fab7e47f8c0e75d710ada5f06c7a431 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 14 Oct 2013 17:57:09 +0200 Subject: [FIX] null >= 0 is true... bzr revid: xmo@openerp.com-20131014155709-9cg4bzof02bhtyts --- addons/web/static/src/js/view_list.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/view_list.js') diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 74c2fc47aee..4faf5dce1ec 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -503,10 +503,14 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi var reloaded = $.Deferred(); this.$el.find('.oe_list_content').append( this.groups.render(function () { - if (self.dataset.index == null && self.records.length || - self.dataset.index >= self.records.length) { + if (self.dataset.index == null) { + if (self.records.length) { self.dataset.index = 0; + } + } else if (self.dataset.index >= self.records.length) { + self.dataset.index = 0; } + self.compute_aggregates(); reloaded.resolve(); })); -- cgit v1.2.3 From eb98ba3fd6a806ec062046983a4715f58b92b37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 17 Oct 2013 11:43:55 +0200 Subject: [FIX] list_view: when composing the active_domain in list view because of the list header being checked, also take into account the current action domain; bzr revid: tde@openerp.com-20131017094355-murxot4rqirw3g68 --- addons/web/static/src/js/view_list.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/view_list.js') diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index f9ec22bf712..9c613935aa1 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -802,9 +802,11 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi }, /** * Calculate the active domain of the list view. This should be done only - * if the header checkbox has been checked. + * if the header checkbox has been checked. This is done by evaluating the + * search results, and then adding the dataset domain (i.e. action domain). */ get_active_domain: function () { + var self = this; if (this.$('.oe_list_record_selector').prop('checked')) { var search_view = this.getParent().searchview; var search_data = search_view.build_search_data(); @@ -813,7 +815,8 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi contexts: search_data.contexts, group_by_seq: search_data.groupbys || [] }).then(function (results) { - return results.domain; + var domain = self.dataset.domain.concat(results.domain || []); + return domain }); } else { -- cgit v1.2.3 From d524b95172f51f22f7d56f503a72f930de573271 Mon Sep 17 00:00:00 2001 From: xmo <> Date: Fri, 25 Oct 2013 16:55:19 +0200 Subject: [FIX] list view: serialize concurrent calls when loading files and ensure consistency of variables (prevent selection of items in list view lost, opw #599969) bzr revid: mat@openerp.com-20131025145519-jio03azp64ppi5ro --- addons/web/static/src/js/view_list.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/view_list.js') diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 4faf5dce1ec..e2909815324 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -496,7 +496,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi * * @returns {$.Deferred} promise to content reloading */ - reload_content: function () { + reload_content: synchronized(function () { var self = this; self.$el.find('.oe_list_record_selector').prop('checked', false); this.records.reset(); @@ -519,7 +519,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi limit: this._limit }); return reloaded.promise(); - }, + }), reload: function () { return this.reload_content(); }, @@ -1601,6 +1601,22 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we } }); +/** + * Serializes concurrent calls to this asynchronous method. The method must + * return a deferred or promise. + * + * Current-implementation is class-serialized (the mutex is common to all + * instances of the list view). Can be switched to instance-serialized if + * having concurrent list views becomes possible and common. + */ +function synchronized(fn) { + var fn_mutex = new $.Mutex(); + return function () { + var args = _.toArray(arguments); + args.unshift(this); + return fn_mutex.exec(fn.bind.apply(fn, args)); + }; +} var DataGroup = instance.web.Class.extend({ init: function(parent, model, domain, context, group_by, level) { this.model = new instance.web.Model(model, context, domain); -- cgit v1.2.3 From 9edf16f6690f14a98c39d7b24ab5e8ece7b53a88 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 28 Oct 2013 15:16:47 +0100 Subject: [FIX] list: force recompute the selection as closing group reset properties (opw #599969) bzr revid: mat@openerp.com-20131028141647-j6wkvl6plwblh077 --- addons/web/static/src/js/view_list.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'addons/web/static/src/js/view_list.js') diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index e2909815324..02d0b21d29c 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1332,6 +1332,9 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we .removeClass('ui-icon-triangle-1-s') .addClass('ui-icon-triangle-1-e'); child.close(); + // force recompute the selection as closing group reset properties + var selection = self.get_selection(); + $(self).trigger('selected', [selection.ids, this.records]); } }); } -- cgit v1.2.3 From a237b0525d546667fbbde2655b80deccdfeec981 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 30 Oct 2013 19:02:42 +0100 Subject: [FIX] web: allow grouping on fields not present in list view [FIX] web,web_kanban: read_group: ensure read grouping fields bzr revid: chs@openerp.com-20131030180242-rxxlawffv13ll5s1 --- addons/web/static/src/js/view_list.js | 37 +++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'addons/web/static/src/js/view_list.js') diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 02d0b21d29c..d5e9ef501bf 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1345,22 +1345,29 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we if (group.grouped_on) { var row_data = {}; row_data[group.grouped_on] = group; + var group_label = _t("Undefined"); var group_column = _(self.columns).detect(function (column) { return column.id === group.grouped_on; }); - if (! group_column) { - throw new Error(_.str.sprintf( - _t("Grouping on field '%s' is not possible because that field does not appear in the list view."), - group.grouped_on)); - } - var group_label; - try { - group_label = group_column.format(row_data, { - value_if_empty: _t("Undefined"), - process_modifiers: false - }); - } catch (e) { - group_label = _.str.escapeHTML(row_data[group_column.id].value); + if (group_column) { + try { + group_label = group_column.format(row_data, { + value_if_empty: _t("Undefined"), + process_modifiers: false + }); + } catch (e) { + group_label = _.str.escapeHTML(row_data[group_column.id].value); + } + } else { + group_label = group.value; + if (group_label instanceof Array) { + group_label = group_label[1]; + } + if (group_label === false) { + group_label = _t('Undefined'); + } + group_label = _.str.escapeHTML(group_label); } + // group_label is html-clean (through format or explicit // escaping if format failed), can inject straight into HTML $group_column.html(_.str.sprintf(_t("%s (%d)"), @@ -1631,6 +1638,10 @@ var DataGroup = instance.web.Class.extend({ }, list: function (fields, ifGroups, ifRecords) { var self = this; + if (!_.isEmpty(this.group_by)) { + // ensure group_by fields are read. + fields = _.unique((fields || []).concat(this.group_by)); + } var query = this.model.query(fields).order_by(this.sort).group_by(this.group_by); $.when(query).done(function (querygroups) { // leaf node -- cgit v1.2.3 From e5ca5a170ce2525e504d864d5041d17be96c4343 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 14 Nov 2013 12:08:47 +0100 Subject: [FIX] web: list views: bubble up failed deferreds. [FIX] web: list view group: always call post_render method lp bug: https://launchpad.net/bugs/1248531 fixed bzr revid: chs@openerp.com-20131114110847-nn382fc60s7u7wp1 --- addons/web/static/src/js/view_list.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src/js/view_list.js') diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index d5e9ef501bf..b9c789cb6a9 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1439,14 +1439,13 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we var view = this.view, limit = view.limit(), - d = new $.Deferred(), page = this.datagroup.openable ? this.page : view.page; 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().done(function() { - dataset.read_slice(fields, options).done(function (records) { + return $.async_when().then(function() { + return 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}); @@ -1478,13 +1477,12 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we self.records.add(records, {silent: true}); list.render(); - d.resolve(list); if (_.isEmpty(records)) { view.no_result(); } + return list; }); }); - return d.promise(); }, setup_resequence_rows: function (list, dataset) { // drag and drop enabled if list is not sorted and there is a @@ -1564,11 +1562,12 @@ 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).done(function (list) { + self.render_dataset(dataset).then(function (list) { self.children[null] = list; self.elements = [list.$current.replaceAll($el)[0]]; self.setup_resequence_rows(list, dataset); + }).always(function() { if (post_render) { post_render(); } }); }); -- cgit v1.2.3