[FIX] correct some issues with scrolling area

the height of the oe_view_manager_header is variable, and the top can't
be positioned correctly with pure css without a lot of work, so this
commit adds a touch of javascript to make sure that the view is
correctly positioned.
This commit is contained in:
Géry Debongnie 2014-05-27 14:21:52 +02:00
parent bb8b659ce3
commit 70052e1fd6
3 changed files with 23 additions and 14 deletions

View File

@ -691,7 +691,6 @@
.openerp .oe_mail_wall > div {
position: absolute;
overflow: auto;
top: 48px;
bottom: 0;
left: 0;
right: 0;

View File

@ -387,6 +387,8 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
this.headless = this.options.hidden && !this.has_defaults;
this.input_subviews = [];
this.view_manager = null;
this.$view_manager_header = null;
this.ready = $.Deferred();
this.drawer_ready = $.Deferred();
@ -398,11 +400,14 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
var self = this;
var p = this._super();
this.$view_manager_header = this.$el.parents(".oe_view_manager_header").first();
this.setup_global_completion();
this.query = new my.SearchQuery()
.on('add change reset remove', this.proxy('do_search'))
.on('change', this.proxy('renderChangedFacets'))
.on('add reset remove', this.proxy('renderFacets'));
.on('add reset remove', this.proxy('renderFacets'))
.on('add change reset remove', this.proxy('adjust_view_top'));
if (this.options.hidden) {
this.$el.hide();
@ -432,21 +437,13 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
}
if (view_manager) {
this.view_manager = view_manager;
view_manager.on('switch_mode', this, function (e) {
self.drawer.toggle(e === 'graph');
});
$(window).resize(this.proxy("adjust_view_top"));
}
$(window).resize(this.adjust_top.bind(this));
return $.when(p, this.ready).then(this.adjust_top.bind(this));
},
adjust_top: function () {
// hack to adjust the top of the view manager body to the actual header height
var parent = this.getParent();
if (parent && parent.$) {
var h = parent.$(".oe_view_manager_header").height() + 1;
parent.$(".oe_view_manager_body").css('top', h + 'px');
}
return $.when(p, this.ready);
},
set_drawer: function (drawer) {
@ -645,6 +642,18 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
});
},
// hack to adjust the top of the view body to the actual header height
// the best way would be to do that with pure css, but this cannot be done
// without giving up IE9 support (flexbox/grid) or without reworking the
// full client structure (switching from tables to a sane responsive layout with
// divs).
adjust_view_top: function () {
if (this.$view_manager_header.length) {
var height = this.$view_manager_header.height() + 1;
this.$view_manager_header.next().css('top', height + 'px');
}
},
search_view_loaded: function(data) {
var self = this;
this.fields_view = data;

View File

@ -607,7 +607,6 @@ instance.web.ViewManager = instance.web.Widget.extend({
// If no default view defined, switch to the first one in sequence
var default_view = this.flags.default_view || this.views_src[0].view_type;
return this.switch_mode(default_view, null, this.flags[default_view] && this.flags[default_view].options);
@ -705,6 +704,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
self.trigger("controller_inited",view_type,controller);
});
},
/**
* @returns {Number|Boolean} the view id of the given type, false if not found
*/
@ -1071,6 +1071,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
view_manager: self
}));
self.set_title();
self.searchview.adjust_view_top();
});
},
do_create_view: function(view_type) {