]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/form/HotplugFeatureSelector.js
perl: fix some common typos found with codespell
[pve-manager.git] / www / manager6 / form / HotplugFeatureSelector.js
CommitLineData
b85427b9 1Ext.define('PVE.form.HotplugFeatureSelector', {
4dcca8a4
DC
2 extend: 'Ext.form.CheckboxGroup',
3 alias: 'widget.pveHotplugFeatureSelector',
b85427b9 4
4dcca8a4
DC
5 columns: 1,
6 vertical: true,
6f32c97f
TL
7
8 defaults: {
9 name: 'hotplug',
10 submitValue: false
11 },
4dcca8a4 12 items: [
6f32c97f
TL
13 {
14 boxLabel: gettext('Disk'),
15 inputValue: 'disk',
16 checked: true
17 },
18 {
19 boxLabel: gettext('Network'),
20 inputValue: 'network',
21 checked: true
22 },
23 {
24 boxLabel: 'USB',
25 inputValue: 'usb',
26 checked: true
27 },
28 {
29 boxLabel: gettext('Memory'),
30 inputValue: 'memory'
31 },
32 {
33 boxLabel: gettext('CPU'),
34 inputValue: 'cpu'
35 }
4dcca8a4 36 ],
b85427b9 37
4dcca8a4 38 setValue: function(value) {
b85427b9 39 var me = this;
4dcca8a4
DC
40 var newVal = [];
41 if (value === '1') {
42 newVal = ['disk', 'network', 'usb'];
43 } else if (value !== '0') {
44 newVal = value.split(',');
b85427b9 45 }
4dcca8a4 46 me.callParent([{ hotplug: newVal }]);
b85427b9
DM
47 },
48
4dcca8a4
DC
49 // overide framework function to
50 // assemble the hotplug value
b85427b9 51 getSubmitData: function() {
4dcca8a4
DC
52 var me = this,
53 boxes = me.getBoxes(),
54 data = [];
55 Ext.Array.forEach(boxes, function(box){
56 if (box.getValue()) {
57 data.push(box.inputValue);
b85427b9 58 }
4dcca8a4
DC
59 });
60
61 /* because above is hotplug an array */
62 /*jslint confusion: true*/
63 if (data.length === 0) {
64 return { 'hotplug':'0' };
65 } else {
66 return { 'hotplug': data.join(',') };
67 }
22f2f9d6 68 }
4dcca8a4 69
b85427b9 70});