Mercurial > lada > lada-client
annotate app/view/widget/base/ComboBox.js @ 1272:208254152ac0
Printing: calcualte NWG < sign in the client.
Also: removed ToDos from printing
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Mon, 19 Dec 2016 14:23:04 +0100 |
parents | 3e6756b0fc97 |
children | d17501b967f2 |
rev | line source |
---|---|
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 * |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 */ |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 |
892
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
847
diff
changeset
|
9 /** |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
847
diff
changeset
|
10 * This Widget extends a Panel to creat a custom Combobox |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
847
diff
changeset
|
11 */ |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 Ext.define('Lada.view.widget.base.ComboBox', { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 extend: 'Ext.form.Panel', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 alias: 'widget.cbox', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 layout: 'hbox', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 border: 0, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 margin: '0, 0, 5, 0', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 initComponent: function() { |
1080
15d7b7a9e177
Override getValue for Netzbetreiber Combobox to allways return the correct
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1016
diff
changeset
|
23 if (this.editable === undefined) { |
15d7b7a9e177
Override getValue for Netzbetreiber Combobox to allways return the correct
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1016
diff
changeset
|
24 this.editable = true; |
15d7b7a9e177
Override getValue for Netzbetreiber Combobox to allways return the correct
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1016
diff
changeset
|
25 } |
1179
08bd9f1c791b
Implement allowBlank for custom ComboBox.
Tom Gottfried <tom@intevation.de>
parents:
1108
diff
changeset
|
26 if (this.allowBlank === undefined) { |
08bd9f1c791b
Implement allowBlank for custom ComboBox.
Tom Gottfried <tom@intevation.de>
parents:
1108
diff
changeset
|
27 this.allowBlank = true; |
08bd9f1c791b
Implement allowBlank for custom ComboBox.
Tom Gottfried <tom@intevation.de>
parents:
1108
diff
changeset
|
28 } |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 this.items = [{ |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 xtype: 'combobox', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 flex: 1, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 name: this.name, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 maxLength: this.maxLength, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 fieldLabel: this.fieldLabel, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 labelWidth: this.labelWidth, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 listeners: this.listeners, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 store: this.store, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 displayField: this.displayField, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 valueField: this.valueField, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 emptyText: this.emptyText, |
740
2e8da590ea0c
made Comboboces editable and filterable for; Messungenform: Messstelle,Datenbasis,Betriebsarts,Testdatensatz,Preobenart,Netzbetreiber Messungform: Messmethode Messwertegrid: Messgroesse,Messeinheit
Dustin Demuth <dustin@intevation.de>
parents:
738
diff
changeset
|
41 autoSelect: this.autoSelect || true, |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 queryMode: this.queryMode, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 triggerAction: this.triggerAction, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 typeAhead: this.typeAhead, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 minChars: this.minChars, |
817
1321efe444f0
ComboBox ForceSelection defaults to false now, ProbenehmerId can not be negative
Dustin Demuth <dustin@intevation.de>
parents:
740
diff
changeset
|
46 maxChars: this.maxChars, |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 multiSelect: this.multiSelect, |
1080
15d7b7a9e177
Override getValue for Netzbetreiber Combobox to allways return the correct
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1016
diff
changeset
|
48 editable: this.editable, |
847
95d40ca7bb70
Netbetreiber Combobox shall be readonly
Dustin Demuth <dustin@intevation.de>
parents:
817
diff
changeset
|
49 readOnly: this.readOnly, |
1179
08bd9f1c791b
Implement allowBlank for custom ComboBox.
Tom Gottfried <tom@intevation.de>
parents:
1108
diff
changeset
|
50 allowBlank: this.allowBlank, |
817
1321efe444f0
ComboBox ForceSelection defaults to false now, ProbenehmerId can not be negative
Dustin Demuth <dustin@intevation.de>
parents:
740
diff
changeset
|
51 forceSelection: this.forceSelection || false, |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 msgTarget: 'none', |
1016
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
892
diff
changeset
|
53 value: this.value, |
738
2db5d54a5685
Fixed ToDo in Umweltbereiche Store, made Umweltbereiche Typable to fix the regression, Sorted Umweltbereiche by ID
Dustin Demuth <dustin@intevation.de>
parents:
733
diff
changeset
|
54 tpl: this.tpl, |
2db5d54a5685
Fixed ToDo in Umweltbereiche Store, made Umweltbereiche Typable to fix the regression, Sorted Umweltbereiche by ID
Dustin Demuth <dustin@intevation.de>
parents:
733
diff
changeset
|
55 displayTpl: this.displayTpl |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 }, { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 xtype: 'image', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 name: 'warnImg', |
632
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
548
diff
changeset
|
59 src: 'resources/img/dialog-warning.png', |
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
548
diff
changeset
|
60 width: 14, |
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
548
diff
changeset
|
61 height: 14, |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 hidden: true |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 }, { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 xtype: 'image', |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 name: 'errorImg', |
632
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
548
diff
changeset
|
66 src: 'resources/img/emblem-important.png', |
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
548
diff
changeset
|
67 width: 14, |
fead63bb5fb4
Updated images for errors and warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
548
diff
changeset
|
68 height: 14, |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 hidden: true |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 }]; |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 this.callParent(arguments); |
1212
3e6756b0fc97
Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents:
1179
diff
changeset
|
72 /* listeners have been passed to combobox. Thus, clear them on panel |
3e6756b0fc97
Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents:
1179
diff
changeset
|
73 * to avoid double effects of events fired on combobox and panel. */ |
3e6756b0fc97
Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents:
1179
diff
changeset
|
74 this.clearListeners(); |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 }, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 showWarnings: function(warnings) { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 var img = this.down('image[name=warnImg]'); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 Ext.create('Ext.tip.ToolTip', { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 target: img.getEl(), |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 html: warnings |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 }); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 this.down('combobox').invalidCls = 'x-lada-warning'; |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 this.down('combobox').markInvalid(''); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 img.show(); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 var fieldset = this.up('fieldset[collapsible=true]'); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 if (fieldset) { |
634
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
88 var i18n = Lada.getApplication().bundle; |
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
89 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
|
90 fieldset.showWarningOrError(true, warningText); |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 } |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 }, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 showErrors: function(errors) { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 var img = this.down('image[name=errorImg]'); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 var warnImg = this.down('image[name=warnImg]'); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 warnImg.hide(); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 Ext.create('Ext.tip.ToolTip', { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 target: img.getEl(), |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 html: errors |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 }); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 this.down('combobox').invalidCls = 'x-lada-error'; |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 this.down('combobox').markInvalid(''); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 img.show(); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 var fieldset = this.up('fieldset[collapsible=true]'); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 if (fieldset) { |
634
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
107 var i18n = Lada.getApplication().bundle; |
291ac2e2bcf5
Set translateable messages for the parent fieldset.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
632
diff
changeset
|
108 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
|
109 fieldset.showWarningOrError(false, '', true, errorText); |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 } |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 }, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 clearWarningOrError: function() { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 this.down('image[name=errorImg]').hide(); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 this.down('image[name=warnImg]').hide(); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 }, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 getValue: function() { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 return this.down('combobox').getValue(); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 }, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 |
1016
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
892
diff
changeset
|
122 setValue: function(value) { |
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
892
diff
changeset
|
123 this.down('combobox').setValue(value); |
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
892
diff
changeset
|
124 }, |
d6e259e76de6
Updated filter value handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
892
diff
changeset
|
125 |
733
a8389baaf4af
Added method to clear values.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
658
diff
changeset
|
126 clearValue: function() { |
a8389baaf4af
Added method to clear values.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
658
diff
changeset
|
127 this.down('combobox').clearValue(); |
a8389baaf4af
Added method to clear values.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
658
diff
changeset
|
128 }, |
a8389baaf4af
Added method to clear values.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
658
diff
changeset
|
129 |
548
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 getName: function() { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 return this.name; |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 }, |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 setReadOnly: function(value) { |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 this.down('combobox').setReadOnly(value); |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 } |
d47ee7439f44
Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 }); |