]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/form/HotplugFeatureSelector.js
ui: enable gettext localisation for more user exposed strings
[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: {
f018c2d6 9 name: 'hotplugCbGroup',
f6710aac 10 submitValue: false,
6f32c97f 11 },
4dcca8a4 12 items: [
6f32c97f
TL
13 {
14 boxLabel: gettext('Disk'),
15 inputValue: 'disk',
f6710aac 16 checked: true,
6f32c97f
TL
17 },
18 {
19 boxLabel: gettext('Network'),
20 inputValue: 'network',
f6710aac 21 checked: true,
6f32c97f
TL
22 },
23 {
24 boxLabel: 'USB',
25 inputValue: 'usb',
f6710aac 26 checked: true,
6f32c97f
TL
27 },
28 {
29 boxLabel: gettext('Memory'),
f6710aac 30 inputValue: 'memory',
6f32c97f
TL
31 },
32 {
33 boxLabel: gettext('CPU'),
f6710aac
TL
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 }
f018c2d6 46 me.callParent([{ hotplugCbGroup: newVal }]);
b85427b9
DM
47 },
48
ec505260 49 // override framework function to
4dcca8a4 50 // assemble the hotplug value
b85427b9 51 getSubmitData: function() {
4dcca8a4
DC
52 var me = this,
53 boxes = me.getBoxes(),
54 data = [];
8058410f 55 Ext.Array.forEach(boxes, function(box) {
4dcca8a4
DC
56 if (box.getValue()) {
57 data.push(box.inputValue);
b85427b9 58 }
4dcca8a4
DC
59 });
60
61 /* because above is hotplug an array */
4dcca8a4 62 if (data.length === 0) {
8058410f 63 return { 'hotplug': '0' };
4dcca8a4
DC
64 } else {
65 return { 'hotplug': data.join(',') };
66 }
f6710aac 67 },
4dcca8a4 68
b85427b9 69});