annotate app/view/widget/base/NumberField.js @ 1197:112fd60f1fb4

It is an error to specify invalid intervals.
author Tom Gottfried <tom@intevation.de>
date Tue, 20 Sep 2016 18:16:41 +0200
parents c63acd44f8ca
children faecbb446a04
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,
1168
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
28 maxLength: this.maxLength || 1000,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
29 enforceMaxLength: this.enforceMaxLength || true,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
30 fieldLabel: this.fieldLabel,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
31 labelWidth: this.labelWidth,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
32 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
33 period: this.period,
1168
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
34 listeners: this.listeners
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
35 }, {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
36 xtype: 'image',
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
37 name: 'warnImg',
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
38 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
39 width: 14,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
40 height: 14,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
41 hidden: true
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
42 }, {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
43 xtype: 'image',
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
44 name: 'errorImg',
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
45 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
46 width: 14,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
47 height: 14,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
48 hidden: true
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
49 }];
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
50 this.callParent(arguments);
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
51 if (this.regex) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
52 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
53 }
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
54 if (this.allowBlank === false) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
55 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
56 }
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 showWarnings: function(warnings) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
60 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
61 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
62 target: img.getEl(),
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
63 html: warnings
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
64 });
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
65 img.show();
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
66 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
67 this.down('numberfield').markInvalid('');
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
68 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
69 if (fieldset) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
70 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
71 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
72 fieldset.showWarningOrError(true, warningText);
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
73 }
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 showErrors: function(errors) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
77 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
78 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
79 warnImg.hide();
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
80 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
81 target: img.getEl(),
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
82 html: errors
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
83 });
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
84 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
85 this.down('numberfield').markInvalid('');
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
86 img.show();
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
87 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
88 if (fieldset) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
89 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
90 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
91 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
92 }
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 getValue: function() {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
96 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
97 },
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 setValue: function(value) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
100 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
101 },
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 clearWarningOrError: function() {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
104 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
105 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
106 },
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 setReadOnly: function(value) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
109 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
110 }
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
111 });

http://lada.wald.intevation.org