annotate app/view/widget/base/CheckBox.js @ 819:00072c3c926e

reload works now.
author Dustin Demuth <dustin@intevation.de>
date Fri, 29 May 2015 09:31:00 +0200
parents 291ac2e2bcf5
children a031b98c7edc
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',
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
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',
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
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) {
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
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 },
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 showErrors: function(errors) {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
66 var img = this.down('image[name=errorImg]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
67 var warnImg = this.down('image[name=warnImg]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
68 warnImg.hide();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
69 Ext.create('Ext.tip.ToolTip', {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
70 target: img.getEl(),
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
71 html: errors
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
72 });
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
73 this.down('checkbox').invalidCls = 'x-lada-error';
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
74 this.down('checkbox').markInvalid('');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
75 img.show();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
76 var fieldset = this.up('fieldset[collapsible=true]');
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
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
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
81 }
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 clearWarningOrError: function() {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
85 this.down('image[name=errorImg]').hide();
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
86 this.down('image[name=warnImg]').hide();
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 getValue: function() {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
90 return this.down('checkbox').getValue();
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 getName: function() {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
94 return this.name;
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
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
97 setReadOnly: function(value) {
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
98 this.down('checkbox').setReadOnly(value);
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
99 }
f240fe19ff5d Added a Checkbox Widget
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
100 });

http://lada.wald.intevation.org