annotate app/view/widget/base/NumberField.js @ 1193:3e078af76b58

Do not try to display an undefined title.
author Tom Gottfried <tom@intevation.de>
date Thu, 08 Sep 2016 10:06:07 +0200
parents e552e82ceb8a
children c63acd44f8ca
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,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
33 listeners: this.listeners
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
34 }, {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
35 xtype: 'image',
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
36 name: 'warnImg',
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
37 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
38 width: 14,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
39 height: 14,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
40 hidden: true
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
41 }, {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
42 xtype: 'image',
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
43 name: 'errorImg',
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
44 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
45 width: 14,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
46 height: 14,
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
47 hidden: true
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
48 }];
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
49 this.callParent(arguments);
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
50 if (this.regex) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
51 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
52 }
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
53 if (this.allowBlank === false) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
54 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
55 }
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 showWarnings: function(warnings) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
59 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
60 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
61 target: img.getEl(),
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
62 html: warnings
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
63 });
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
64 img.show();
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
65 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
66 this.down('numberfield').markInvalid('');
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
67 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
68 if (fieldset) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
69 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
70 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
71 fieldset.showWarningOrError(true, warningText);
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
72 }
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 showErrors: function(errors) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
76 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
77 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
78 warnImg.hide();
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
79 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
80 target: img.getEl(),
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
81 html: errors
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
82 });
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
83 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
84 this.down('numberfield').markInvalid('');
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
85 img.show();
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
86 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
87 if (fieldset) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
88 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
89 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
90 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
91 }
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 getValue: function() {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
95 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
96 },
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 setValue: function(value) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
99 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
100 },
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 clearWarningOrError: function() {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
103 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
104 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
105 },
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 setReadOnly: function(value) {
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
108 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
109 }
40a07eb873bf Add numberfield with error/warning functionality and use for Messprogramm form.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
110 });

http://lada.wald.intevation.org