comparison app/view/widget/base/DateField.js @ 645:422e71708a0c

Ein Datefield Widget hinzugefĆ¼gt
author Dustin Demuth <dustin@intevation.de>
date Tue, 17 Mar 2015 17:10:02 +0100
parents
children a8389baaf4af
comparison
equal deleted inserted replaced
644:71e8b84d7829 645:422e71708a0c
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */
8
9 Ext.define('Lada.view.widget.base.DateField', {
10 extend: 'Ext.form.Panel',
11 alias: 'widget.datef',
12
13 requires: [
14 'Ext.form.field.Date'
15 ],
16
17 layout: 'hbox',
18
19 border: 0,
20
21 margin: '0, 0, 5, 0',
22
23 initComponent: function() {
24 this.items = [{
25 xtype: 'datefield',
26 flex: 1,
27 name: this.name,
28 fieldLabel: this.fieldLabel,
29 labelWidth: this.labelWidth,
30 listeners: this.listeners,
31 triggerAction: this.triggerAction,
32 format: this.format,
33 msgTarget: 'none',
34 tpl: this.tpl
35 }, {
36 xtype: 'image',
37 name: 'warnImg',
38 src: 'resources/img/dialog-warning.png',
39 width: 14,
40 height: 14,
41 hidden: true
42 }, {
43 xtype: 'image',
44 name: 'errorImg',
45 src: 'resources/img/emblem-important.png',
46 width: 14,
47 height: 14,
48 hidden: true
49 }];
50 this.callParent(arguments);
51 },
52
53 showWarnings: function(warnings) {
54 var img = this.down('image[name=warnImg]');
55 Ext.create('Ext.tip.ToolTip', {
56 target: img.getEl(),
57 html: warnings
58 });
59 this.down('datefield').invalidCls = 'x-lada-warning';
60 this.down('datefield').markInvalid('');
61 img.show();
62 var fieldset = this.up('fieldset[collapsible=true]');
63 if (fieldset) {
64 var i18n = Lada.getApplication().bundle;
65 var warningText = i18n.getMsg(this.name) + ': ' + warnings;
66 fieldset.showWarningOrError(true, warningText);
67 }
68 },
69
70 showErrors: function(errors) {
71 var img = this.down('image[name=errorImg]');
72 var warnImg = this.down('image[name=warnImg]');
73 warnImg.hide();
74 Ext.create('Ext.tip.ToolTip', {
75 target: img.getEl(),
76 html: errors
77 });
78 this.down('datefield').invalidCls = 'x-lada-error';
79 this.down('datefield').markInvalid('');
80 img.show();
81 var fieldset = this.up('fieldset[collapsible=true]');
82 if (fieldset) {
83 var i18n = Lada.getApplication().bundle;
84 var errorText = i18n.getMsg(this.name) + ': ' + errors;
85 fieldset.showWarningOrError(false, '', true, errorText);
86 }
87 },
88
89 clearWarningOrError: function() {
90 this.down('image[name=errorImg]').hide();
91 this.down('image[name=warnImg]').hide();
92 },
93
94 getValue: function() {
95 return this.down('datefield').getValue();
96 },
97
98 getName: function() {
99 return this.name;
100 },
101
102 setReadOnly: function(value) {
103 this.down('datefield').setReadOnly(value);
104 }
105 });

http://lada.wald.intevation.org