[pve-devel] r5927 - in pve-manager/pve2/www/new: qemu window
svn-commits at proxmox.com
svn-commits at proxmox.com
Mon May 9 09:11:15 CEST 2011
Author: dietmar
Date: 2011-05-09 09:11:15 +0200 (Mon, 09 May 2011)
New Revision: 5927
Modified:
pve-manager/pve2/www/new/qemu/CreateWizard.js
pve-manager/pve2/www/new/window/Wizard.js
Log:
cleanups
Modified: pve-manager/pve2/www/new/qemu/CreateWizard.js
===================================================================
--- pve-manager/pve2/www/new/qemu/CreateWizard.js 2011-05-09 05:31:26 UTC (rev 5926)
+++ pve-manager/pve2/www/new/qemu/CreateWizard.js 2011-05-09 07:11:15 UTC (rev 5927)
@@ -90,8 +90,7 @@
allowBlank: true
}
],
- getValues: function() {
- var values = this.getFieldValues();
+ onGetValues: function(values) {
if (!values.name)
delete values.name;
return values;
@@ -200,8 +199,7 @@
boxLabel: 'Do not use any installation media'
}
],
- getValues: function() {
- var values = this.getFieldValues();
+ onGetValues: function(values) {
if (values.mediaType === 'iso')
return { cdrom: values.cdimage };
if (values.mediaType === 'cdrom')
@@ -262,8 +260,7 @@
boxLabel: 'Do not attach a hard disk'
}
],
- getValues: function() {
- var values = this.getFieldValues();
+ onGetValues: function(values) {
if (values.hdType === 'none')
return {};
@@ -286,7 +283,14 @@
maxValue: 4,
value: 1,
fieldLabel: 'Sockets',
- allowBlank: false
+ allowBlank: false,
+ listeners: {
+ change: function(f, value) {
+ var sockets = me.down('field[name=sockets]').getValue();
+ var cores = me.down('field[name=cores]').getValue();
+ me.down('field[name=totalcores]').setValue(sockets*cores);
+ }
+ }
},
{
xtype: 'numberfield',
@@ -295,7 +299,20 @@
maxValue: 32,
value: 1,
fieldLabel: 'Cores',
- allowBlank: false
+ allowBlank: false,
+ listeners: {
+ change: function(f, value) {
+ var sockets = me.down('field[name=sockets]').getValue();
+ var cores = me.down('field[name=cores]').getValue();
+ me.down('field[name=totalcores]').setValue(sockets*cores);
+ }
+ }
+ },
+ {
+ xtype: 'displayfield',
+ fieldLabel: 'Total cores',
+ name: 'totalcores',
+ value: 1
}
]
},
@@ -340,8 +357,7 @@
emptyText: 'auto'
}
],
- getValues: function() {
- var values = this.getFieldValues();
+ onGetValues: function(values) {
var str = values.netcard;
if (values.mac)
str += '=' + values.mac;
@@ -367,7 +383,7 @@
listeners: {
show: function(panel) {
var form = me.down('form').getForm();
- var kv = me.getFieldValues();
+ var kv = me.getValues();
var data = [];
Ext.Object.each(kv, function(key, value) {
var html = Ext.htmlEncode(Ext.JSON.encode(value));
@@ -380,7 +396,7 @@
},
onSubmit: function() {
//var form = me.down('form').getForm();
- var kv = me.getFieldValues();
+ var kv = me.getValues();
console.dir(kv);
}
}
Modified: pve-manager/pve2/www/new/window/Wizard.js
===================================================================
--- pve-manager/pve2/www/new/window/Wizard.js 2011-05-09 05:31:26 UTC (rev 5926)
+++ pve-manager/pve2/www/new/window/Wizard.js 2011-05-09 07:11:15 UTC (rev 5927)
@@ -5,19 +5,24 @@
],
alias: ['widget.inputpanel'],
- getFieldValues: function(dirtyOnly) {
+ getValues: function(dirtyOnly) {
var me = this;
+ if (Ext.isFunction(me.onGetValues))
+ dirtyOnly = false;
+
var values = {};
Ext.Array.each(me.query('[isFormField]'), function(field) {
if (!dirtyOnly || field.isDirty()) {
- PVE.Utils.assemble_field_data(values, field.getModelData());
+ PVE.Utils.assemble_field_data(values, field.getSubmitData());
}
});
- return values;
-
+ if (Ext.isFunction(me.onGetValues))
+ return me.onGetValues(values, dirtyOnly);
+
+ return values;
},
initComponent: function() {
@@ -36,7 +41,7 @@
'PVE.Utils'
],
- getFieldValues: function(dirtyOnly) {
+ getValues: function(dirtyOnly) {
var me = this;
var values = {};
@@ -45,15 +50,12 @@
form.getFields().each(function(field) {
if (!field.up('inputpanel') && (!dirtyOnly || field.isDirty())) {
- PVE.Utils.assemble_field_data(values, field.getModelData());
+ PVE.Utils.assemble_field_data(values, field.getSubmitData());
}
});
Ext.Array.each(me.query('inputpanel'), function(panel) {
- if (Ext.isFunction(panel.getValues))
- PVE.Utils.assemble_field_data(values, panel.getValues(dirtyOnly));
- else
- PVE.Utils.assemble_field_data(values, panel.getFieldValues(dirtyOnly));
+ PVE.Utils.assemble_field_data(values, panel.getValues(dirtyOnly));
});
return values;
@@ -67,8 +69,9 @@
/*
* Items may have the following functions:
- * validate(): per tab custom validation
+ * validator(): per tab custom validation
* onSubmit(): submit handler
+ * onGetValues(): overwrite getValues results
*/
Ext.Array.each(tabs, function(tab) {
@@ -84,8 +87,8 @@
valid = false;
});
- if (Ext.isFunction(card.validate))
- return card.validate();
+ if (Ext.isFunction(card.validator))
+ return card.validator();
return valid;
};
More information about the pve-devel
mailing list