[Mpuls-commits] r2436 - in wasko/branches/2.0: . mpulsweb/controllers mpulsweb/lib mpulsweb/public/styles

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Apr 20 14:10:24 CEST 2010


Author: roland
Date: 2010-04-20 14:10:21 +0200 (Tue, 20 Apr 2010)
New Revision: 2436

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/mpulsweb/controllers/formularpage.py
   wasko/branches/2.0/mpulsweb/lib/renderer.py
   wasko/branches/2.0/mpulsweb/public/styles/all.css
   wasko/branches/2.0/mpulsweb/public/styles/color3.css
Log:
Fixed Wald issue #1364: highlighting of form fields with warnings

Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-04-20 10:59:47 UTC (rev 2435)
+++ wasko/branches/2.0/ChangeLog	2010-04-20 12:10:21 UTC (rev 2436)
@@ -24,6 +24,11 @@
 	Fixed Wald issue #1392: transfer of cases while deleting user
 	* mpulsweb/public/styles/all.css:
 	Fixed Wald issue #1404: extended search labels
+        Fixed Wald issue #1364: highlighting of form fields with errors
+	* mpulsweb/public/styles/color3.css:
+	* mpulsweb/controllers/formularpage.py:
+	* mpulsweb/lib/renderer.py:
+	* mpulsweb/public/styles/all.css:
 	* mpulsweb/public/styles/color3.css: Fixed Wald issue #1364: highlighting
         of form fields with errors
 

Modified: wasko/branches/2.0/mpulsweb/controllers/formularpage.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/formularpage.py	2010-04-20 10:59:47 UTC (rev 2435)
+++ wasko/branches/2.0/mpulsweb/controllers/formularpage.py	2010-04-20 12:10:21 UTC (rev 2436)
@@ -121,9 +121,32 @@
     # Currently values of the fields are set within the renderer.
     # Htmlfill is used to fill in the error values from the error items.
     defaults = prepare_htmlfill_defaults(defaults)
-    return formencode.htmlfill.render(form, defaults=defaults,
-                                      errors=errors, auto_insert_errors=False,
-                                      force_defaults=False)
+    print "++++++++++++++++++++++++++++++Error %s ++++++++++++++++++++++" % errors
+    print "++++++++++++++++++++++++++++++Warning %s ++++++++++++++++++++++" % renderer.warnings
+    
+    # Parse the real errors
+    parsedForm = formencode.htmlfill.render(form,
+                                            defaults           = defaults,
+                                            errors             = errors,
+                                            auto_insert_errors = False,
+                                            force_defaults     = False)
+    
+    # Replace "form:warnings" with "form:errors" so that htmlfill understands it
+    parsedForm = parsedForm.replace('form:warning', 'form:error')
+    
+    # make a new dictionary because the warnings have the warning text in a (one
+    #element) list
+    warningList = {}
+    for i in renderer.warnings.keys():
+        warningList[i] = renderer.warnings[i][0]
+    
+    # Let htmlfill parse the form again
+    parsedForm = formencode.htmlfill.render(parsedForm,
+                                            errors             = warningList,
+                                            error_class        = 'warning',
+                                            auto_insert_errors = False,
+                                            force_defaults     = False)
+    return parsedForm
 
 
 class FormularpageController(BaseController):

Modified: wasko/branches/2.0/mpulsweb/lib/renderer.py
===================================================================
--- wasko/branches/2.0/mpulsweb/lib/renderer.py	2010-04-20 10:59:47 UTC (rev 2435)
+++ wasko/branches/2.0/mpulsweb/lib/renderer.py	2010-04-20 12:10:21 UTC (rev 2436)
@@ -119,7 +119,6 @@
             out.append(" %s=%s" % (name, quoteattr(value)))
     if _close:
         out.append(">")
-        #out.append("/>")
     else:
         out.append(">")
     return "".join(out)
@@ -308,10 +307,11 @@
     def _renderLabel(self, node, labeltag=True):
         meta = self._getMeta(node)
         out = []
