comparison app/view/window/GenProbenFromMessprogramm.js @ 1205:613e48a3fef9

Error messages from LADA server are not related to HTTP errors.
author Tom Gottfried <tom@intevation.de>
date Fri, 30 Sep 2016 10:56:18 +0200
parents 95d24315d68e
children 1179a6358213
comparison
equal deleted inserted replaced
1204:95d24315d68e 1205:613e48a3fef9
141 */ 141 */
142 onSuccess: function(response) { 142 onSuccess: function(response) {
143 var i18n = Lada.getApplication().bundle; 143 var i18n = Lada.getApplication().bundle;
144 144
145 var json = Ext.JSON.decode(response.responseText); 145 var json = Ext.JSON.decode(response.responseText);
146 var radio = Ext.ComponentQuery.query('modeswitcher')[0] 146
147 .down('radiofield[inputValue=proben]'); 147 if (json.message != '200') {
148 radio.setValue(true); 148 // handle LADA server errors
149 149 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
150 var contentPanel = Ext.ComponentQuery.query('panel[name=main]')[0] 150 i18n.getMsg(json.message));
151 .down('panel[name=contentpanel]'); 151 } else {
152 contentPanel.removeAll(); //clear the panel: make space for new grids 152 var radio = Ext.ComponentQuery.query('modeswitcher')[0]
153 var gridstore = Ext.create('Lada.store.Proben'); 153 .down('radiofield[inputValue=proben]');
154 var frgrid = Ext.create('Lada.view.grid.ProbeList', { 154 radio.setValue(true);
155 plugins: [{ 155
156 ptype: 'gridrowexpander', 156 var contentPanel = Ext.ComponentQuery.query('panel[name=main]')[0]
157 gridType: 'Lada.view.grid.Messung', 157 .down('panel[name=contentpanel]');
158 expandOnDblClick: false, 158 contentPanel.removeAll(); //clear panel: make space for new grids
159 gridConfig: { 159 var gridstore = Ext.create('Lada.store.Proben');
160 bottomBar: false 160 var frgrid = Ext.create('Lada.view.grid.ProbeList', {
161 } 161 plugins: [{
162 }] 162 ptype: 'gridrowexpander',
163 }); 163 gridType: 'Lada.view.grid.Messung',
164 164 expandOnDblClick: false,
165 var columns = [{ 165 gridConfig: {
166 header: i18n.getMsg('prnId'), 166 bottomBar: false
167 dataIndex: 'probeIdAlt' 167 }
168 }, { 168 }]
169 header: i18n.getMsg('netzbetreiberId'), 169 });
170 dataIndex: 'netzbetreiberId', 170
171 renderer: function(value) { 171 var columns = [{
172 var r = ''; 172 header: i18n.getMsg('prnId'),
173 if (!value || value === '') { 173 dataIndex: 'probeIdAlt'
174 r = 'Error'; 174 }, {
175 } 175 header: i18n.getMsg('netzbetreiberId'),
176 var store = Ext.data.StoreManager.get('netzbetreiber'); 176 dataIndex: 'netzbetreiberId',
177 var record = store.getById(value); 177 renderer: function(value) {
178 if (record) { 178 var r = '';
179 r = record.get('netzbetreiber'); 179 if (!value || value === '') {
180 } 180 r = 'Error';
181 return r; 181 }
182 } 182 var store = Ext.data.StoreManager.get('netzbetreiber');
183 }, { 183 var record = store.getById(value);
184 header: i18n.getMsg('mstId'), 184 if (record) {
185 dataIndex: 'mstId', 185 r = record.get('netzbetreiber');
186 renderer: function(value) { 186 }
187 var r = ''; 187 return r;
188 if (!value || value === '') { 188 }
189 r = 'Error'; 189 }, {
190 } 190 header: i18n.getMsg('mstId'),
191 var store = Ext.data.StoreManager.get('messstellen'); 191 dataIndex: 'mstId',
192 var record = store.getById(value); 192 renderer: function(value) {
193 if (record) { 193 var r = '';
194 r = record.get('messStelle'); 194 if (!value || value === '') {
195 } 195 r = 'Error';
196 return r; 196 }
197 } 197 var store = Ext.data.StoreManager.get('messstellen');
198 }, { 198 var record = store.getById(value);
199 header: i18n.getMsg('datenbasisId'), 199 if (record) {
200 dataIndex: 'datenbasisId', 200 r = record.get('messStelle');
201 renderer: function(value) { 201 }
202 var r = ''; 202 return r;
203 if (!value || value === '') { 203 }
204 r = value; 204 }, {
205 } 205 header: i18n.getMsg('datenbasisId'),
206 var store = Ext.data.StoreManager.get('datenbasis'); 206 dataIndex: 'datenbasisId',
207 var record = store.getById(value); 207 renderer: function(value) {
208 if (record) { 208 var r = '';
209 r = record.get('datenbasis'); 209 if (!value || value === '') {
210 } 210 r = value;
211 return r; 211 }
212 } 212 var store = Ext.data.StoreManager.get('datenbasis');
213 }, { 213 var record = store.getById(value);
214 header: i18n.getMsg('baId'), 214 if (record) {
215 dataIndex: 'baId', 215 r = record.get('datenbasis');
216 renderer: function(value) { 216 }
217 var r = ''; 217 return r;
218 if (!value || value === '') { 218 }
219 r = ''; 219 }, {
220 } 220 header: i18n.getMsg('baId'),
221 var store = Ext.create('Ext.data.Store', { 221 dataIndex: 'baId',
222 fields: ['betriebsartId', 'betriebsart'], 222 renderer: function(value) {
223 data: [{ 223 var r = '';
224 'betriebsartId': '1', 224 if (!value || value === '') {
225 'betriebsart': 'Normal-/Routinebetrieb' 225 r = '';
226 }, { 226 }
227 'betriebsartId': '2', 227 var store = Ext.create('Ext.data.Store', {
228 'betriebsart': 'Störfall/Intensivbetrieb' 228 fields: ['betriebsartId', 'betriebsart'],
229 }] 229 data: [{
230 }); 230 'betriebsartId': '1',
231 var record = store.getById(value); 231 'betriebsart': 'Normal-/Routinebetrieb'
232 if (record) { 232 }, {
233 r = record.get('betriebsart'); 233 'betriebsartId': '2',
234 } 234 'betriebsart': 'Störfall/Intensivbetrieb'
235 return r; 235 }]
236 } 236 });
237 }, { 237 var record = store.getById(value);
238 header: i18n.getMsg('probenartId'), 238 if (record) {
239 dataIndex: 'probenartId', 239 r = record.get('betriebsart');
240 renderer: function(value) { 240 }
241 var r = ''; 241 return r;
242 if (!value || value === '') { 242 }
243 r = value; 243 }, {
244 } 244 header: i18n.getMsg('probenartId'),
245 var store = Ext.data.StoreManager.get('probenarten'); 245 dataIndex: 'probenartId',
246 var record = store.getById(value); 246 renderer: function(value) {
247 if (record) { 247 var r = '';
248 r = record.get('probenart'); 248 if (!value || value === '') {
249 } 249 r = value;
250 return r; 250 }
251 } 251 var store = Ext.data.StoreManager.get('probenarten');
252 }, { 252 var record = store.getById(value);
253 header: i18n.getMsg('sollVon'), 253 if (record) {
254 dataIndex: 'solldatumBeginn', 254 r = record.get('probenart');
255 renderer: function(value) { 255 }
256 if (!value) { 256 return r;
257 return ''; 257 }
258 } 258 }, {
259 return Ext.Date.format(value, 'd.m.Y'); 259 header: i18n.getMsg('sollVon'),
260 } 260 dataIndex: 'solldatumBeginn',
261 }, { 261 renderer: function(value) {
262 header: i18n.getMsg('sollBis'), 262 if (!value) {
263 dataIndex: 'solldatumEnde', 263 return '';
264 renderer: function(value) { 264 }
265 if (!value) { 265 return Ext.Date.format(value, 'd.m.Y');
266 return ''; 266 }
267 } 267 }, {
268 return Ext.Date.format(value, 'd.m.Y'); 268 header: i18n.getMsg('sollBis'),
269 } 269 dataIndex: 'solldatumEnde',
270 }]; 270 renderer: function(value) {
271 frgrid.reconfigure(gridstore, columns); 271 if (!value) {
272 272 return '';
273 gridstore.loadData(json.data); 273 }
274 contentPanel.add(frgrid); 274 return Ext.Date.format(value, 'd.m.Y');
275 Ext.Msg.show({ 275 }
276 title: i18n.getMsg('success'), 276 }];
277 autoScroll: true, 277 frgrid.reconfigure(gridstore, columns);
278 msg: me.evalResponse(json), 278
279 buttons: Ext.Msg.OK 279 gridstore.loadData(json.data);
280 }); 280 contentPanel.add(frgrid);
281 me.close(); 281 Ext.Msg.show({
282 title: i18n.getMsg('success'),
283 autoScroll: true,
284 msg: me.evalResponse(json),
285 buttons: Ext.Msg.OK
286 });
287 me.close();
288 }
282 }, 289 },
283 290
284 /** 291 /**
285 * Callback on failure of request (HTTP status != 200) 292 * Callback on failure of request (HTTP status != 200)
286 */ 293 */
314 + 'Alle ungesicherten Daten gehen dabei verloren.<br/>' 321 + 'Alle ungesicherten Daten gehen dabei verloren.<br/>'
315 + 'Soll die Anwendung jetzt neu geladen werden?', 322 + 'Soll die Anwendung jetzt neu geladen werden?',
316 this.reload); 323 this.reload);
317 } 324 }
318 // further error handling 325 // further error handling
319 if(json.message){ 326 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
320 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title') 327 i18n.getMsg('err.msg.generic.body'));
321 +' #'+json.message,
322 i18n.getMsg(json.message));
323 } else {
324 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
325 i18n.getMsg('err.msg.generic.body'));
326 }
327 } else { 328 } else {
328 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), 329 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
329 i18n.getMsg('err.msg.response.body')); 330 i18n.getMsg('err.msg.response.body'));
330 } 331 }
331 }, 332 },

http://lada.wald.intevation.org