2015-07-03 11:29:11 +02:00
Ext . define ( 'PVE.form.HotplugFeatureSelector' , {
2016-05-11 11:40:31 +02:00
extend : 'Ext.form.CheckboxGroup' ,
alias : 'widget.pveHotplugFeatureSelector' ,
2015-07-03 11:29:11 +02:00
2016-05-11 11:40:31 +02:00
columns : 1 ,
vertical : true ,
items : [
{ boxLabel : gettext ( 'Disk' ) , name : 'hotplug' , inputValue : 'disk' , submitValue : false , checked : true } ,
{ boxLabel : gettext ( 'Network' ) , name : 'hotplug' , inputValue : 'network' , submitValue : false , checked : true } ,
2017-11-08 16:10:27 +01:00
{ boxLabel : 'USB' , name : 'hotplug' , inputValue : 'usb' , submitValue : false , checked : true } ,
2016-05-11 11:40:31 +02:00
{ boxLabel : gettext ( 'Memory' ) , name : 'hotplug' , inputValue : 'memory' , submitValue : false } ,
{ boxLabel : gettext ( 'CPU' ) , name : 'hotplug' , inputValue : 'cpu' , submitValue : false }
] ,
2015-07-03 11:29:11 +02:00
2016-05-11 11:40:31 +02:00
setValue : function ( value ) {
2015-07-03 11:29:11 +02:00
var me = this ;
2016-05-11 11:40:31 +02:00
var newVal = [ ] ;
if ( value === '1' ) {
newVal = [ 'disk' , 'network' , 'usb' ] ;
} else if ( value !== '0' ) {
newVal = value . split ( ',' ) ;
2015-07-03 11:29:11 +02:00
}
2016-05-11 11:40:31 +02:00
me . callParent ( [ { hotplug : newVal } ] ) ;
2015-07-03 11:29:11 +02:00
} ,
2016-05-11 11:40:31 +02:00
// overide framework function to
// assemble the hotplug value
2015-07-03 11:29:11 +02:00
getSubmitData : function ( ) {
2016-05-11 11:40:31 +02:00
var me = this ,
boxes = me . getBoxes ( ) ,
data = [ ] ;
Ext . Array . forEach ( boxes , function ( box ) {
if ( box . getValue ( ) ) {
data . push ( box . inputValue ) ;
2015-07-03 11:29:11 +02:00
}
2016-05-11 11:40:31 +02:00
} ) ;
/* because above is hotplug an array */
/*jslint confusion: true*/
if ( data . length === 0 ) {
return { 'hotplug' : '0' } ;
} else {
return { 'hotplug' : data . join ( ',' ) } ;
}
2016-04-29 12:06:28 +02:00
}
2016-05-11 11:40:31 +02:00
2015-07-03 11:29:11 +02:00
} ) ;