[Lada-commits] [PATCH 5 of 5] Added ClearMessages, SetWarnigs, SetReadonly

Wald Commits scm-commit at wald.intevation.org
Fri Mar 27 16:00:50 CET 2015


# HG changeset patch
# User Dustin Demuth <dustin at intevation.de>
# Date 1427468083 -3600
# Node ID 2ad36c8db968f21252cb01b216fe2b38ab97032d
# Parent  c632c7c34029443b8eb53052976fbfec0b19c14c
Added ClearMessages, SetWarnigs, SetReadonly

diff -r c632c7c34029 -r 2ad36c8db968 app/view/form/Location.js
--- 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);
diff -r c632c7c34029 -r 2ad36c8db968 app/view/form/Messung.js
--- 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);
diff -r c632c7c34029 -r 2ad36c8db968 app/view/form/Ort.js
--- a/app/view/form/Ort.js	Fri Mar 27 15:22:32 2015 +0100
+++ b/app/view/form/Ort.js	Fri Mar 27 15:54:43 2015 +0100
@@ -86,11 +86,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('location[name=ort]').clearWarningOrError();
+        this.down('tfield[name=ortsTyp]').clearWarningOrError();
+        //this.down('textarea[name=ortszusatztext]').clearWarningOrError();
     },
 
     setReadOnly: function(value) {
+        //this.down('location[name=ort]').setReadOnly(value);
+        this.down('tfield[name=ortsTyp]').setReadOnly(value);
+        this.down('textarea[name=ortszusatztext]').setReadOnly(value);
     }
 });
diff -r c632c7c34029 -r 2ad36c8db968 app/view/widget/Messmethode.js
--- a/app/view/widget/Messmethode.js	Fri Mar 27 15:22:32 2015 +0100
+++ b/app/view/widget/Messmethode.js	Fri Mar 27 15:54:43 2015 +0100
@@ -23,7 +23,7 @@
     typeAhead: true,
     minChars: 0,
     layout: 'hbox',
-    
+
     initComponent: function() {
         this.store = Ext.data.StoreManager.get('messmethoden');
         if (!this.store) {


More information about the Lada-commits mailing list