[FIX] web: calendar: avoid rerendering on resize

Before this commit, when a calendar view was resized the full view was
rendered again to recalculate the resize.

After this commit, we now set manually the new size.
This avoid to lose the current position-y in the calendar.

Steps to reproduce:
* Open a window (not maximized)
* Go to calendar (day/week view)
* Scroll to the end of the calendar
* Resize the window => the calendar returns to the begging.

Note:
By the same way it also fixes a performance issue in TimeOff's render as
it makes an RPC to calculate the popover for the year view.

Task ID: 2200168 (5.a)

closes odoo/odoo#66387

Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
This commit is contained in:
Romeo Fragomeli
2021-03-11 14:59:45 +00:00
parent 46c4e6fc56
commit b11eabbfd7
@@ -524,7 +524,7 @@ return AbstractRenderer.extend({
return 'popover';
},
windowResize: function () {
self._render();
self._onWindowResize();
},
views: {
timeGridDay: {
@@ -981,6 +981,16 @@ return AbstractRenderer.extend({
this._unselectEvent();
}
},
/**
* Handler for resize event.
* As the result it will resize the calendar to fit the window space.
*
* @private
*/
_onWindowResize: function () {
this.$el.height($(window).height() - this.$el.offset().top);
this.calendar.updateSize();
},
/**
* @private
* @param {OdooEvent} event