annotate app/view/widget/base/CheckBox.js @ 624:927484545e9b

added xtype for numeric-fields to grid to enable decimalseparator-replacement by locale-config
author Dustin Demuth <dustin@intevation.de>
date Mon, 16 Mar 2015 11:23:38 +0100
parents f240fe19ff5d
children fead63bb5fb4
rev   line source
610
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
3 *
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
7 */
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
8
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
9 Ext.define('Lada.view.widget.base.CheckBox', {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
10 extend: 'Ext.form.Panel',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
11 alias: 'widget.chkbox',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
12
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
13 layout: 'hbox',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
14
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
15 border: 0,
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
16
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
17 margin: '0, 0, 5, 0',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
18
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
19 initComponent: function() {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
20 this.items = [{
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
21 xtype: 'checkbox',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
22 flex: 1,
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
23 name: this.name,
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
24 fieldLabel: this.fieldLabel,
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
25 labelWidth: this.labelWidth,
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
26 listeners: this.listeners,
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
27 triggerAction: this.triggerAction,
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
28 msgTarget: 'none',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
29 tpl: this.tpl
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
30 }, {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
31 xtype: 'image',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
32 name: 'warnImg',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
33 src: 'resources/img/icon-warning.gif',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
34 width: 12,
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
35 height: 12,
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
36 hidden: true
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
37 }, {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
38 xtype: 'image',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
39 name: 'errorImg',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
40 src: 'resources/img/icon-error.gif',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
41 width: 12,
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
42 height: 12,
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
43 hidden: true
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
44 }];
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
45 this.callParent(arguments);
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
46 },
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
47
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
48 showWarnings: function(warnings) {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
49 var img = this.down('image[name=warnImg]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
50 Ext.create('Ext.tip.ToolTip', {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
51 target: img.getEl(),
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
52 html: warnings
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
53 });
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
54 this.down('checkbox').invalidCls = 'x-lada-warning';
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
55 this.down('checkbox').markInvalid('');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
56 img.show();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
57 var fieldset = this.up('fieldset[collapsible=true]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
58 if (fieldset) {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
59 fieldset.showWarnings(warnings);
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
60 }
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
61 },
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
62
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
63 showErrors: function(errors) {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
64 var img = this.down('image[name=errorImg]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
65 var warnImg = this.down('image[name=warnImg]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
66 warnImg.hide();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
67 Ext.create('Ext.tip.ToolTip', {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
68 target: img.getEl(),
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
69 html: errors
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
70 });
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
71 this.down('checkbox').invalidCls = 'x-lada-error';
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
72 this.down('checkbox').markInvalid('');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
73 img.show();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
74 var fieldset = this.up('fieldset[collapsible=true]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
75 if (fieldset) {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
76 fieldset.showErrors();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
77 }
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
78 },
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
79
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
80 clearWarningOrError: function() {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
81 this.down('image[name=errorImg]').hide();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
82 this.down('image[name=warnImg]').hide();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
83 },
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
84
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
85 getValue: function() {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
86 return this.down('checkbox').getValue();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
87 },
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
88
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
89 getName: function() {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
90 return this.name;
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
91 },
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
92
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
93 setReadOnly: function(value) {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
94 this.down('checkbox').setReadOnly(value);
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
95 }
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
96 });

http://lada.wald.intevation.org