Mercurial > lada > lada-client
annotate app/view/widget/base/NumberField.js @ 1389:39414e1e3571
internationalization Strings for auditTrail
author | Maximilian Krambach <mkrambach@intevation.de> |
---|---|
date | Tue, 28 Feb 2017 17:06:36 +0100 |
parents | faecbb446a04 |
children |
rev | line source |
---|---|
1168
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
3 * |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
7 */ |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
8 |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
9 /** |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
10 * This Widget extends a Panel to create a Numberfield |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
11 */ |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
12 Ext.define('Lada.view.widget.base.NumberField', { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
13 extend: 'Ext.panel.Panel', |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
14 alias: 'widget.numfield', |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
15 |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
16 layout: 'hbox', |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
17 |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
18 border: 0, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
19 margin: '0, 0, 5, 0', |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
20 |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
21 initComponent: function() { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
22 this.items = [{ |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
23 xtype: 'numberfield', |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
24 flex: 1, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
25 name: this.name, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
26 msgTarget: 'none', |
1169
e552e82ceb8a
Teilintervall and offset must be integer.
Tom Gottfried <tom@intevation.de>
parents:
1168
diff
changeset
|
27 allowDecimals: this.allowDecimals, |
1284
faecbb446a04
Ortserstellung: new Messpunkt from map, clone or form
Maximilian Krambach <mkrambach@intevation.de>
parents:
1194
diff
changeset
|
28 decimalPrecision: this.decimalPrecision || 2, |
1168
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
29 maxLength: this.maxLength || 1000, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
30 enforceMaxLength: this.enforceMaxLength || true, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
31 fieldLabel: this.fieldLabel, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
32 labelWidth: this.labelWidth, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
33 readOnly: this.readOnly || false, |
1194
c63acd44f8ca
Fix regression of 40a07eb873bf to display errors and warnings again.
Tom Gottfried <tom@intevation.de>
parents:
1169
diff
changeset
|
34 period: this.period, |
1168
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
35 listeners: this.listeners |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
36 }, { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
37 xtype: 'image', |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
38 name: 'warnImg', |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
39 src: 'resources/img/dialog-warning.png', |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
40 width: 14, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
41 height: 14, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
42 hidden: true |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
43 }, { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
44 xtype: 'image', |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
45 name: 'errorImg', |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
46 src: 'resources/img/emblem-important.png', |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
47 width: 14, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
48 height: 14, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
49 hidden: true |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
50 }]; |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
51 this.callParent(arguments); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
52 if (this.regex) { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
53 Ext.apply(this.down('numberfield'), {regex: this.regex}); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
54 } |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
55 if (this.allowBlank === false) { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
56 Ext.apply(this.down('numberfield'), {allowBlank: this.allowBlank}); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
57 } |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
58 }, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
59 |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
60 showWarnings: function(warnings) { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
61 var img = this.down('image[name=warnImg]'); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
62 Ext.create('Ext.tip.ToolTip', { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
63 target: img.getEl(), |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
64 html: warnings |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
65 }); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
66 img.show(); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
67 this.down('numberfield').invalidCls = 'x-lada-warning'; |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
68 this.down('numberfield').markInvalid(''); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
69 var fieldset = this.up('fieldset[collapsible=true]'); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
70 if (fieldset) { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
71 var i18n = Lada.getApplication().bundle; |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
72 var warningText = i18n.getMsg(this.name) + ': ' + warnings; |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
73 fieldset.showWarningOrError(true, warningText); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
74 } |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
75 }, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
76 |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
77 showErrors: function(errors) { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
78 var img = this.down('image[name=errorImg]'); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
79 var warnImg = this.down('image[name=warnImg]'); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
80 warnImg.hide(); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
81 Ext.create('Ext.tip.ToolTip', { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
82 target: img.getEl(), |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
83 html: errors |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
84 }); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
85 this.down('numberfield').invalidCls = 'x-lada-error'; |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
86 this.down('numberfield').markInvalid(''); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
87 img.show(); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
88 var fieldset = this.up('fieldset[collapsible=true]'); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
89 if (fieldset) { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
90 var i18n = Lada.getApplication().bundle; |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
91 var errorText = i18n.getMsg(this.name) + ': ' + errors; |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
92 fieldset.showWarningOrError(false, '', true, errorText); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
93 } |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
94 }, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
95 |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
96 getValue: function() { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
97 return this.down('numberfield').getValue(); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
98 }, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
99 |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
100 setValue: function(value) { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
101 this.down('numberfield').setValue(value); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
102 }, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
103 |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
104 clearWarningOrError: function() { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
105 this.down('image[name=errorImg]').hide(); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
106 this.down('image[name=warnImg]').hide(); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
107 }, |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
108 |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
109 setReadOnly: function(value) { |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
110 this.down('numberfield').setReadOnly(value); |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
111 } |
40a07eb873bf
Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
112 }); |