Mercurial > lada > lada-client
comparison app/controller/FilterResult.js @ 923:7cbbe0485d0d
Added a Print-button which sends a selection of proben to a service which still has to be specified.
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Thu, 20 Aug 2015 14:37:37 +0200 |
parents | f220ba587c89 |
children | 3e3e737050b7 |
comparison
equal
deleted
inserted
replaced
922:9f5d8885e464 | 923:7cbbe0485d0d |
---|---|
36 'filterresultgrid toolbar button[action=import]': { | 36 'filterresultgrid toolbar button[action=import]': { |
37 click: this.uploadFile | 37 click: this.uploadFile |
38 }, | 38 }, |
39 'filterresultgrid toolbar button[action=export]': { | 39 'filterresultgrid toolbar button[action=export]': { |
40 click: this.downloadFile | 40 click: this.downloadFile |
41 }, | |
42 'filterresultgrid toolbar button[action=print]': { | |
43 click: this.printSelection | |
41 } | 44 } |
42 }); | 45 }); |
43 this.callParent(arguments); | 46 this.callParent(arguments); |
44 }, | 47 }, |
45 | 48 |
209 } | 212 } |
210 } | 213 } |
211 }); | 214 }); |
212 }, | 215 }, |
213 | 216 |
217 /** | |
218 * Send the selection to a Printservice | |
219 */ | |
220 printSelection: function(button) { | |
221 var grid = button.up('grid'); | |
222 var selection = grid.getView().getSelectionModel().getSelection(); | |
223 var i18n = Lada.getApplication().bundle; | |
224 var proben = []; | |
225 for (var i = 0; i < selection.length; i++) { | |
226 proben.push(selection[i].get('id')); | |
227 } | |
228 var me = this; | |
229 Ext.Ajax.request({ | |
230 method: 'POST', | |
231 url: '127.0.0.1', // TODO | |
232 jsonData: {'proben': proben}, // TODO | |
233 success: function(response) { | |
234 console.log('success'); | |
235 var content = response.responseText; | |
236 var blob = new Blob([content],{type: 'application/pdf'}); | |
237 saveAs(blob, 'lada-print.pdf'); | |
238 }, | |
239 failure: function(response) { | |
240 console.log('failure'); | |
241 // Error handling | |
242 // TODO | |
243 if (response.responseText) { | |
244 try { | |
245 var json = Ext.JSON.decode(response.responseText); | |
246 } | |
247 catch(e){ | |
248 console.log(e); | |
249 } | |
250 } | |
251 if (json) { | |
252 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ | |
253 formPanel.setMessages(json.errors, json.warnings); | |
254 } | |
255 if(json.message){ | |
256 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') | |
257 +' #'+json.message, | |
258 Lada.getApplication().bundle.getMsg(json.message)); | |
259 } else { | |
260 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | |
261 i18n.getMsg('err.msg.print.noContact')); | |
262 } | |
263 } else { | |
264 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | |
265 i18n.getMsg('err.msg.print.noContact')); | |
266 } | |
267 } | |
268 }); | |
269 }, | |
270 | |
214 reload: function(btn) { | 271 reload: function(btn) { |
215 if (btn === 'yes') { | 272 if (btn === 'yes') { |
216 location.reload(); | 273 location.reload(); |
217 } | 274 } |
218 } | 275 } |