mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-03 16:21:19 +00:00
Utils: refactor updateColumns from pve-manager
we want to reuse this in pbs Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
bf147dccb8
commit
d365540e14
30
src/Utils.js
30
src/Utils.js
@ -1060,6 +1060,36 @@ utilities: {
|
|||||||
}
|
}
|
||||||
return acme;
|
return acme;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateColumns: 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 < 1400 ? 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();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
singleton: true,
|
singleton: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user