Mercurial > lada > lada-client
comparison app/view/widget/base/NumberField.js @ 1171:9182430b79d7
Merge
author | Evi Huber <ehuber@bfs.de> |
---|---|
date | Mon, 04 Jul 2016 11:26:42 +0200 |
parents | e552e82ceb8a |
children | c63acd44f8ca |
comparison
equal
deleted
inserted
replaced
1170:8280cd5694e5 | 1171:9182430b79d7 |
---|---|
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 /** | |
10 * This Widget extends a Panel to create a Numberfield | |
11 */ | |
12 Ext.define('Lada.view.widget.base.NumberField', { | |
13 extend: 'Ext.panel.Panel', | |
14 alias: 'widget.numfield', | |
15 | |
16 layout: 'hbox', | |
17 | |
18 border: 0, | |
19 margin: '0, 0, 5, 0', | |
20 | |
21 initComponent: function() { | |
22 this.items = [{ | |
23 xtype: 'numberfield', | |
24 flex: 1, | |
25 name: this.name, | |
26 msgTarget: 'none', | |
27 allowDecimals: this.allowDecimals, | |
28 maxLength: this.maxLength || 1000, | |
29 enforceMaxLength: this.enforceMaxLength || true, | |
30 fieldLabel: this.fieldLabel, | |
31 labelWidth: this.labelWidth, | |
32 readOnly: this.readOnly || false, | |
33 listeners: this.listeners | |
34 }, { | |
35 xtype: 'image', | |
36 name: 'warnImg', | |
37 src: 'resources/img/dialog-warning.png', | |
38 width: 14, | |
39 height: 14, | |
40 hidden: true | |
41 }, { | |
42 xtype: 'image', | |
43 name: 'errorImg', | |
44 src: 'resources/img/emblem-important.png', | |
45 width: 14, | |
46 height: 14, | |
47 hidden: true | |
48 }]; | |
49 this.callParent(arguments); | |
50 if (this.regex) { | |
51 Ext.apply(this.down('numberfield'), {regex: this.regex}); | |
52 } | |
53 if (this.allowBlank === false) { | |
54 Ext.apply(this.down('numberfield'), {allowBlank: this.allowBlank}); | |
55 } | |
56 }, | |
57 | |
58 showWarnings: function(warnings) { | |
59 var img = this.down('image[name=warnImg]'); | |
60 Ext.create('Ext.tip.ToolTip', { | |
61 target: img.getEl(), | |
62 html: warnings | |
63 }); | |
64 img.show(); | |
65 this.down('numberfield').invalidCls = 'x-lada-warning'; | |
66 this.down('numberfield').markInvalid(''); | |
67 var fieldset = this.up('fieldset[collapsible=true]'); | |
68 if (fieldset) { | |
69 var i18n = Lada.getApplication().bundle; | |
70 var warningText = i18n.getMsg(this.name) + ': ' + warnings; | |
71 fieldset.showWarningOrError(true, warningText); | |
72 } | |
73 }, | |
74 | |
75 showErrors: function(errors) { | |
76 var img = this.down('image[name=errorImg]'); | |
77 var warnImg = this.down('image[name=warnImg]'); | |
78 warnImg.hide(); | |
79 Ext.create('Ext.tip.ToolTip', { | |
80 target: img.getEl(), | |
81 html: errors | |
82 }); | |
83 this.down('numberfield').invalidCls = 'x-lada-error'; | |
84 this.down('numberfield').markInvalid(''); | |
85 img.show(); | |
86 var fieldset = this.up('fieldset[collapsible=true]'); | |
87 if (fieldset) { | |
88 var i18n = Lada.getApplication().bundle; | |
89 var errorText = i18n.getMsg(this.name) + ': ' + errors; | |
90 fieldset.showWarningOrError(false, '', true, errorText); | |
91 } | |
92 }, | |
93 | |
94 getValue: function() { | |
95 return this.down('numberfield').getValue(); | |
96 }, | |
97 | |
98 setValue: function(value) { | |
99 this.down('numberfield').setValue(value); | |
100 }, | |
101 | |
102 clearWarningOrError: function() { | |
103 this.down('image[name=errorImg]').hide(); | |
104 this.down('image[name=warnImg]').hide(); | |
105 }, | |
106 | |
107 setReadOnly: function(value) { | |
108 this.down('numberfield').setReadOnly(value); | |
109 } | |
110 }); |