From 04dde0026ef0c0ad761879bb30b43be947ad3894 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 23 Sep 2019 08:18:09 +0200 Subject: [PATCH] ui: vm/usbedit: use simple bind for radio button changes reduces code and is more expressive Signed-off-by: Thomas Lamprecht --- www/manager6/qemu/USBEdit.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/www/manager6/qemu/USBEdit.js b/www/manager6/qemu/USBEdit.js index 1e854a2e3..c67634973 100644 --- a/www/manager6/qemu/USBEdit.js +++ b/www/manager6/qemu/USBEdit.js @@ -5,21 +5,14 @@ Ext.define('PVE.qemu.USBInputPanel', { autoComplete: false, onlineHelp: 'qm_usb_passthrough', + viewModel: { + data: {} + }, + controller: { xclass: 'Ext.app.ViewController', control: { - 'field[name=usb]': { - change: function(field, newValue, oldValue) { - var hwidfield = this.lookupReference('hwid'); - var portfield = this.lookupReference('port'); - if (field.inputValue === 'hostdevice') { - hwidfield.setDisabled(!newValue); - } else if(field.inputValue === 'port') { - portfield.setDisabled(!newValue); - } - } - }, 'pveUSBSelector': { change: function(field, newValue, oldValue) { var usbval = field.getUSBValue(); @@ -92,6 +85,7 @@ Ext.define('PVE.qemu.USBInputPanel', { name: 'usb', inputValue: 'hostdevice', boxLabel: gettext('Use USB Vendor/Device ID'), + reference: 'hostdevice', submitValue: false }, { @@ -100,8 +94,8 @@ Ext.define('PVE.qemu.USBInputPanel', { type: 'device', name: 'hostdevice', cbind: { pveSelNode: '{pveSelNode}' }, + bind: { disabled: '{!hostdevice.checked}' }, editable: true, - reference: 'hwid', allowBlank: false, fieldLabel: 'Choose Device', labelAlign: 'right', @@ -111,6 +105,7 @@ Ext.define('PVE.qemu.USBInputPanel', { name: 'usb', inputValue: 'port', boxLabel: gettext('Use USB Port'), + reference: 'port', submitValue: false }, { @@ -118,9 +113,9 @@ Ext.define('PVE.qemu.USBInputPanel', { disabled: true, name: 'port', cbind: { pveSelNode: '{pveSelNode}' }, + bind: { disabled: '{!port.checked}' }, editable: true, type: 'port', - reference: 'port', allowBlank: false, fieldLabel: gettext('Choose Port'), labelAlign: 'right',