mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-08-12 11:46:03 +00:00
new helper Proxmox.Utils.compute_min_label_width()
This commit is contained in:
parent
211267b8cc
commit
28e54f37df
10
Utils.js
10
Utils.js
@ -79,6 +79,16 @@ Ext.define('Proxmox.Utils', { utilities: {
|
|||||||
return value ? Proxmox.Utils.enabledText : Proxmox.Utils.disabledText;
|
return value ? Proxmox.Utils.enabledText : Proxmox.Utils.disabledText;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
compute_min_label_width: function(text, width) {
|
||||||
|
|
||||||
|
if (width === undefined) { width = 100; }
|
||||||
|
|
||||||
|
var tm = new Ext.util.TextMetrics();
|
||||||
|
var min = tm.getWidth(text + ':');
|
||||||
|
|
||||||
|
return min < width ? width : min;
|
||||||
|
},
|
||||||
|
|
||||||
authOK: function() {
|
authOK: function() {
|
||||||
return (Proxmox.UserName !== '') && Ext.util.Cookies.get(Proxmox.Setup.auth_cookie_name);
|
return (Proxmox.UserName !== '') && Ext.util.Cookies.get(Proxmox.Setup.auth_cookie_name);
|
||||||
},
|
},
|
||||||
|
@ -29,8 +29,6 @@ Ext.define('Proxmox.grid.ObjectGrid', {
|
|||||||
|
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
var tm = new Ext.util.TextMetrics();
|
|
||||||
|
|
||||||
me.rows[name] = {
|
me.rows[name] = {
|
||||||
required: true,
|
required: true,
|
||||||
defaultValue: opts.defaultValue || 0,
|
defaultValue: opts.defaultValue || 0,
|
||||||
@ -46,7 +44,8 @@ Ext.define('Proxmox.grid.ObjectGrid', {
|
|||||||
defaultValue: opts.defaultValue || 0,
|
defaultValue: opts.defaultValue || 0,
|
||||||
checked: opts.defaultValue ? true : false,
|
checked: opts.defaultValue ? true : false,
|
||||||
deleteDefaultValue: opts.deleteDefaultValue ? true : false,
|
deleteDefaultValue: opts.deleteDefaultValue ? true : false,
|
||||||
labelWidth: opts.labelWidth || tm.getWidth(text + ':'),
|
labelWidth: Proxmox.Utils.compute_min_label_width(
|
||||||
|
text, opts.labelWidth),
|
||||||
fieldLabel: text
|
fieldLabel: text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,8 +57,6 @@ Ext.define('Proxmox.grid.ObjectGrid', {
|
|||||||
|
|
||||||
opts = opts || {}
|
opts = opts || {}
|
||||||
|
|
||||||
var tm = new Ext.util.TextMetrics();
|
|
||||||
|
|
||||||
me.rows[name] = {
|
me.rows[name] = {
|
||||||
required: true,
|
required: true,
|
||||||
defaultValue: opts.defaultValue,
|
defaultValue: opts.defaultValue,
|
||||||
@ -75,7 +72,8 @@ Ext.define('Proxmox.grid.ObjectGrid', {
|
|||||||
emptyText: gettext('Default'),
|
emptyText: gettext('Default'),
|
||||||
deleteEmpty: true,
|
deleteEmpty: true,
|
||||||
value: opts.defaultValue,
|
value: opts.defaultValue,
|
||||||
labelWidth: opts.labelWidth || tm.getWidth(text + ':'),
|
labelWidth: Proxmox.Utils.compute_min_label_width(
|
||||||
|
text, opts.labelWidth),
|
||||||
fieldLabel: text
|
fieldLabel: text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user