diff app/view/form/Location.js @ 708:2ad36c8db968

Added ClearMessages, SetWarnigs, SetReadonly
author Dustin Demuth <dustin@intevation.de>
date Fri, 27 Mar 2015 15:54:43 +0100
parents fe527f380b10
children 3139b920dd0e
line wrap: on
line diff
--- a/app/view/form/Location.js	Fri Mar 27 15:22:32 2015 +0100
+++ b/app/view/form/Location.js	Fri Mar 27 15:54:43 2015 +0100
@@ -113,10 +113,49 @@
     },
 
     setMessages: function(errors, warnings) {
-    },
+        var key;
+        var element;
+        var content;
+        var i18n = Lada.getApplication().bundle;
+        if (warnings) {
+            for (key in warnings) {
+                element = this.down('component[name=' + key + ']');
+                if (!element) {
+                    continue;
+                }
+                content = warnings[key];
+                var warnText = '';
+                for (var i = 0; i < content.length; i++) {
+                    warnText += i18n.getMsg(content[i].toString()) + '\n';
+                }
+                element.showWarnings(warnText);
+            }
+        }
+        if (errors) {
+            for (key in errors) {
+                element = this.down('component[name=' + key + ']');
+                if (!element) {
+                    continue;
+                }
+                content = errors[key];
+                var errorText = '';
+                for (var i = 0; i < content.length; i++) {
+                    errorText += i18n.getMsg(content[i].toString()) + '\n';
+                }
+                element.showErrors(errorText);
+            }
+        }
+     },
 
     clearMessages: function() {
-    },
+        this.down('tfield[name=beschreibung]').clearWarningOrError();
+        this.down('tfield[name=bezeichnung]').clearWarningOrError();
+        this.down('staat[name=staatId]').clearWarningOrError();
+        this.down('verwaltungseinheit[name=verwaltungseinheitId]').clearWarningOrError();
+        //this.down('numberfield[name=longitude]').clearWarningOrError();
+        //this.down('numberfield[name=latitude]').clearWarningOrError();
+        //this.down('numberfield[name=hoeheLand]').clearWarningOrError();
+     },
 
     setReadOnly: function(value) {
         this.down('tfield[name=beschreibung]').setReadOnly(value);

http://lada.wald.intevation.org