annotate app/view/widget/base/CheckBox.js @ 865:7bd3afe30ac2

Updated version number.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 10 Jul 2015 18:37:58 +0200
parents a031b98c7edc
children 777bf66dbb11
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,
854
a031b98c7edc Geplant-Checkbox for Messungen is now ReadOnly
Dustin Demuth <dustin@intevation.de>
parents: 634
diff changeset
28 readOnly: this.readOnly,
610
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
29 msgTarget: 'none',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
30 tpl: this.tpl
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
31 }, {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
32 xtype: 'image',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
33 name: 'warnImg',
632
fead63bb5fb4 Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 610
diff changeset
34 src: 'resources/img/dialog-warning.png',
fead63bb5fb4 Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 610
diff changeset
35 width: 14,
fead63bb5fb4 Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 610
diff changeset
36 height: 14,
610
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
37 hidden: true
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
38 }, {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
39 xtype: 'image',
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
40 name: 'errorImg',
632
fead63bb5fb4 Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 610
diff changeset
41 src: 'resources/img/emblem-important.png',
fead63bb5fb4 Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 610
diff changeset
42 width: 14,
fead63bb5fb4 Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 610
diff changeset
43 height: 14,
610
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
44 hidden: true
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
45 }];
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
46 this.callParent(arguments);
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
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
49 showWarnings: function(warnings) {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
50 var img = this.down('image[name=warnImg]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
51 Ext.create('Ext.tip.ToolTip', {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
52 target: img.getEl(),
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
53 html: warnings
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
54 });
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
55 this.down('checkbox').invalidCls = 'x-lada-warning';
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
56 this.down('checkbox').markInvalid('');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
57 img.show();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
58 var fieldset = this.up('fieldset[collapsible=true]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
59 if (fieldset) {
634
291ac2e2bcf5 Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 632
diff changeset
60 var i18n = Lada.getApplication().bundle;
291ac2e2bcf5 Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 632
diff changeset
61 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
62 fieldset.showWarningOrError(true, warningText);
610
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
63 }
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
64 },
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
65
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
66 showErrors: function(errors) {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
67 var img = this.down('image[name=errorImg]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
68 var warnImg = this.down('image[name=warnImg]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
69 warnImg.hide();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
70 Ext.create('Ext.tip.ToolTip', {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
71 target: img.getEl(),
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
72 html: errors
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
73 });
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
74 this.down('checkbox').invalidCls = 'x-lada-error';
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
75 this.down('checkbox').markInvalid('');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
76 img.show();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
77 var fieldset = this.up('fieldset[collapsible=true]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
78 if (fieldset) {
634
291ac2e2bcf5 Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 632
diff changeset
79 var i18n = Lada.getApplication().bundle;
291ac2e2bcf5 Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 632
diff changeset
80 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
81 fieldset.showWarningOrError(false, '', true, errorText);
610
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
82 }
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 clearWarningOrError: function() {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
86 this.down('image[name=errorImg]').hide();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
87 this.down('image[name=warnImg]').hide();
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
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
90 getValue: function() {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
91 return this.down('checkbox').getValue();
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
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
94 getName: function() {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
95 return this.name;
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
96 },
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
97
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
98 setReadOnly: function(value) {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
99 this.down('checkbox').setReadOnly(value);
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
100 }
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
101 });

http://lada.wald.intevation.org