mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-12 01:42:09 +00:00
ObjectGrid: add helpers to add editor
This commit is contained in:
parent
7ec6cd9e86
commit
0e49da6db9
4
Utils.js
4
Utils.js
@ -75,6 +75,10 @@ Ext.define('Proxmox.Utils', { utilities: {
|
|||||||
return !value ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
|
return !value ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
format_enabled_toggle: function(value) {
|
||||||
|
return value ? Proxmox.Utils.enabledText : Proxmox.Utils.disabledText;
|
||||||
|
},
|
||||||
|
|
||||||
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);
|
||||||
},
|
},
|
||||||
|
@ -22,6 +22,66 @@ Ext.define('Proxmox.grid.ObjectGrid', {
|
|||||||
disabled: false,
|
disabled: false,
|
||||||
hideHeaders: true,
|
hideHeaders: true,
|
||||||
|
|
||||||
|
rows: {},
|
||||||
|
|
||||||
|
add_boolean_row: function(name, text, opts) {
|
||||||
|
var me = this;
|
||||||
|
|
||||||
|
opts = opts || {};
|
||||||
|
|
||||||
|
var tm = new Ext.util.TextMetrics();
|
||||||
|
|
||||||
|
me.rows[name] = {
|
||||||
|
required: true,
|
||||||
|
defaultValue: opts.defaultValue || 0,
|
||||||
|
header: text,
|
||||||
|
renderer: opts.renderer || Proxmox.Utils.format_boolean,
|
||||||
|
editor: {
|
||||||
|
xtype: 'proxmoxWindowEdit',
|
||||||
|
subject: text,
|
||||||
|
items: {
|
||||||
|
xtype: 'proxmoxcheckbox',
|
||||||
|
name: name,
|
||||||
|
uncheckedValue: 0,
|
||||||
|
defaultValue: opts.defaultValue || 0,
|
||||||
|
checked: opts.defaultValue ? true : false,
|
||||||
|
deleteDefaultValue: opts.deleteDefaultValue ? true : false,
|
||||||
|
labelWidth: opts.labelWidth || tm.getWidth(text + ':'),
|
||||||
|
fieldLabel: text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
add_integer_row: function(name, text, opts) {
|
||||||
|
var me = this;
|
||||||
|
|
||||||
|
opts = opts || {}
|
||||||
|
|
||||||
|
var tm = new Ext.util.TextMetrics();
|
||||||
|
|
||||||
|
me.rows[name] = {
|
||||||
|
required: true,
|
||||||
|
defaultValue: opts.defaultValue,
|
||||||
|
header: text,
|
||||||
|
editor: {
|
||||||
|
xtype: 'proxmoxWindowEdit',
|
||||||
|
subject: text,
|
||||||
|
items: {
|
||||||
|
xtype: 'proxmoxintegerfield',
|
||||||
|
name: name,
|
||||||
|
minValue: opts.minValue,
|
||||||
|
maxValue: opts.maxValue,
|
||||||
|
emptyText: gettext('Default'),
|
||||||
|
deleteEmpty: true,
|
||||||
|
value: opts.defaultValue,
|
||||||
|
labelWidth: opts.labelWidth || tm.getWidth(text + ':'),
|
||||||
|
fieldLabel: text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
editorConfig: {}, // default config passed to editor
|
editorConfig: {}, // default config passed to editor
|
||||||
|
|
||||||
run_editor: function() {
|
run_editor: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user