|
@@ -45,6 +45,7 @@ KanbanRenderer.include({ |
|
|
|
$column.scrollLeft(this._scrollPosition.left); |
|
|
|
$column.scrollTop(this._scrollPosition.top); |
|
|
|
} |
|
|
|
this._computeTabPosition(); |
|
|
|
this._super.apply(this, arguments); |
|
|
|
}, |
|
|
|
/** |
|
@@ -142,38 +143,61 @@ KanbanRenderer.include({ |
|
|
|
'.o_kanban_group.o_current') |
|
|
|
.removeClass('o_current'); |
|
|
|
this.$('.o_kanban_group[data-id="' + columnID + '"], ' + |
|
|
|
'.o_kanban_mobile_tab[data-id="' + columnID + '"]') |
|
|
|
'.o_kanban_mobile_tab[data-id="' + columnID + '"]') |
|
|
|
.addClass('o_current'); |
|
|
|
} |
|
|
|
}, |
|
|
|
/** |
|
|
|
* Update the tabs positions |
|
|
|
* Compute the justify content of the kanban tab headers |
|
|
|
* @private |
|
|
|
* @param {boolean} [animate=false] set to true to animate |
|
|
|
*/ |
|
|
|
_computeTabPosition: function (animate) { |
|
|
|
_computeTabHeaderJustifyContent: function () { |
|
|
|
if (this.widgets && this.widgets.length) { |
|
|
|
var self = this; |
|
|
|
// Use to compute the sum of the outerWidth of all tab |
|
|
|
var widthChilds = this.widgets.map(function (column) { |
|
|
|
return self.$('.o_kanban_mobile_tab[data-id="' + (column.id || column.db_id) + '"]').outerWidth(); |
|
|
|
}).reduce(function (a, b) { |
|
|
|
return a + b; |
|
|
|
}); |
|
|
|
// Apply a space around between child if the parent length is higher then the sum of the child width |
|
|
|
var $oKanbanMobileTabs = this.$('.o_kanban_mobile_tabs'); |
|
|
|
if ($oKanbanMobileTabs.outerWidth() >= widthChilds) { |
|
|
|
$oKanbanMobileTabs.addClass('justify-content-around'); |
|
|
|
} else { |
|
|
|
$oKanbanMobileTabs.removeClass('justify-content-around'); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
/** |
|
|
|
* Compute the scroll x value for the tabs |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
_computeTabScrollPosition: function () { |
|
|
|
if (this.widgets && this.widgets.length) { |
|
|
|
var lastItemIndex = this.widgets.length - 1; |
|
|
|
var moveToIndex = this.activeColumnIndex; |
|
|
|
// update the columns and tabs positions (optionally with an animation) |
|
|
|
var updateFunc = animate ? 'animate' : 'css'; |
|
|
|
_.each(self.widgets, function (column, index) { |
|
|
|
var columnID = column.id || column.db_id; |
|
|
|
var $tab = self.$('.o_kanban_mobile_tab[data-id="' + columnID + '"]'); |
|
|
|
if (index === moveToIndex - 1) { |
|
|
|
$tab[updateFunc]({left: '0%'}); |
|
|
|
} else if (index === moveToIndex + 1) { |
|
|
|
$tab[updateFunc]({left: '100%'}); |
|
|
|
} else if (index === moveToIndex) { |
|
|
|
$tab[updateFunc]({left: '50%'}); |
|
|
|
} else if (index < moveToIndex) { |
|
|
|
$tab[updateFunc]({left: '-100%'}); |
|
|
|
} else if (index > moveToIndex) { |
|
|
|
$tab[updateFunc]({left: '200%'}); |
|
|
|
var scrollToLeft = 0; |
|
|
|
for (var i = 0; i < moveToIndex; i++) { |
|
|
|
var $tab = this.$('.o_kanban_mobile_tab[data-id="' + (this.widgets[i].id || this.widgets[i].db_id) + '"]'); |
|
|
|
if (moveToIndex !== lastItemIndex && i === moveToIndex - 1) { |
|
|
|
scrollToLeft += $tab.outerWidth() * 0.75; |
|
|
|
} else { |
|
|
|
scrollToLeft += $tab.outerWidth(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
// Apply the scroll x on the tabs |
|
|
|
this.$('.o_kanban_mobile_tabs').scrollLeft(scrollToLeft); |
|
|
|
} |
|
|
|
}, |
|
|
|
/** |
|
|
|
* Update the tabs positions |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
_computeTabPosition: function () { |
|
|
|
this._computeTabHeaderJustifyContent(); |
|
|
|
this._computeTabScrollPosition(); |
|
|
|
}, |
|
|
|
/** |
|
|
|
* Update the columns positions |
|
|
|
* @private |
|
@@ -208,7 +232,7 @@ KanbanRenderer.include({ |
|
|
|
*/ |
|
|
|
_moveToGroupUpdateLayoutKanban : function (animate) { |
|
|
|
this._computeOCurrentClass(); |
|
|
|
this._computeTabPosition(animate); |
|
|
|
this._computeTabPosition(); |
|
|
|
this._computeColumnPosition(animate); |
|
|
|
}, |
|
|
|
/** |
|
|
0 comments on commit
74afbf9