Mercurial > lada > lada-client
comparison app/view/form/Messung.js @ 961:6f1cc3316e2d
Intermediate Result. When creating a Messung a Statuswert will be set.
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Tue, 10 Nov 2015 13:07:57 +0100 |
parents | 73b397d8dd3a |
children | 6a6f2c6fe8ee |
comparison
equal
deleted
inserted
replaced
960:73b397d8dd3a | 961:6f1cc3316e2d |
---|---|
153 | 153 |
154 setRecord: function(record) { | 154 setRecord: function(record) { |
155 var form = this.getForm(); | 155 var form = this.getForm(); |
156 form.loadRecord(record); | 156 form.loadRecord(record); |
157 if (record.getId()){ | 157 if (record.getId()){ |
158 this.retrieveStatus(record.id, record.get('status')); | 158 this.retrieveStatus(record.getId(), record.get('status')); |
159 } | 159 } |
160 else { | 160 else { |
161 //remove the StatusWert and StatusStufe field from the form | 161 //remove the StatusWert and StatusStufe field from the form |
162 var sw = this.down('[name=status]'); | 162 var sw = this.down('[name=status]'); |
163 var ss = this.down('[name=stufe]'); | 163 var ss = this.down('[name=stufe]'); |
169 retrieveStatus: function(messungsId, statusId) { | 169 retrieveStatus: function(messungsId, statusId) { |
170 var i18n = Lada.getApplication().bundle; | 170 var i18n = Lada.getApplication().bundle; |
171 var msg = i18n.getMsg('load.statuswert'); | 171 var msg = i18n.getMsg('load.statuswert'); |
172 var textfield = this.down('[name=status]'); | 172 var textfield = this.down('[name=status]'); |
173 | 173 |
174 textfield.setRawValue(msg); | 174 if(textfield) { |
175 | 175 textfield.setRawValue(msg); |
176 var sStore = Ext.StoreManager.lookup('Status'); | 176 } |
177 if (!sStore) { | 177 |
178 sStore = Ext.create('Lada.store.Status'); | 178 var sStore = Ext.create('Lada.store.Status'); |
179 } | 179 sStore.load({ |
180 sStore.on('load', | 180 params: { |
181 function(records, operation, success) { | 181 messungsId: messungsId |
182 }, | |
183 callback: function(records, operation, success) { | |
182 var sw, ss; | 184 var sw, ss; |
183 var i18n = Lada.getApplication().bundle; | 185 var i18n = Lada.getApplication().bundle; |
184 if (sStore.getTotalCount() === 0 || !statusId) { | 186 if (sStore.getTotalCount() === 0 || !statusId) { |
185 sw = 0; | 187 sw = 0; |
186 } | 188 } |
189 ss = sStore.getById(statusId).get('statusStufe'); | 191 ss = sStore.getById(statusId).get('statusStufe'); |
190 } | 192 } |
191 this.setStatusWert(sw); | 193 this.setStatusWert(sw); |
192 this.setStatusStufe(ss); | 194 this.setStatusStufe(ss); |
193 }, | 195 }, |
194 this); | 196 scope: this |
195 sStore.load({ | |
196 params: { | |
197 messungsId: messungsId | |
198 } | |
199 }); | 197 }); |
200 }, | 198 }, |
201 | 199 |
202 /** | 200 /** |
203 * Updates the Messungform and fills the Statuswert | 201 * Updates the Messungform and fills the Statuswert |
214 var item = swStore.getById(value); | 212 var item = swStore.getById(value); |
215 if (item) { | 213 if (item) { |
216 msg = item.get('wert'); | 214 msg = item.get('wert'); |
217 } | 215 } |
218 } | 216 } |
219 textfield.setRawValue(msg); | 217 if (textfield) { |
218 textfield.setRawValue(msg); | |
219 } | |
220 }, | 220 }, |
221 }); | 221 }); |
222 }, | 222 }, |
223 | 223 |
224 /** | 224 /** |
236 var item = ssStore.getById(value); | 236 var item = ssStore.getById(value); |
237 if (item) { | 237 if (item) { |
238 msg = item.get('stufe'); | 238 msg = item.get('stufe'); |
239 } | 239 } |
240 } | 240 } |
241 textfield.setRawValue(msg); | 241 if (textfield) { |
242 textfield.setRawValue(msg); | |
243 } | |
242 }, | 244 }, |
243 }); | 245 }); |
244 }, | 246 }, |
245 | 247 |
246 setMessages: function(errors, warnings) { | 248 setMessages: function(errors, warnings) { |