-        error = node.hasErrors() and "error" or ""
+        warning = node.getIdentifier() in self.warnings and "warning" or ""
+        error   = node.hasErrors() and "error" or ""
         if labeltag:
             out.append(tag("label", for_=node.getIdentifier()))
-            out.append(tag("a", class_=error,
+            out.append(tag("a", class_=error or warning,
                            name="f_%s" % node.getIdentifier()))
             out.append(escape(meta.getDescription()))
             out.append("</a>")
@@ -350,12 +350,30 @@
 
     def _renderErrors(self, node):
         meta = self._getMeta(node)
+        hasWarnings = node.getIdentifier() in self.warnings
         out = []
-        if node.hasErrors() or True:
-            out.append('<span class="error">')
-            out.append(tag("form:error", name=node.getIdentifier(),
-                           format=""))
-            out.append('</span>')
+        if hasWarnings and not node.hasErrors():
+            spanClass = 'warning'
+        else:
+            spanClass = 'error'
+            
+        #if node.hasErrors() or True:
+            #out.append('<span class="error">')
+            #out.append(tag("form:error", name=node.getIdentifier(),
+                           #format=""))
+            #out.append('</span>')
+        out.append('<span class="%s">' % spanClass)
+        if hasWarnings and not node.hasErrors():
+            out.append(tag("form:%s" % spanClass,
+                    name      = node.getIdentifier(),
+                    format    = '',
+                    formatter = 'none'))
+        else:
+            out.append(tag("form:%s" % spanClass,
+                    name   = node.getIdentifier(),
+                    format =""))
+        out.append('</span>')
+        
         return "".join(out)
 
     def _checkWarnings(self, node):
@@ -544,8 +562,8 @@
 
     def _renderText(self, node):
         meta = self._getMeta(node)
-        out = []
-        id = node.getIdentifier()
+        out  = []
+        id   = node.getIdentifier()
         out.append(self._renderLabel(node))
         out.append(self._renderAttributes(node))
         out.append('<br>')

Modified: wasko/branches/2.0/mpulsweb/public/styles/all.css
===================================================================
--- wasko/branches/2.0/mpulsweb/public/styles/all.css	2010-04-20 10:59:47 UTC (rev 2435)
+++ wasko/branches/2.0/mpulsweb/public/styles/all.css	2010-04-20 12:10:21 UTC (rev 2436)
@@ -221,6 +221,10 @@
     color: #A40000;
 }
 
+.formularpage .warning .error-message {
+    color: #f57900;
+}
+
 .formularpage input, select, textarea, p {
 	width: 99%;
 }
@@ -250,12 +254,13 @@
 	margin: 0;
 }
 
-.formularpage span.error {
+.formularpage span.warning, .formularpage span.error {
 	font-size: 0.7em;
 	margin: 0;
-	color: #000;
 }
 
+
+
 .formularpage p.readonly{
 	padding: 1pt;
 	border-color: #e6e4de;

Modified: wasko/branches/2.0/mpulsweb/public/styles/color3.css
===================================================================
--- wasko/branches/2.0/mpulsweb/public/styles/color3.css	2010-04-20 10:59:47 UTC (rev 2435)
+++ wasko/branches/2.0/mpulsweb/public/styles/color3.css	2010-04-20 12:10:21 UTC (rev 2436)
@@ -36,13 +36,21 @@
 li tt { text-decoration: none; }
 
 .error {
-	color: #a40000;
+	color: #a40000 !important;
 }
 
-input.error, input[type="text"].error {
-	border: 1px solid #a40000;
+select.error, input.error, input[type="text"].error {
+	border: 1px solid #a40000 !important;
 }
 
+.warning {
+	color: #f57900;
+}
+
+select.warning, input.warning, input[type="text"].warning {
+	border: 1px solid #f57900;
+}
+
 /*------------------*/
 /* 2.	Header      */
 /*------------------*/



More information about the Mpuls-commits mailing list