extjs: add parseBoolean for drive backup and iothreads

The backup and iothread options are now boolean types
internally instead of strings and need to be treated as
such.

Added a parseBoolean() function to deal with this with an
optional default value to use for undefined values.

The default for an undefined backup value is true.
This commit is contained in:
Wolfgang Bumiller 2016-01-29 10:26:23 +01:00 committed by Dietmar Maurer
parent 7a4c3133bc
commit 8aebff91f5
2 changed files with 12 additions and 2 deletions

View File

@ -5,6 +5,16 @@ Ext.define('PVE.Parser', { statics: {
// this class only contains static functions
parseBoolean: function(value, default_value) {
if (!Ext.isDefined(value))
return default_value;
value = value.toLowerCase();
return value === 1 || value === '1' ||
value === 'on' ||
value === 'yes' ||
value === 'true';
},
parseQemuNetwork: function(key, value) {
if (!(key && value)) {
return;

View File

@ -90,11 +90,11 @@ Ext.define('PVE.qemu.HDInputPanel', {
}
values.hdimage = drive.file;
values.nobackup = (drive.backup === 'no');
values.nobackup = !PVE.Parser.parseBoolean(drive.backup, 1);
values.diskformat = drive.format || 'raw';
values.cache = drive.cache || '';
values.discard = (drive.discard === 'on');
values.iothread = (drive.iothread === 'on');
values.iothread = PVE.Parser.parseBoolean(drive.iothread);
me.setValues(values);
},