From 4febc669d58c71310c4257efd2896b9ba4399e98 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 29 May 2020 19:31:02 +0200 Subject: [PATCH] utils: add updateColumnWidth helper from PVE Signed-off-by: Thomas Lamprecht --- Utils.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Utils.js b/Utils.js index 480c11d..8548711 100644 --- a/Utils.js +++ b/Utils.js @@ -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) {