[FIX] kanban: display no_result message when there are no records in the kanban view with columns

bzr revid: chm@openerp.com-20130121153358-tzp976npk1jp9yip
This commit is contained in:
Christophe Matthieu 2013-01-21 16:33:58 +01:00
parent a7ebaf73df
commit 61be1b4637
1 changed files with 12 additions and 4 deletions

View File

@ -223,7 +223,6 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
},
do_search: function(domain, context, group_by) {
var self = this;
this.$el.find('.oe_view_nocontent').remove();
this.search_domain = domain;
this.search_context = context;
this.search_group_by = group_by;
@ -235,6 +234,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
self.$el.toggleClass('oe_kanban_grouped_by_m2o', self.grouped_by_m2o);
var grouping = new instance.web.Model(self.dataset.model, context, domain).query().group_by(self.group_by);
$.when(grouping).done(function(groups) {
self.$el.find('.oe_view_nocontent').remove();
if (groups) {
self.do_process_groups(groups);
} else {
@ -245,6 +245,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
},
do_process_groups: function(groups) {
var self = this;
this.$el.find('table:first').show();
this.$el.removeClass('oe_kanban_ungrouped').addClass('oe_kanban_grouped');
this.add_group_mutex.exec(function() {
self.do_clear_groups();
@ -253,13 +254,15 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
self.no_result();
return false;
}
self.nb_records = 0;
var remaining = groups.length - 1,
groups_array = [];
return $.when.apply(null, _.map(groups, function (group, index) {
var dataset = new instance.web.DataSetSearch(self, self.dataset.model,
new instance.web.CompoundContext(self.dataset.get_context(), group.model.context()), group.model.domain());
return dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit })
.then(function(records) {
.then(function (records) {
self.nb_records += records.length;
self.dataset.ids.push.apply(self.dataset.ids, dataset.ids);
groups_array[index] = new instance.web_kanban.KanbanGroup(self, records, group, dataset);
if (!remaining--) {
@ -267,11 +270,16 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
return self.do_add_groups(groups_array);
}
});
}));
})).then(function () {
if(!self.nb_records) {
self.no_result();
}
});
});
},
do_process_dataset: function() {
var self = this;
this.$el.find('table:first').show();
this.$el.removeClass('oe_kanban_grouped').addClass('oe_kanban_ungrouped');
this.add_group_mutex.exec(function() {
var def = $.Deferred();
@ -447,7 +455,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|| !this.options.action.help) {
return;
}
this.$el.find('.oe_view_nocontent').remove();
this.$el.find('table:first').hide();
this.$el.prepend(
$('<div class="oe_view_nocontent">').html(this.options.action.help)
);