[FIX] web: mobile tab wrong if "Undefined" column
If a kanban view is grouped on a many2one, records with the field unset are displayed in a column "Undefined" displayed first. But the tab in mobile view doesn't respect this, so we can get: columns: Undefined colA colB tabs: colA colB Undefined So we always get always on the wrong column wrong when clicking on a tab: clicking on colB we get on colA, clicking on Undefined we get on colB, ... note: in this commit the "false" tab has been set to a translatable "Undefined" name. issue found when working on #21199
This commit is contained in:
committed by
Adrien Dieudonné
parent
9518c51374
commit
bed48ad960
@@ -12,6 +12,7 @@ var config = require('web.config');
|
||||
var core = require('web.core');
|
||||
var KanbanRenderer = require('web.KanbanRenderer');
|
||||
|
||||
var _t = core._t;
|
||||
var qweb = core.qweb;
|
||||
|
||||
if (!config.device.isMobile) {
|
||||
@@ -138,8 +139,19 @@ KanbanRenderer.include({
|
||||
* @private
|
||||
*/
|
||||
_renderGrouped: function (fragment) {
|
||||
var data = [];
|
||||
_.each(this.state.data, function (group) {
|
||||
if (!group.value) {
|
||||
group = _.extend({}, group, {value: _t('Undefined')});
|
||||
data.unshift(group);
|
||||
}
|
||||
else {
|
||||
data.push(group);
|
||||
}
|
||||
});
|
||||
|
||||
var $tabs = $(qweb.render('KanbanView.MobileTabs', {
|
||||
data: this.state.data,
|
||||
data: data,
|
||||
}));
|
||||
$tabs.appendTo(fragment);
|
||||
return this._super.apply(this, arguments);
|
||||
|
||||
@@ -56,7 +56,7 @@ QUnit.module('Views', {
|
||||
QUnit.module('KanbanView Mobile');
|
||||
|
||||
QUnit.test('mobile grouped rendering', function (assert) {
|
||||
assert.expect(8);
|
||||
assert.expect(9);
|
||||
|
||||
var kanban = createView({
|
||||
View: KanbanView,
|
||||
@@ -97,6 +97,38 @@ QUnit.module('Views', {
|
||||
assert.ok(kanban.$('.o_kanban_group:nth(1) > div:nth(1)').hasClass('o_kanban_quick_create'),
|
||||
"clicking on create should open the quick_create in the second column");
|
||||
|
||||
// kanban column should match kanban mobile tabs
|
||||
var column_ids = kanban.$('.o_kanban_group').map(function(){ return $(this).data('id') }).get();
|
||||
var tab_ids = kanban.$('.o_kanban_mobile_tab').map(function(){ return $(this).data('id') }).get();
|
||||
assert.deepEqual(column_ids, tab_ids, "all columns data-id should match mobile tabs data-id");
|
||||
|
||||
kanban.destroy();
|
||||
});
|
||||
QUnit.test('mobile grouped with undefined column', function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
var kanban = createView({
|
||||
View: KanbanView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<kanban class="o_kanban_test o_kanban_small_column">' +
|
||||
'<templates><t t-name="kanban-box">' +
|
||||
'<div><field name="foo"/></div>' +
|
||||
'</t></templates>' +
|
||||
'</kanban>',
|
||||
groupBy: ['product_id'],
|
||||
});
|
||||
|
||||
// first column should be undefined with framework unique identifier
|
||||
assert.strictEqual(kanban.$('.o_kanban_group').length, 3, "should have 3 columns" );
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:first-child[data-id^="partner_"]').length, 1,
|
||||
"Undefined column should be first and have unique framework identifier as data-id")
|
||||
|
||||
// kanban column should match kanban mobile tabs
|
||||
var column_ids = kanban.$('.o_kanban_group').map(function(){ return $(this).data('id') }).get();
|
||||
var tab_ids = kanban.$('.o_kanban_mobile_tab').map(function(){ return $(this).data('id') }).get();
|
||||
assert.deepEqual(column_ids, tab_ids, "all columns data-id should match mobile tabs data-id");
|
||||
|
||||
kanban.destroy();
|
||||
});
|
||||
QUnit.test('mobile grouped on many2one rendering', function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user