Mercurial > lada > lada-client
comparison app/view/form/Ortszuordnung.js @ 1051:981339d774b8
merged stammdatengrids to default.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 01 Mar 2016 14:12:39 +0100 |
parents | 1bd4c0709bd6 |
children | f1d21e6a7449 |
comparison
equal
deleted
inserted
replaced
1048:eacf25f071c0 | 1051:981339d774b8 |
---|---|
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 /** | |
10 * Form to edit the Ortszuordnung of a Probe | |
11 */ | |
12 Ext.define('Lada.view.form.Ortszuordnung', { | |
13 extend: 'Ext.form.Panel', | |
14 alias: 'widget.ortszuordnungform', | |
15 | |
16 model: 'Lada.model.Ortszuordnung', | |
17 | |
18 requires: [ | |
19 'Lada.view.widget.Verwaltungseinheit', | |
20 'Lada.view.widget.Staat' | |
21 ], | |
22 | |
23 layout: 'fit', | |
24 margin: 5, | |
25 border: 0, | |
26 | |
27 record: null, | |
28 | |
29 trackResetOnLoad: true, | |
30 | |
31 initComponent: function() { | |
32 var i18n = Lada.getApplication().bundle; | |
33 this.items = [{ | |
34 xtype: 'fieldset', | |
35 title: i18n.getMsg('ortszuordnung.form.fset.title'), | |
36 layout: 'fit', | |
37 items: [{ | |
38 layout: 'hbox', | |
39 border: 0, | |
40 margin: '0, 0, 10, 0', | |
41 dockedItems: [{ | |
42 xtype: 'toolbar', | |
43 dock: 'bottom', | |
44 border: '0, 1, 1, 1', | |
45 style: { | |
46 borderBottom: '1px solid #b5b8c8 !important', | |
47 borderLeft: '1px solid #b5b8c8 !important', | |
48 borderRight: '1px solid #b5b8c8 !important' | |
49 }, | |
50 items: [{ | |
51 text: i18n.getMsg('ortszuordnung.form.setOrt'), | |
52 qtip: i18n.getMsg('ortszuordnung.form.setOrt.qtip'), | |
53 icon: 'resources/img/dialog-ok-apply.png', | |
54 action: 'setOrt', | |
55 enableToggle: true, | |
56 disabled: true | |
57 }, '->', { | |
58 text: i18n.getMsg('save'), | |
59 qtip: i18n.getMsg('save.qtip'), | |
60 icon: 'resources/img/dialog-ok-apply.png', | |
61 action: 'save', | |
62 disabled: true | |
63 }, { | |
64 text: i18n.getMsg('discard'), | |
65 qtip: i18n.getMsg('discard.qtip'), | |
66 icon: 'resources/img/dialog-cancel.png', | |
67 action: 'discard', | |
68 disabled: true | |
69 }] | |
70 }], | |
71 items: [{ | |
72 layout: 'vbox', | |
73 border: 0, | |
74 margin: '0, 10, 0, 0', | |
75 items: [{ | |
76 xtype: 'tfield', | |
77 labelWidth: 125, | |
78 maxLength: 100, | |
79 name: 'ortszusatztext', | |
80 fieldLabel: i18n.getMsg('ortszuordnung.form.field.ortszusatztext') | |
81 }, { | |
82 xtype: 'tfield', | |
83 labelWidth: 125, | |
84 maxLength: 100, | |
85 name: 'ortszuordnungTyp', | |
86 fieldLabel: i18n.getMsg('ortszuordnung.form.field.ortszuordnungtyp') | |
87 }, { | |
88 xtype: 'textfield', | |
89 submitValue: true, | |
90 readOnly: true, | |
91 hidden: true, | |
92 name: 'ortId' | |
93 }] | |
94 }, { | |
95 layout: 'vbox', | |
96 flex: 1, | |
97 margin: '0, 10, 0, 0', | |
98 border: 0, | |
99 items: [{ | |
100 xtype: 'displayfield', | |
101 labelWidth: 125, | |
102 fieldLabel: i18n.getMsg('orte.gemeinde'), | |
103 name: 'gemeinde' | |
104 }, { | |
105 xtype: 'displayfield', | |
106 labelWidth: 125, | |
107 fieldLabel: i18n.getMsg('staat'), | |
108 name: 'staat' | |
109 }] | |
110 }, { | |
111 layout: 'vbox', | |
112 flex: 1, | |
113 margin: '0, 10, 0, 0', | |
114 border: 0, | |
115 items: [{ | |
116 xtype: 'displayfield', | |
117 labelWidth: 125, | |
118 fieldLabel: i18n.getMsg('orte.lon'), | |
119 name: 'lon' | |
120 }, { | |
121 xtype: 'displayfield', | |
122 labelWidth: 125, | |
123 fieldLabel: i18n.getMsg('orte.lat'), | |
124 name: 'lat' | |
125 }] | |
126 }] | |
127 }] | |
128 }]; | |
129 this.callParent(arguments); | |
130 }, | |
131 | |
132 setRecord: function(record) { | |
133 this.getForm().loadRecord(record); | |
134 | |
135 if (! record.get('readonly')) { | |
136 this.down('[action=setOrt]').enable(); | |
137 this.setReadOnly(false); | |
138 } | |
139 else { | |
140 this.setReadOnly(true); | |
141 } | |
142 var ortId = this.getRecord().get('ortId'); | |
143 this.refreshOrt(ortId); | |
144 }, | |
145 | |
146 refreshOrt: function(ortId) { | |
147 var orteStore = Ext.StoreManager.get('orte'); | |
148 var ort = orteStore.getById(ortId); | |
149 var verwStore = Ext.StoreManager.get('verwaltungseinheiten'); | |
150 var verw = verwStore.getById(ort.get('gemId')); | |
151 var staatStore = Ext.StoreManager.get('staaten'); | |
152 var staat = staatStore.getById(ort.get('staatId')); | |
153 | |
154 this.getForm().setValues({ | |
155 gemeinde: verw.get('bezeichnung'), | |
156 staat: staat.get('staatIso'), | |
157 lon: ort.get('longitude'), | |
158 lat: ort.get('latitude') | |
159 }); | |
160 }, | |
161 | |
162 /** | |
163 * setOrt can be called from a CallbackFunction, ie select from a grid. | |
164 * it will set the ortId of this record | |
165 */ | |
166 setOrt: function(row, selRecord, index, opts) { | |
167 var newOrtId = selRecord.get('id'); | |
168 var r = this.getRecord(); | |
169 if (newOrtId) { | |
170 if (newOrtId != r.get('ortId')) { | |
171 r.set('ortId', newOrtId); | |
172 this.getForm().setValues({ortId: newOrtId}); | |
173 this.refreshOrt(newOrtId); | |
174 //set dirty... | |
175 this.fireEvent('dirtychange', this.getForm(), true); | |
176 } | |
177 } | |
178 }, | |
179 | |
180 setMessages: function(errors, warnings) { | |
181 var key; | |
182 var element; | |
183 var content; | |
184 var i18n = Lada.getApplication().bundle; | |
185 if (warnings) { | |
186 for (key in warnings) { | |
187 element = this.down('component[name=' + key + ']'); | |
188 if (!element) { | |
189 continue; | |
190 } | |
191 content = warnings[key]; | |
192 var warnText = ''; | |
193 for (var i = 0; i < content.length; i++) { | |
194 warnText += i18n.getMsg(content[i].toString()) + '\n'; | |
195 } | |
196 element.showWarnings(warnText); | |
197 } | |
198 } | |
199 if (errors) { | |
200 for (key in errors) { | |
201 element = this.down('component[name=' + key + ']'); | |
202 if (!element) { | |
203 continue; | |
204 } | |
205 content = errors[key]; | |
206 var errorText = ''; | |
207 for (var i = 0; i < content.length; i++) { | |
208 errorText += i18n.getMsg(content[i].toString()) + '\n'; | |
209 } | |
210 element.showErrors(errorText); | |
211 } | |
212 } | |
213 }, | |
214 | |
215 clearMessages: function() { | |
216 this.down('tfield[name=ortszusatztext]').clearWarningOrError(); | |
217 this.down('tfield[name=ortszuordnungTyp]').clearWarningOrError(); | |
218 }, | |
219 | |
220 setReadOnly: function(value) { | |
221 this.down('tfield[name=ortszusatztext]').setReadOnly(value); | |
222 this.down('tfield[name=ortszuordnungTyp]').setReadOnly(value); | |
223 } | |
224 }); | |
225 |