]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/form/HotplugFeatureSelector.js
ui: eslint: fix various spacing related issues
[pve-manager.git] / www / manager6 / form / HotplugFeatureSelector.js
1 Ext.define('PVE.form.HotplugFeatureSelector', {
2 extend: 'Ext.form.CheckboxGroup',
3 alias: 'widget.pveHotplugFeatureSelector',
4
5 columns: 1,
6 vertical: true,
7
8 defaults: {
9 name: 'hotplugCbGroup',
10 submitValue: false,
11 },
12 items: [
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 },
36 ],
37
38 setValue: function(value) {
39 var me = this;
40 var newVal = [];
41 if (value === '1') {
42 newVal = ['disk', 'network', 'usb'];
43 } else if (value !== '0') {
44 newVal = value.split(',');
45 }
46 me.callParent([{ hotplugCbGroup: newVal }]);
47 },
48
49 // override framework function to
50 // assemble the hotplug value
51 getSubmitData: function() {
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);
58 }
59 });
60
61 /* because above is hotplug an array */
62 if (data.length === 0) {
63 return { 'hotplug': '0' };
64 } else {
65 return { 'hotplug': data.join(',') };
66 }
67 },
68
69 });