diff app/view/widgets/Datetime.js @ 542:0a948bb99b60

Added error and warning handling to date time field.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 18 Dec 2014 15:03:08 +0100
parents 7c0653e8d9f7
children
line wrap: on
line diff
--- a/app/view/widgets/Datetime.js	Thu Dec 18 15:02:00 2014 +0100
+++ b/app/view/widgets/Datetime.js	Thu Dec 18 15:03:08 2014 +0100
@@ -10,12 +10,59 @@
  * Datetimepicker with german date format.
  */
 Ext.define('Lada.view.widgets.Datetime', {
-    extend: 'Ext.ux.form.DateTimeField',
+    extend: 'Ext.panel.Panel',
     alias: 'widget.datetime',
-    format: 'd.m.Y',
-    emptyText: 'Wählen Sie einen Zeitpunkt',
+
+    layout: 'hbox',
+
+    border: 0,
 
     initComponent: function() {
+        var dateField = Ext.create('Ext.ux.form.DateTimeField', {
+            format: 'd.m.Y',
+            emptyText: 'Wählen Sie einen Zeitpunkt',
+            fieldLabel: this.fieldLabel,
+            margin: this.fieldMargin,
+            labelWidth: this.labelWidth,
+            flex: 1,
+            name: this.name,
+            listeners: this.listeners
+        });
+        this.items = [{
+            xtype: 'image',
+            name: 'warnImg',
+            src: 'gfx/icon-warning.gif',
+            margin: '2, 5, 2, 5',
+            width: 16,
+            height: 16,
+            hidden: true
+        }, {
+            xtype: 'image',
+            name: 'errorImg',
+            src: 'gfx/icon-error.gif',
+            margin: '2, 5, 2, 5',
+            width: 16,
+            height: 16,
+            hidden: true
+        }, dateField];
         this.callParent(arguments);
+    },
+
+    showWarnings: function(warnings) {
+        var img = this.down('image[name=warnImg]');
+        Ext.create('Ext.tip.ToolTip', {
+            target: img.getEl(),
+            html: warnings
+        });
+        img.show();
+    },
+
+    showErrors: function(errors) {
+        var img = this.down('image[name=errorImg]');
+        Ext.create('Ext.tip.ToolTip', {
+            target: img.getEl(),
+            html: errors
+        });
+        img.show();
     }
 });

http://lada.wald.intevation.org