Mercurial > lada > lada-client
annotate app/view/widget/base/TextField.js @ 1168:40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 01 Jul 2016 14:01:02 +0200 |
parents | 5ceb0381ae73 |
children | bfdc00c24baf |
rev | line source |
---|---|
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 * |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 */ |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 |
892
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
659
diff
changeset
|
9 /** |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
659
diff
changeset
|
10 * This Widget extends a Panel to create a Textfield |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
659
diff
changeset
|
11 */ |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 Ext.define('Lada.view.widget.base.TextField', { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 extend: 'Ext.panel.Panel', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 alias: 'widget.tfield', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 layout: 'hbox', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 border: 0, |
599
41d480b69436
UI update for textfield widget.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
548
diff
changeset
|
19 margin: '0, 0, 5, 0', |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 initComponent: function() { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 this.items = [{ |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 xtype: 'textfield', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 flex: 1, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 name: this.name, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 msgTarget: 'none', |
659
40834912929e
Textfields sind nun max. 1000 Zeichen Lang. Die begrenzung wird erzwungen, kann jedoch überschrieben werden
Dustin Demuth <dustin@intevation.de>
parents:
634
diff
changeset
|
27 maxLength: this.maxLength || 1000, |
40834912929e
Textfields sind nun max. 1000 Zeichen Lang. Die begrenzung wird erzwungen, kann jedoch überschrieben werden
Dustin Demuth <dustin@intevation.de>
parents:
634
diff
changeset
|
28 enforceMaxLength: this.enforceMaxLength || true, |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 fieldLabel: this.fieldLabel, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 labelWidth: this.labelWidth, |
1144
5ceb0381ae73
Set a regex and required for ortszuordnungstyp field.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1016
diff
changeset
|
31 readOnly: this.readOnly || false, |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 listeners: this.listeners |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 }, { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 xtype: 'image', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 name: 'warnImg', |
632
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
599
diff
changeset
|
36 src: 'resources/img/dialog-warning.png', |
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
599
diff
changeset
|
37 width: 14, |
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
599
diff
changeset
|
38 height: 14, |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 hidden: true |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 }, { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 xtype: 'image', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 name: 'errorImg', |
632
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
599
diff
changeset
|
43 src: 'resources/img/emblem-important.png', |
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
599
diff
changeset
|
44 width: 14, |
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
599
diff
changeset
|
45 height: 14, |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 hidden: true |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 }]; |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 this.callParent(arguments); |
1144
5ceb0381ae73
Set a regex and required for ortszuordnungstyp field.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1016
diff
changeset
|
49 if (this.regex) { |
5ceb0381ae73
Set a regex and required for ortszuordnungstyp field.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1016
diff
changeset
|
50 Ext.apply(this.down('textfield'), {regex: this.regex}); |
5ceb0381ae73
Set a regex and required for ortszuordnungstyp field.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1016
diff
changeset
|
51 } |
5ceb0381ae73
Set a regex and required for ortszuordnungstyp field.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1016
diff
changeset
|
52 if (this.allowBlank === false) { |
5ceb0381ae73
Set a regex and required for ortszuordnungstyp field.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1016
diff
changeset
|
53 Ext.apply(this.down('textfield'), {allowBlank: this.allowBlank}); |
5ceb0381ae73
Set a regex and required for ortszuordnungstyp field.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1016
diff
changeset
|
54 } |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 }, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 showWarnings: function(warnings) { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 var img = this.down('image[name=warnImg]'); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 Ext.create('Ext.tip.ToolTip', { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 target: img.getEl(), |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 html: warnings |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 }); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 img.show(); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 this.down('textfield').invalidCls = 'x-lada-warning'; |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 this.down('textfield').markInvalid(''); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 var fieldset = this.up('fieldset[collapsible=true]'); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 if (fieldset) { |
634
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
68 var i18n = Lada.getApplication().bundle; |
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
69 var warningText = i18n.getMsg(this.name) + ': ' + warnings; |
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
70 fieldset.showWarningOrError(true, warningText); |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 } |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 }, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 showErrors: function(errors) { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 var img = this.down('image[name=errorImg]'); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 var warnImg = this.down('image[name=warnImg]'); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 warnImg.hide(); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 Ext.create('Ext.tip.ToolTip', { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 target: img.getEl(), |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 html: errors |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 }); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 this.down('textfield').invalidCls = 'x-lada-error'; |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 this.down('textfield').markInvalid(''); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 img.show(); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 var fieldset = this.up('fieldset[collapsible=true]'); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 if (fieldset) { |
634
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
87 var i18n = Lada.getApplication().bundle; |
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
88 var errorText = i18n.getMsg(this.name) + ': ' + errors; |
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
89 fieldset.showWarningOrError(false, '', true, errorText); |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 } |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 }, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 |
1016
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
930
diff
changeset
|
93 getValue: function() { |
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
930
diff
changeset
|
94 return this.down('textfield').getValue(); |
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
930
diff
changeset
|
95 }, |
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
930
diff
changeset
|
96 |
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
930
diff
changeset
|
97 setValue: function(value) { |
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
930
diff
changeset
|
98 this.down('textfield').setValue(value); |
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
930
diff
changeset
|
99 }, |
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
930
diff
changeset
|
100 |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 clearWarningOrError: function() { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 this.down('image[name=errorImg]').hide(); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 this.down('image[name=warnImg]').hide(); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 }, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 setReadOnly: function(value) { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 this.down('textfield').setReadOnly(value); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 } |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 }); |