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

Added ClearMessages, SetWarnigs, SetReadonly
author Dustin Demuth <dustin@intevation.de>
date Fri, 27 Mar 2015 15:54:43 +0100
parents a0df1a8dff24
children f204f30b824a
line wrap: on
line diff
--- a/app/view/form/Messung.js	Fri Mar 27 15:22:32 2015 +0100
+++ b/app/view/form/Messung.js	Fri Mar 27 15:54:43 2015 +0100
@@ -65,7 +65,7 @@
                     }]
                 }],
                 items: [{
-                    xtype: 'textfield',
+                    xtype: 'tfield',
                     name: 'nebenprobenNr',
                     maxLength: 10,
                     margin: '0, 10, 5, 0',
@@ -122,17 +122,53 @@
         this.getForm().loadRecord(record);
     },
 
-    setMessages: function() {
-        // TODO this is a stub
+    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() {
-        // TODO this is a stub
+        this.down('tfield[name=nebenprobenNr]').clearWarningOrError();
+        //this.down('messmethode[name=mmtId]').clearWarningOrError();
+        this.down('datetime[name=messzeitpunkt]').clearWarningOrError();
+        //this.down('numberfield[name=messdauer]').clearWarningOrError();
+        this.down('chkbox[name=fertig]').clearWarningOrError();
+        this.down('chkbox[name=geplant]').clearWarningOrError();
     },
 
     setReadOnly: function(value) {
-        this.down('textfield[name=nebenprobenNr]').setReadOnly(value);
-        this.down('messmethode[name=mmtId]').setReadOnly(value);
+        this.down('tfield[name=nebenprobenNr]').setReadOnly(value);
+        //this.down('messmethode[name=mmtId]').setReadOnly(value);
         this.down('datetime[name=messzeitpunkt]').setReadOnly(value);
         this.down('numberfield[name=messdauer]').setReadOnly(value);
         this.down('chkbox[name=fertig]').setReadOnly(value);

http://lada.wald.intevation.org