pve-manager/www/manager6/form/HotplugFeatureSelector.js
Emmanuel Kasper 548b29644d adapt KVComboBoxes to pass store items using 'comboItems' parameter
we used a custom 'data' property to pass around the items to
add to the store, but this property is now used by ExtJS to
store content for the component template

also move to declarative style, saves lines
2016-03-04 06:17:25 +01:00

50 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)) {
if (value === '0') {
value = [];
} else if (value === '1') {
value = ['disk', 'network', 'usb'];
} else {
value = value.split(',');
}
}
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;
},
});