Skip to content

Commit

Permalink
[FIX] web: empty kanban view on mobile
Browse files Browse the repository at this point in the history
Due to the recent refactoring in control panel 40dd121,
some css rules have been broken in mobile.

To fix this, we need to set 'o_current' class inside the
displayed column because we need to know which one to
display in mobile.

This issue doesn't occur in desktop because all kanban columns
are displayed.

closes #29457
  • Loading branch information
res-odoo authored and adr-odoo committed Dec 13, 2018
1 parent 4abdfc3 commit 287136b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Expand Up @@ -143,7 +143,7 @@ KanbanRenderer.include({
onSuccess: function () {
// update the columns and tabs positions (optionally with an animation)
var updateFunc = animate ? 'animate' : 'css';
self.$('.o_kanban_mobile_tab').removeClass('o_current');
self.$('.o_kanban_mobile_tab, .o_kanban_group').removeClass('o_current');
_.each(self.widgets, function (column, index) {
var columnID = column.id || column.db_id;
var $column = self.$('.o_kanban_group[data-id="' + columnID + '"]');
Expand All @@ -157,6 +157,7 @@ KanbanRenderer.include({
} else if (index === moveToIndex) {
$column[updateFunc]({left: '0%'});
$tab[updateFunc]({left: '50%'});
$column.addClass('o_current');
$tab.addClass('o_current');
} else if (index < moveToIndex) {
$column.css({left: '-100%'});
Expand Down
3 changes: 3 additions & 0 deletions addons/web/static/src/scss/kanban_view_mobile.scss
Expand Up @@ -36,6 +36,9 @@
margin-left: 0; // override the margin-left: -1px of the desktop mode
border: none;

&.o_current {
position: initial;
}
.o_kanban_header {
display: none;
}
Expand Down
6 changes: 5 additions & 1 deletion addons/web/static/tests/views/kanban_mobile_tests.js
Expand Up @@ -56,7 +56,7 @@ QUnit.module('Views', {
QUnit.module('KanbanView Mobile');

QUnit.test('mobile grouped rendering', function (assert) {
assert.expect(9);
assert.expect(11);

var kanban = createView({
View: KanbanView,
Expand All @@ -75,6 +75,8 @@ QUnit.module('Views', {
assert.containsN(kanban, '.o_kanban_group', 2, "should have 2 columns" );
assert.hasClass(kanban.$('.o_kanban_mobile_tab:first'),'o_current',
"first tab is the active tab with class 'o_current'");
assert.hasClass(kanban.$('.o_kanban_group:first'),'o_current',
"first column is the active column with class 'o_current'");
assert.containsN(kanban, '.o_kanban_group:first > div.o_kanban_record', 2,
"there are 2 records in active tab");
assert.strictEqual(kanban.$('.o_kanban_group:nth(1) > div.o_kanban_record').length, 0,
Expand All @@ -89,6 +91,8 @@ QUnit.module('Views', {
kanban.$('.o_kanban_mobile_tab:nth(1)').trigger('click');
assert.hasClass(kanban.$('.o_kanban_mobile_tab:nth(1)'),'o_current',
"second tab is now active with class 'o_current'");
assert.hasClass(kanban.$('.o_kanban_group:nth(1)'),'o_current',
"second column is now active with class 'o_current'");
assert.strictEqual(kanban.$('.o_kanban_group:nth(1) > div.o_kanban_record').length, 2,
"the 2 records of the second group have now been loaded");

Expand Down

0 comments on commit 287136b

Please sign in to comment.