ObjectGrid: add helpers to add editor

This commit is contained in:
Dietmar Maurer 2017-02-24 17:43:49 +01:00
parent 7ec6cd9e86
commit 0e49da6db9
2 changed files with 64 additions and 0 deletions

View File

@ -75,6 +75,10 @@ Ext.define('Proxmox.Utils', { utilities: {
return !value ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
},
format_enabled_toggle: function(value) {
return value ? Proxmox.Utils.enabledText : Proxmox.Utils.disabledText;
},
authOK: function() {
return (Proxmox.UserName !== '') && Ext.util.Cookies.get(Proxmox.Setup.auth_cookie_name);
},

View File

@ -22,6 +22,66 @@ Ext.define('Proxmox.grid.ObjectGrid', {
disabled: false,
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
run_editor: function() {