Mercurial > lada > lada-client
annotate app/view/widget/base/CheckBox.js @ 783:afdbe3770b99
Exclude deskriptor fields from form.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 13 May 2015 10:22:53 +0200 |
parents | 291ac2e2bcf5 |
children | a031b98c7edc |
rev | line source |
---|---|
610 | 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 Ext.define('Lada.view.widget.base.CheckBox', { | |
10 extend: 'Ext.form.Panel', | |
11 alias: 'widget.chkbox', | |
12 | |
13 layout: 'hbox', | |
14 | |
15 border: 0, | |
16 | |
17 margin: '0, 0, 5, 0', | |
18 | |
19 initComponent: function() { | |
20 this.items = [{ | |
21 xtype: 'checkbox', | |
22 flex: 1, | |
23 name: this.name, | |
24 fieldLabel: this.fieldLabel, | |
25 labelWidth: this.labelWidth, | |
26 listeners: this.listeners, | |
27 triggerAction: this.triggerAction, | |
28 msgTarget: 'none', | |
29 tpl: this.tpl | |
30 }, { | |
31 xtype: 'image', | |
32 name: 'warnImg', | |
632
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
610
diff
changeset
|
33 src: 'resources/img/dialog-warning.png', |
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
610
diff
changeset
|
34 width: 14, |
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
610
diff
changeset
|
35 height: 14, |
610 | 36 hidden: true |
37 }, { | |
38 xtype: 'image', | |
39 name: 'errorImg', | |
632
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
610
diff
changeset
|
40 src: 'resources/img/emblem-important.png', |
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
610
diff
changeset
|
41 width: 14, |
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
610
diff
changeset
|
42 height: 14, |
610 | 43 hidden: true |
44 }]; | |
45 this.callParent(arguments); | |
46 }, | |
47 | |
48 showWarnings: function(warnings) { | |
49 var img = this.down('image[name=warnImg]'); | |
50 Ext.create('Ext.tip.ToolTip', { | |
51 target: img.getEl(), | |
52 html: warnings | |
53 }); | |
54 this.down('checkbox').invalidCls = 'x-lada-warning'; | |
55 this.down('checkbox').markInvalid(''); | |
56 img.show(); | |
57 var fieldset = this.up('fieldset[collapsible=true]'); | |
58 if (fieldset) { | |
634
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
59 var i18n = Lada.getApplication().bundle; |
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
60 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
|
61 fieldset.showWarningOrError(true, warningText); |
610 | 62 } |
63 }, | |
64 | |
65 showErrors: function(errors) { | |
66 var img = this.down('image[name=errorImg]'); | |
67 var warnImg = this.down('image[name=warnImg]'); | |
68 warnImg.hide(); | |
69 Ext.create('Ext.tip.ToolTip', { | |
70 target: img.getEl(), | |
71 html: errors | |
72 }); | |
73 this.down('checkbox').invalidCls = 'x-lada-error'; | |
74 this.down('checkbox').markInvalid(''); | |
75 img.show(); | |
76 var fieldset = this.up('fieldset[collapsible=true]'); | |
77 if (fieldset) { | |
634
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
78 var i18n = Lada.getApplication().bundle; |
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
79 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
|
80 fieldset.showWarningOrError(false, '', true, errorText); |
610 | 81 } |
82 }, | |
83 | |
84 clearWarningOrError: function() { | |
85 this.down('image[name=errorImg]').hide(); | |
86 this.down('image[name=warnImg]').hide(); | |
87 }, | |
88 | |
89 getValue: function() { | |
90 return this.down('checkbox').getValue(); | |
91 }, | |
92 | |
93 getName: function() { | |
94 return this.name; | |
95 }, | |
96 | |
97 setReadOnly: function(value) { | |
98 this.down('checkbox').setReadOnly(value); | |
99 } | |
100 }); |