You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2006/06/17 19:25:40 UTC

svn commit: r415031 - in /tapestry/tapestry4/trunk: examples/TimeTracker/src/context/css/forms.css framework/src/js/tapestry/form.js framework/src/js/tapestry/form/validation.js framework/src/js/tapestry/widget/DropdownTimePicker.js

Author: jkuhnert
Date: Sat Jun 17 10:25:40 2006
New Revision: 415031

URL: http://svn.apache.org/viewvc?rev=415031&view=rev
Log:
Fixed date format bug on re-render of timepicker , finished up validation msg display / field decorators (for now..)

Modified:
    tapestry/tapestry4/trunk/examples/TimeTracker/src/context/css/forms.css
    tapestry/tapestry4/trunk/framework/src/js/tapestry/form.js
    tapestry/tapestry4/trunk/framework/src/js/tapestry/form/validation.js
    tapestry/tapestry4/trunk/framework/src/js/tapestry/widget/DropdownTimePicker.js

Modified: tapestry/tapestry4/trunk/examples/TimeTracker/src/context/css/forms.css
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/examples/TimeTracker/src/context/css/forms.css?rev=415031&r1=415030&r2=415031&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/examples/TimeTracker/src/context/css/forms.css (original)
+++ tapestry/tapestry4/trunk/examples/TimeTracker/src/context/css/forms.css Sat Jun 17 10:25:40 2006
@@ -61,4 +61,22 @@
 .fieldInvalid {
     background: #ffaf7e;
     font-weight: bold;
-}
\ No newline at end of file
+}
+
+.missingList, .invalidList {
+    padding: 0.6em;
+    padding-top: 0.2em;
+}
+
+.missingList {
+    border-top: 4px solid #bedef4;
+}
+
+.invalidList {
+    border-top: 4px solid #ffaf7e;
+}
+
+.missingList li, .invalidList li {
+    list-style:none;
+    font-style:italic;
+}

Modified: tapestry/tapestry4/trunk/framework/src/js/tapestry/form.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/tapestry/form.js?rev=415031&r1=415030&r2=415031&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/tapestry/form.js (original)
+++ tapestry/tapestry4/trunk/framework/src/js/tapestry/form.js Sat Jun 17 10:25:40 2006
@@ -178,13 +178,7 @@
 		
 		var id=evt.target.getAttribute("id");
 		if (!id) return;
-		try {
 		if (!tapestry.form.validation.validateForm(evt.target, this.forms[id])) {
-			dojo.event.browser.stopEvent(evt);
-			dojo.log.info("Stopped form submission, invalid input.");
-		}
-		} catch (e) {
-			alert("Error validating form:" + e);
 			dojo.event.browser.stopEvent(evt);
 		}
 	},

Modified: tapestry/tapestry4/trunk/framework/src/js/tapestry/form/validation.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/tapestry/form/validation.js?rev=415031&r1=415030&r2=415031&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/tapestry/form/validation.js (original)
+++ tapestry/tapestry4/trunk/framework/src/js/tapestry/form/validation.js Sat Jun 17 10:25:40 2006
@@ -46,6 +46,8 @@
 		if (!props) return true; // form exists but no profile? just submit I guess..
 		if (!props.validateForm) return true;
 		
+		this.clearValidationDecorations(form, props);
+		
 		for (var i=0; i < props.profiles.length; i++) {
 			var results=dojo.validate.check(form, props.profiles[i]);
 			
@@ -75,8 +77,8 @@
 	processResults:function(form, results, profile){
 		if (results.isSuccessful()) return true; 
 		
-		//TODO: Need to remove previous field validation
-		//decorations for things fixed since last run
+		// TODO: Need to remove previous field validation
+		// decorations for things fixed since last run
 		var formValid=true;
 		if (results.hasMissing()) {
 			var missing=results.getMissing();
@@ -118,6 +120,13 @@
 		}
 	},
 	
+	clearValidationDecorations:function(form, props){
+		for (var i=0; i<form.elements.length; i++) {
+			dojo.html.removeClass(form.elements[i], this.missingClass);
+			dojo.html.removeClass(form.elements[i], this.invalidClass);
+		}
+	},
+	
 	/**
 	 * Optionally allows an alert dialog/dhtml dialog/etc to 
 	 * be displayed to user to alert them to the invalid state
@@ -128,10 +137,44 @@
 	 * @param profile Validation profile definition 
 	 */
 	summarizeErrors:function(form, results, profile){
+		var merrs=[];
+		var ierrs=[];
+		if (results.hasMissing()){
+			var fields=results.getMissing();
+			for (var i=0; i<fields.length; i++){
+				if (profile[fields[i]] && profile[fields[i]]["required"]){
+					merrs.push(profile[fields[i]]["required"]);
+				}
+			}
+		}
+		if (results.hasInvalid()){
+			var fields=results.getInvalid();
+			for (var i=0; i<fields.length; i++){
+				if (profile[fields[i]] && profile[fields[i]]["required"]){
+					ierrs.push(profile[fields[i]]["required"]);
+				}
+			}
+		}
+		
+		var msg="";
+		if (merrs.length > 0) {
+			msg+='<ul class="missingList">';
+			for (var i=0; i<merrs.length;i++) {
+				msg+="<li>"+merrs[i]+"</li>";
+			}
+			msg+="</ul>";
+		}
+		if (ierrs.length > 0) {
+			msg+='<ul class="invalidList">';
+			for (var i=0; i<ierrs.length;i++) {
+				msg+="<li>"+ierrs[i]+"</li>";
+			}
+			msg+="</ul>";
+		}
 		
 		var ad=dojo.widget.byId("validationDialog");
 		if (ad) {
-			ad.setMessage("You ~still~ have form input errors...wtf?");
+			ad.setMessage(msg);
 			ad.show();
 			return;
 		}
@@ -141,7 +184,7 @@
 		var dialog=dojo.widget.createWidget("AlertDialog", 
 						{
 							widgetId:"validationDialog",
-							message:"Form input errors found, please fix before proceeding."
+							message:msg
 						}, node);
 		dialog.show();
 	}

Modified: tapestry/tapestry4/trunk/framework/src/js/tapestry/widget/DropdownTimePicker.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/tapestry/widget/DropdownTimePicker.js?rev=415031&r1=415030&r2=415031&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/tapestry/widget/DropdownTimePicker.js (original)
+++ tapestry/tapestry4/trunk/framework/src/js/tapestry/widget/DropdownTimePicker.js Sat Jun 17 10:25:40 2006
@@ -22,7 +22,7 @@
 			tapestry.widget.DropdownTimePicker.superclass.fillInTemplate.call(this, args, frag);
 			var source = this.getFragNodeRef(frag);
 			
-			if(args.date){ this.date = args.date; }
+			if(args.date){ this.date = new Date(args.date); }
 			
 			var dpNode = document.createElement("div");
 			this.containerNode.appendChild(dpNode);
@@ -45,9 +45,10 @@
 		},
 		
 		onInputChange: function(){
+			if (this.inputNode.value.length < 1) return;
 			var tmp = new Date(this.inputNode.value);
 			this.timePicker.time = tmp;
-			this.timePicker.setDateTime(dojo.widget.TimePikcer.util.toRfcDateTime(tmp));
+			this.timePicker.setDateTime(dojo.widget.TimePicker.util.toRfcDateTime(tmp));
 			this.timePicker.initData();
 			this.timePicker.initUI();
 		}