This commit is contained in:
2026-05-20 08:41:40 +02:00
parent a9bf6fbb60
commit 9b5f12bc94
7 changed files with 381 additions and 24 deletions

View File

@@ -1278,6 +1278,11 @@ var Sao = {
Mousetrap.bind(['ctrl+m', 'command+m'], function(e) {
e.preventDefault();
jQuery('.row-offcanvas').toggleClass('active');
[0, 80, 180, 320].forEach(function(delay) {
window.setTimeout(function() {
window.dispatchEvent(new Event('resize'));
}, delay);
});
return false;
});
}
@@ -12422,6 +12427,23 @@ var Sao = {
'class': 'row'
}).appendTo(this.filter_box);
this.el.append(this.filter_box);
this.ag_grid_filter_toggle_bar = jQuery('<div/>', {
'class': 'ag-grid-screen-filter-toggle-bar',
}).hide();
this.ag_grid_filter_toggle = jQuery('<button/>', {
'type': 'button',
'class': 'btn btn-default btn-sm ag-grid-screen-filter-toggle',
'aria-expanded': 'true',
'title': Sao.i18n.gettext('Hide filters'),
}).append(Sao.common.ICONFACTORY.get_icon_img('tryton-unfold-less', {
'aria-hidden': true,
})).append(jQuery('<span/>', {
'class': 'ag-grid-screen-filter-toggle-label',
'text': ' ' + Sao.i18n.gettext('Hide filters'),
})).appendTo(this.ag_grid_filter_toggle_bar);
this.ag_grid_filter_toggle.click(
this.toggle_ag_grid_filters.bind(this));
this.el.append(this.ag_grid_filter_toggle_bar);
this.filter_button = jQuery('<button/>', {
type: 'button',
'class': 'btn btn-link',
@@ -12802,17 +12824,83 @@ var Sao = {
this.tab.hide();
}
},
toggle_ag_grid_filters: function() {
this.set_ag_grid_filters_collapsed(
!this.el.hasClass('ag-grid-screen-filters-collapsed'));
},
set_ag_grid_filters_collapsed: function(collapsed) {
this.el.toggleClass('ag-grid-screen-filters-collapsed', collapsed);
if (collapsed) {
this.filter_box.hide();
} else {
this.filter_box.show();
}
if (this.ag_grid_filter_toggle) {
this.ag_grid_filter_toggle
.attr('aria-expanded', String(!collapsed))
.attr('title', Sao.i18n.gettext(
collapsed ? 'Show filters' : 'Hide filters'));
this.ag_grid_filter_toggle
.find('img.icon')
.replaceWith(Sao.common.ICONFACTORY.get_icon_img(
collapsed ? 'tryton-unfold-more' :
'tryton-unfold-less', {
'aria-hidden': true,
}));
this.ag_grid_filter_toggle
.find('.ag-grid-screen-filter-toggle-label')
.text(' ' + Sao.i18n.gettext(
collapsed ? 'Show filters' : 'Hide filters'));
}
window.setTimeout(() => {
window.dispatchEvent(new Event('resize'));
}, 0);
},
set_ag_grid_filter_toggle_visible: function(visible) {
if (!this.ag_grid_filter_toggle_bar) {
return;
}
this.el.toggleClass('ag-grid-screen-with-filter-toggle', visible);
if (visible) {
this.ag_grid_filter_toggle_bar.show();
this.set_ag_grid_filters_collapsed(
this.el.hasClass('ag-grid-screen-filters-collapsed'));
} else {
this.ag_grid_filter_toggle_bar.hide();
this.el.removeClass('ag-grid-screen-filters-collapsed');
}
},
set: function(widget) {
if (this.alternate_view) {
this.alternate_viewport.children().detach();
this.alternate_viewport.append(widget);
} else {
var is_ag_grid = Boolean(widget && widget.hasClass &&
widget.hasClass('ag-grid-tree-container'));
this.content_box.children().detach();
this.content_box.toggleClass(
'ag-grid-content-box',
Boolean(widget && widget.hasClass &&
widget.hasClass('ag-grid-tree-container')));
is_ag_grid);
if (!is_ag_grid) {
this.content_box.css({
height: '',
minHeight: '',
flexBasis: '',
flexShrink: '',
width: '',
maxWidth: '',
});
}
this.content_box.append(widget);
if (is_ag_grid) {
var toolbar = widget.find('.ag-grid-tree-toolbar').first();
if (toolbar.length) {
toolbar.append(this.ag_grid_filter_toggle_bar);
}
} else {
this.el.append(this.ag_grid_filter_toggle_bar);
}
this.set_ag_grid_filter_toggle_visible(is_ag_grid);
}
},
get_text: function() {
@@ -26393,11 +26481,35 @@ function eval_pyson(value){
return;
}
var rect = this.grid_host[0].getBoundingClientRect();
var available = window.innerHeight - rect.top - 36;
var height = Math.max(420, Math.min(720, available));
height = Math.max(520, height);
var content_box = this.grid_host.closest('.content-box.ag-grid-content-box');
var screen_container = this.grid_host.closest('.screen-container');
var toolbar_height = this.toolbar && this.toolbar.length ?
Math.ceil(this.toolbar.outerHeight(true)) : 0;
var external_scroll_height = 20;
var bottom_margin = 96;
var available = window.innerHeight - rect.top -
external_scroll_height - bottom_margin;
if (content_box.length) {
var content_rect = content_box[0].getBoundingClientRect();
available = Math.min(
available,
window.innerHeight - content_rect.top - toolbar_height -
external_scroll_height - bottom_margin);
}
var compact_min_height = 260;
var readable_min_height = 420;
var maximum_height = 720;
var height;
if (available >= compact_min_height) {
height = Math.max(
compact_min_height,
Math.min(maximum_height, available));
} else {
height = Math.max(
readable_min_height,
Math.min(maximum_height,
window.innerHeight - rect.top - bottom_margin));
}
var width_right = window.innerWidth - 12;
if (screen_container.length) {
width_right = Math.min(
@@ -26413,9 +26525,6 @@ function eval_pyson(value){
width: available_width + 'px',
maxWidth: available_width + 'px',
});
var toolbar_height = this.toolbar && this.toolbar.length ?
Math.ceil(this.toolbar.outerHeight(true)) : 0;
var external_scroll_height = 20;
var container_height = height + toolbar_height + external_scroll_height;
this.el.css({
height: container_height + 'px',