mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-06-10 01:28:06 +00:00

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
50 lines
1.2 KiB
JavaScript
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;
|
|
},
|
|
});
|