[pve-devel] r5994 - in pve-manager/pve2/www/new: . node

svn-commits at proxmox.com svn-commits at proxmox.com
Wed May 18 11:46:09 CEST 2011


Author: dietmar
Date: 2011-05-18 11:46:09 +0200 (Wed, 18 May 2011)
New Revision: 5994

Modified:
   pve-manager/pve2/www/new/PVEUtils.js
   pve-manager/pve2/www/new/node/DNSEdit.js
   pve-manager/pve2/www/new/node/TimeEdit.js
Log:
cleanups


Modified: pve-manager/pve2/www/new/PVEUtils.js
===================================================================
--- pve-manager/pve2/www/new/PVEUtils.js	2011-05-18 06:22:39 UTC (rev 5993)
+++ pve-manager/pve2/www/new/PVEUtils.js	2011-05-18 09:46:09 UTC (rev 5994)
@@ -24,6 +24,15 @@
     }
 });
 
+// custom Vtype for vtype:'IPAddress'
+Ext.apply(Ext.form.field.VTypes, {
+    IPAddress:  function(v) {
+        return /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(v);
+    },
+    IPAddressText: 'Must be a numeric IP address',
+    IPAddressMask: /[\d\.]/i
+});
+
 Ext.define('PVE.Utils', {
     singleton: true,
 
@@ -82,8 +91,6 @@
 
     extractFormActionError: function(action) {
 	var msg;
-	console.log("TEST " + action.failureType);
-	console.dir(action);
 	switch (action.failureType) {
 	case Ext.form.action.Action.CLIENT_INVALID:
 	    msg = 'Form fields may not be submitted with invalid values';

Modified: pve-manager/pve2/www/new/node/DNSEdit.js
===================================================================
--- pve-manager/pve2/www/new/node/DNSEdit.js	2011-05-18 06:22:39 UTC (rev 5993)
+++ pve-manager/pve2/www/new/node/DNSEdit.js	2011-05-18 09:46:09 UTC (rev 5994)
@@ -33,16 +33,19 @@
 		{
 		    xtype: 'textfield',
                     fieldLabel: 'First DNS server',
+		    vtype: 'IPAddress',
                     name: 'dns1'
 		},
 		{
 		    xtype: 'textfield',
                     fieldLabel: 'Second DNS server',
+ 		    vtype: 'IPAddress',
                     name: 'dns2'
 		},
 		{
 		    xtype: 'textfield',
                     fieldLabel: 'Third DNS server',
+ 		    vtype: 'IPAddress',
                     name: 'dns3'
 		}
 	    ]
@@ -73,11 +76,17 @@
 	    }
 	});
 
-	form.on('dirtychange', function(form, dirty){
-	    submitBtn.setDisabled(!dirty);
+	var set_button_status = function() {
+	    var valid = form.isValid();
+	    var dirty = form.isDirty();
+	    submitBtn.setDisabled(!(valid && dirty));
 	    resetBtn.setDisabled(!dirty);
-	});
 
+	};
+
+	form.on('dirtychange', set_button_status);
+	form.on('validitychange', set_button_status);
+
 	formpanel.load({
 	    method: 'GET',
 	    failure: function(form, action) {
@@ -97,16 +106,7 @@
 	    layout: 'fit',
 	    border: false,
 	    items: formpanel,
-	    buttons: [
-		submitBtn,
-		resetBtn,
-		{
-		    text: 'Cancel',
-		    handler: function(){
-			me.close();
-		    }
-		}
-	    ]
+	    buttons: [ submitBtn, resetBtn ]
 	});
 
 	me.callParent();

Modified: pve-manager/pve2/www/new/node/TimeEdit.js
===================================================================
--- pve-manager/pve2/www/new/node/TimeEdit.js	2011-05-18 06:22:39 UTC (rev 5993)
+++ pve-manager/pve2/www/new/node/TimeEdit.js	2011-05-18 09:46:09 UTC (rev 5994)
@@ -61,11 +61,17 @@
 	    }
 	});
 
-	form.on('dirtychange', function(form, dirty){
-	    submitBtn.setDisabled(!dirty);
+	var set_button_status = function() {
+	    var valid = form.isValid();
+	    var dirty = form.isDirty();
+	    submitBtn.setDisabled(!(valid && dirty));
 	    resetBtn.setDisabled(!dirty);
-	});
 
+	};
+
+	form.on('dirtychange', set_button_status);
+	form.on('validitychange', set_button_status);
+
 	formpanel.load({
 	    method: 'GET',
 	    failure: function(form, action) {
@@ -80,20 +86,11 @@
 	    title: "Set time zone",
 	    modal: true,
             width: 400,
-	    height: 100,
+	    height: 110,
 	    layout: 'fit',
 	    border: false,
 	    items: formpanel,
-	    buttons: [
-		submitBtn,
-		resetBtn,
-		{
-		    text: 'Cancel',
-		    handler: function(){
-			me.close();
-		    }
-		}
-	    ]
+	    buttons: [ submitBtn, resetBtn ]
 	});
 
 	me.callParent();




More information about the pve-devel mailing list