[pve-devel] [PATCH manager v2 2/3] Use a View Controller for making components react to each other
Emmanuel Kasper
e.kasper at proxmox.com
Mon Jul 10 16:35:03 CEST 2017
This allow to declare all the components inside the same items
array, and separate behaviour from view better.
No functional changes.
---
www/manager6/qemu/CreateWizard.js | 71 ++++++++++++++++++++++-----------------
1 file changed, 40 insertions(+), 31 deletions(-)
diff --git a/www/manager6/qemu/CreateWizard.js b/www/manager6/qemu/CreateWizard.js
index 42de6ce0..57d90be8 100644
--- a/www/manager6/qemu/CreateWizard.js
+++ b/www/manager6/qemu/CreateWizard.js
@@ -3,6 +3,22 @@ Ext.define('PVE.qemu.CreateWizard', {
alias: 'widget.pveQemuCreateWizard',
qemuScsiController: undefined,
+ controller: {
+
+ xclass: 'Ext.app.ViewController',
+
+ control: {
+ 'field[name=nodename]': {
+ change: function(f, value) {
+ var me = this;
+ ['networkpanel', 'hdpanel', 'cdpanel'].forEach(function(reference) {
+ me.lookup(reference).setNodename(value);
+ });
+ }
+ }
+ }
+ },
+
initComponent: function() {
var me = this;
@@ -16,26 +32,6 @@ Ext.define('PVE.qemu.CreateWizard', {
]
});
- var cdpanel = Ext.create('PVE.qemu.CDInputPanel', {
- title: gettext('CD/DVD'),
- confid: 'ide2',
- fieldDefaults: {
- labelWidth: 160
- },
- insideWizard: true
- });
-
- var hdpanel = Ext.create('PVE.qemu.HDInputPanel', {
- title: gettext('Hard Disk'),
- isCreate: true,
- insideWizard: true
- });
-
- var networkpanel = Ext.create('PVE.qemu.NetworkInputPanel', {
- title: gettext('Network'),
- insideWizard: true
- });
-
Ext.applyIf(me, {
subject: gettext('Virtual Machine'),
items: [
@@ -51,14 +47,7 @@ Ext.define('PVE.qemu.CreateWizard', {
preferredValue: me.nodename,
fieldLabel: gettext('Node'),
allowBlank: false,
- onlineValidator: true,
- listeners: {
- change: function(f, value) {
- networkpanel.setNodename(value);
- hdpanel.setNodename(value);
- cdpanel.setNodename(value);
- }
- }
+ onlineValidator: true
},
{
xtype: 'pveGuestIDSelector',
@@ -101,8 +90,23 @@ Ext.define('PVE.qemu.CreateWizard', {
xtype: 'pveQemuOSTypePanel',
insideWizard: true
},
- cdpanel,
- hdpanel,
+ {
+ xtype: 'pveQemuCDInputPanel',
+ reference: 'cdpanel',
+ title: gettext('CD/DVD'),
+ confid: 'ide2',
+ fieldDefaults: {
+ labelWidth: 160
+ },
+ insideWizard: true
+ },
+ {
+ xtype: 'pveQemuHDInputPanel',
+ reference: 'hdpanel',
+ title: gettext('Hard Disk'),
+ isCreate: true,
+ insideWizard: true
+ },
{
xtype: 'pveQemuProcessorPanel',
title: gettext('CPU')
@@ -112,7 +116,12 @@ Ext.define('PVE.qemu.CreateWizard', {
insideWizard: true,
title: gettext('Memory')
},
- networkpanel,
+ {
+ xtype: 'pveQemuNetworkInputPanel',
+ reference: 'networkpanel',
+ title: gettext('Network'),
+ insideWizard: true
+ },
{
title: gettext('Confirm'),
layout: 'fit',
--
2.11.0
More information about the pve-devel
mailing list