[FIX] web: web_client o_content is scrollable, not action manager
Go on a kanban view with a scroll bar
scroll all the way down
Open a record in form view
Use the breadcrumb to go back to the kanban
Before this commit, the kanban was re-opened
but the position were we were before opening the record was lost
This was due to 40dd121938
which refactors the dom, puting the action manager on top of controllers
After this commit, when re-opening the kanban, we end up at the same position
we left it at
OPW 2074077
closes odoo/odoo#39120
X-original-commit: c0d48878c452b256859f067186567c126d8de27e
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
committed by
fw-bot
parent
3a7bb6aefd
commit
52f67d87d1
@@ -311,6 +311,24 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMi
|
||||
this.$el.toggleClass('o_fullscreen', fullscreen);
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the left and top scroll positions of the main scrolling area
|
||||
* (i.e. the '.o_content' div in desktop).
|
||||
*
|
||||
* @returns {Object} with keys left and top
|
||||
*/
|
||||
getScrollPosition: function () {
|
||||
var scrollingEl = this.action_manager.el.getElementsByClassName('o_content')[0];
|
||||
return {
|
||||
left: scrollingEl ? scrollingEl.scrollLeft : 0,
|
||||
top: scrollingEl ? scrollingEl.scrollTop : 0,
|
||||
};
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Handlers
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -401,14 +419,15 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMi
|
||||
}
|
||||
},
|
||||
/**
|
||||
* This function must be implemented to provide to the caller the current
|
||||
* scroll position (left and top) of the webclient.
|
||||
* Provides to the caller the current scroll position (left and top) of the
|
||||
* main scrolling area of the webclient.
|
||||
*
|
||||
* @abstract
|
||||
* @private
|
||||
* @param {OdooEvent} ev
|
||||
* @param {function} ev.data.callback
|
||||
*/
|
||||
_onGetScrollPosition: function (ev) {
|
||||
ev.data.callback(this.getScrollPosition());
|
||||
},
|
||||
/**
|
||||
* Loads an action from the database given its ID.
|
||||
@@ -432,11 +451,10 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMi
|
||||
this.do_push_state(_.extend(e.data.state, {'cids': $.bbq.getState().cids}));
|
||||
},
|
||||
/**
|
||||
* This function must be implemented by actual webclient to scroll either to
|
||||
* a given offset or to a target element (given a selector).
|
||||
* Scrolls either to a given offset or to a target element (given a selector).
|
||||
* It must be called with: trigger_up('scrollTo', options).
|
||||
*
|
||||
* @abstract
|
||||
* @private
|
||||
* @param {OdooEvent} ev
|
||||
* @param {integer} [ev.data.top] the number of pixels to scroll from top
|
||||
* @param {integer} [ev.data.left] the number of pixels to scroll from left
|
||||
@@ -444,6 +462,19 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMi
|
||||
* scroll to
|
||||
*/
|
||||
_onScrollTo: function (ev) {
|
||||
var scrollingEl = this.action_manager.el.getElementsByClassName('o_content')[0];
|
||||
if (!scrollingEl) {
|
||||
return;
|
||||
}
|
||||
var offset = {top: ev.data.top, left: ev.data.left || 0};
|
||||
if (!offset.top) {
|
||||
offset = dom.getPosition(document.querySelector(ev.data.selector));
|
||||
// Substract the position of the scrolling element
|
||||
offset.top -= dom.getPosition(scrollingEl).top;
|
||||
}
|
||||
|
||||
scrollingEl.scrollTop = offset.top;
|
||||
scrollingEl.scrollLeft = offset.left;
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -238,49 +238,6 @@ return AbstractWebClient.extend({
|
||||
_openMenu: function (action, options) {
|
||||
return this.do_action(action, options);
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the left and top scroll positions of the main scrolling area
|
||||
* (i.e. the action manager in desktop).
|
||||
*
|
||||
* @returns {Object} with keys left and top
|
||||
*/
|
||||
getScrollPosition: function () {
|
||||
return {
|
||||
left: this.action_manager.el.scrollLeft,
|
||||
top: this.action_manager.el.scrollTop,
|
||||
};
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Handlers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @private
|
||||
*/
|
||||
_onGetScrollPosition: function (ev) {
|
||||
ev.data.callback(this.getScrollPosition());
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
* @private
|
||||
*/
|
||||
_onScrollTo: function (ev) {
|
||||
var offset = {top: ev.data.top, left: ev.data.left || 0};
|
||||
if (!offset.top) {
|
||||
offset = dom.getPosition(document.querySelector(ev.data.selector));
|
||||
// Substract the position of the action_manager as it is the scrolling part
|
||||
offset.top -= dom.getPosition(this.action_manager.el).top;
|
||||
}
|
||||
this.action_manager.el.scrollTop = offset.top;
|
||||
this.action_manager.el.scrollLeft = offset.left;
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user