utils: add updateColumnWidth helper from PVE

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-05-29 19:31:02 +02:00
parent e662b4a0b8
commit 4febc669d5

View File

@ -477,6 +477,36 @@ Ext.define('Proxmox.Utils', { utilities: {
}
},
updateColumnWidth: function(container) {
let mode = Ext.state.Manager.get('summarycolumns') || 'auto';
let factor;
if (mode !== 'auto') {
factor = parseInt(mode, 10);
if (Number.isNaN(factor)) {
factor = 1;
}
} else {
factor = container.getSize().width < 1600 ? 1 : 2;
}
if (container.oldFactor === factor) {
return;
}
let items = container.query('>'); // direct childs
factor = Math.min(factor, items.length);
container.oldFactor = factor;
items.forEach((item) => {
item.columnWidth = 1 / factor;
});
// we have to update the layout twice, since the first layout change
// can trigger the scrollbar which reduces the amount of space left
container.updateLayout();
container.updateLayout();
},
dialog_title: function(subject, create, isAdd) {
if (create) {
if (isAdd) {