changeset 645:422e71708a0c

Ein Datefield Widget hinzugefĆ¼gt
author Dustin Demuth <dustin@intevation.de>
date Tue, 17 Mar 2015 17:10:02 +0100 (2015-03-17)
parents 71e8b84d7829
children d945cfeeebeb
files app/view/widget/base/DateField.js
diffstat 1 files changed, 105 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/widget/base/DateField.js	Tue Mar 17 17:10:02 2015 +0100
@@ -0,0 +1,105 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+Ext.define('Lada.view.widget.base.DateField', {
+    extend: 'Ext.form.Panel',
+    alias: 'widget.datef',
+
+    requires: [
+        'Ext.form.field.Date'
+    ],
+
+    layout: 'hbox',
+
+    border: 0,
+
+    margin: '0, 0, 5, 0',
+
+    initComponent: function() {
+        this.items = [{
+            xtype: 'datefield',
+            flex: 1,
+            name: this.name,
+            fieldLabel: this.fieldLabel,
+            labelWidth: this.labelWidth,
+            listeners: this.listeners,
+            triggerAction: this.triggerAction,
+            format: this.format,
+            msgTarget: 'none',
+            tpl: this.tpl
+        }, {
+            xtype: 'image',
+            name: 'warnImg',
+            src: 'resources/img/dialog-warning.png',
+            width: 14,
+            height: 14,
+            hidden: true
+        }, {
+            xtype: 'image',
+            name: 'errorImg',
+            src: 'resources/img/emblem-important.png',
+            width: 14,
+            height: 14,
+            hidden: true
+        }];
+        this.callParent(arguments);
+    },
+
+    showWarnings: function(warnings) {
+        var img = this.down('image[name=warnImg]');
+        Ext.create('Ext.tip.ToolTip', {
+            target: img.getEl(),
+            html: warnings
+        });
+        this.down('datefield').invalidCls = 'x-lada-warning';
+        this.down('datefield').markInvalid('');
+        img.show();
+        var fieldset = this.up('fieldset[collapsible=true]');
+        if (fieldset) {
+            var i18n = Lada.getApplication().bundle;
+            var warningText = i18n.getMsg(this.name) + ': ' + warnings;
+            fieldset.showWarningOrError(true, warningText);
+        }
+    },
+
+    showErrors: function(errors) {
+        var img = this.down('image[name=errorImg]');
+        var warnImg = this.down('image[name=warnImg]');
+        warnImg.hide();
+        Ext.create('Ext.tip.ToolTip', {
+            target: img.getEl(),
+            html: errors
+        });
+        this.down('datefield').invalidCls = 'x-lada-error';
+        this.down('datefield').markInvalid('');
+        img.show();
+        var fieldset = this.up('fieldset[collapsible=true]');
+        if (fieldset) {
+            var i18n = Lada.getApplication().bundle;
+            var errorText = i18n.getMsg(this.name) + ': ' + errors;
+            fieldset.showWarningOrError(false, '', true, errorText);
+        }
+    },
+
+    clearWarningOrError: function() {
+        this.down('image[name=errorImg]').hide();
+        this.down('image[name=warnImg]').hide();
+    },
+
+    getValue: function() {
+        return this.down('datefield').getValue();
+    },
+
+    getName: function() {
+        return this.name;
+    },
+
+    setReadOnly: function(value) {
+        this.down('datefield').setReadOnly(value);
+    }
+});

http://lada.wald.intevation.org