mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-17 20:23:28 +00:00
ui: qemu: disk edit: refactor to more declarative style using bindings
would technically require a versioned dependency bump to widget toolkit as the `clearOnDisable` flag is new in 3.4-2, but this is really only for slight UX improvement, so avoid the hard dependency bump.. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
1e3033bc8f
commit
3f543d7ff7
@ -10,29 +10,23 @@ Ext.define('PVE.qemu.HDInputPanel', {
|
|||||||
|
|
||||||
vmconfig: {}, // used to select usused disks
|
vmconfig: {}, // used to select usused disks
|
||||||
|
|
||||||
viewModel: {},
|
viewModel: {
|
||||||
|
data: {
|
||||||
|
isScsi: false,
|
||||||
|
isVirtIO: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
controller: {
|
controller: {
|
||||||
|
|
||||||
xclass: 'Ext.app.ViewController',
|
xclass: 'Ext.app.ViewController',
|
||||||
|
|
||||||
onControllerChange: function(field) {
|
onControllerChange: function(field) {
|
||||||
let me = this;
|
let me = this;
|
||||||
var value = field.getValue();
|
let vm = this.getViewModel();
|
||||||
|
|
||||||
var allowIOthread = value.match(/^(virtio|scsi)/);
|
let value = field.getValue();
|
||||||
me.lookup('iothread').setDisabled(!allowIOthread);
|
vm.set('isSCSI', value.match(/^scsi/));
|
||||||
if (!allowIOthread) {
|
vm.set('isVirtIO', value.match(/^virtio/));
|
||||||
me.lookup('iothread').setValue(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
var virtio = value.match(/^virtio/);
|
|
||||||
me.lookup('ssd').setDisabled(virtio);
|
|
||||||
if (virtio) {
|
|
||||||
me.lookup('ssd').setValue(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
me.lookup('scsiController').setVisible(value.match(/^scsi/));
|
|
||||||
|
|
||||||
me.fireIdChange();
|
me.fireIdChange();
|
||||||
},
|
},
|
||||||
@ -66,6 +60,10 @@ Ext.define('PVE.qemu.HDInputPanel', {
|
|||||||
if (view.isCreate) {
|
if (view.isCreate) {
|
||||||
vm.set('isIncludedInBackup', true);
|
vm.set('isIncludedInBackup', true);
|
||||||
}
|
}
|
||||||
|
if (view.confid) {
|
||||||
|
vm.set('isSCSI', view.confid.match(/^scsi/));
|
||||||
|
vm.set('isVirtIO', view.confid.match(/^virtio/));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -199,7 +197,10 @@ Ext.define('PVE.qemu.HDInputPanel', {
|
|||||||
reference: 'scsiController',
|
reference: 'scsiController',
|
||||||
bind: me.insideWizard ? {
|
bind: me.insideWizard ? {
|
||||||
value: '{current.scsihw}',
|
value: '{current.scsihw}',
|
||||||
} : undefined,
|
visible: '{isSCSI}',
|
||||||
|
} : {
|
||||||
|
visible: '{isSCSI}',
|
||||||
|
},
|
||||||
renderer: PVE.Utils.render_scsihw,
|
renderer: PVE.Utils.render_scsihw,
|
||||||
submitValue: false,
|
submitValue: false,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
@ -255,19 +256,23 @@ Ext.define('PVE.qemu.HDInputPanel', {
|
|||||||
advancedColumn1.push(
|
advancedColumn1.push(
|
||||||
{
|
{
|
||||||
xtype: 'proxmoxcheckbox',
|
xtype: 'proxmoxcheckbox',
|
||||||
disabled: me.confid && me.confid.match(/^virtio/),
|
|
||||||
fieldLabel: gettext('SSD emulation'),
|
fieldLabel: gettext('SSD emulation'),
|
||||||
labelWidth: labelWidth,
|
labelWidth: labelWidth,
|
||||||
name: 'ssd',
|
name: 'ssd',
|
||||||
reference: 'ssd',
|
clearOnDisable: true,
|
||||||
|
bind: {
|
||||||
|
disabled: '{!isVirtIO}',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
xtype: 'proxmoxcheckbox',
|
xtype: 'proxmoxcheckbox',
|
||||||
disabled: me.confid && !me.confid.match(/^(virtio|scsi)/),
|
name: 'iothread',
|
||||||
fieldLabel: 'IO thread',
|
fieldLabel: 'IO thread',
|
||||||
labelWidth: labelWidth,
|
labelWidth: labelWidth,
|
||||||
reference: 'iothread',
|
clearOnDisable: true,
|
||||||
name: 'iothread',
|
bind: {
|
||||||
|
disabled: '{!isVirtIO && !isSCSI}',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user