pve-manager/www/manager6/form/HotplugFeatureSelector.js
Dominik Csapak ec0bd652db jslint: fix type confusion and property access
fix various type confusion, for example:
items: {} and items: []
style: string and style: {}

also fix object['property'] access with
object.property

also fix /=/ with either '=' or /\=/ where appropriate
(/=/ can be confused with /= according to jslint)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2016-04-29 17:06:23 +02:00

52 lines
1.2 KiB
JavaScript

Ext.define('PVE.form.HotplugFeatureSelector', {
extend: 'PVE.form.KVComboBox',
alias: ['widget.pveHotplugFeatureSelector'],
multiSelect: true,
allowBlank: true,
deleteEmpty: false,
comboItems: [['disk', gettext('Disk')],
['network', gettext('Network')],
['usb', gettext('USB')],
['memory', gettext('Memory')],
['cpu', gettext('CPU')]],
setValue: function(value, doSelect) {
var me = this;
if (me.multiSelect && Ext.isString(value)) {
var newVal;
if (value === '0') {
newVal = [];
} else if (value === '1') {
newVal = ['disk', 'network', 'usb'];
} else {
newVal = value.split(',');
}
me.callParent([newVal, doSelect]);
}
me.callParent([value, doSelect]);
},
getSubmitData: function() {
var me = this,
data = null,
val;
if (!me.disabled && me.submitValue) {
val = me.getSubmitValue();
if (Ext.isArray(val)) {
val = val.join(',') || '0';
}
if (val !== null && val !== '') {
data = {};
data[me.getName()] = val;
} else if (me.deleteEmpty) {
data = {};
data['delete'] = me.getName();
}
}
return data;
},
});