Mercurial > lada > lada-client
changeset 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 | 9f5d8885e464 |
children | 9265637fe6c0 |
files | app/controller/FilterResult.js app/view/grid/FilterResult.js resources/i18n/Lada_de-DE.properties resources/img/printer.png |
diffstat | 4 files changed, 65 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controller/FilterResult.js Fri Aug 14 13:31:30 2015 +0200 +++ b/app/controller/FilterResult.js Thu Aug 20 14:37:37 2015 +0200 @@ -38,6 +38,9 @@ }, 'filterresultgrid toolbar button[action=export]': { click: this.downloadFile + }, + 'filterresultgrid toolbar button[action=print]': { + click: this.printSelection } }); this.callParent(arguments); @@ -211,6 +214,60 @@ }); }, + /** + * Send the selection to a Printservice + */ + printSelection: function(button) { + var grid = button.up('grid'); + var selection = grid.getView().getSelectionModel().getSelection(); + var i18n = Lada.getApplication().bundle; + var proben = []; + for (var i = 0; i < selection.length; i++) { + proben.push(selection[i].get('id')); + } + var me = this; + Ext.Ajax.request({ + method: 'POST', + url: '127.0.0.1', // TODO + jsonData: {'proben': proben}, // TODO + success: function(response) { + console.log('success'); + var content = response.responseText; + var blob = new Blob([content],{type: 'application/pdf'}); + saveAs(blob, 'lada-print.pdf'); + }, + failure: function(response) { + console.log('failure'); + // Error handling + // TODO + if (response.responseText) { + try { + var json = Ext.JSON.decode(response.responseText); + } + catch(e){ + console.log(e); + } + } + if (json) { + if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ + formPanel.setMessages(json.errors, json.warnings); + } + if(json.message){ + Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') + +' #'+json.message, + Lada.getApplication().bundle.getMsg(json.message)); + } else { + Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), + i18n.getMsg('err.msg.print.noContact')); + } + } else { + Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), + i18n.getMsg('err.msg.print.noContact')); + } + } + }); + }, + reload: function(btn) { if (btn === 'yes') { location.reload();
--- a/app/view/grid/FilterResult.js Fri Aug 14 13:31:30 2015 +0200 +++ b/app/view/grid/FilterResult.js Thu Aug 20 14:37:37 2015 +0200 @@ -51,6 +51,11 @@ icon: 'resources/img/svn-update.png', action: 'export', disabled: true + }, { + text: 'Auswahl Drucken', + icon: 'resources/img/printer.png', + action: 'print', + disabled: true }, '-', { @@ -102,6 +107,7 @@ this.down('button[action=addProbe]').enable(); this.down('button[action=import]').enable(); this.down('button[action=export]').enable(); + this.down('button[action=print]').enable(); } else if (store.model.modelName == 'Lada.model.MessprogrammList') { t.setText(i18n.getMsg('probeplanning')); @@ -110,6 +116,7 @@ this.down('button[action=addProbe]').disable(); this.down('button[action=import]').disable(); this.down('button[action=export]').disable(); + this.down('button[action=print]').disable(); } else { t.setText('');
--- a/resources/i18n/Lada_de-DE.properties Fri Aug 14 13:31:30 2015 +0200 +++ b/resources/i18n/Lada_de-DE.properties Thu Aug 20 14:37:37 2015 +0200 @@ -132,6 +132,7 @@ err.msg.response.body:Die Antwort des Servers konnte nicht ausgewertet werden. err.msg.laf.filecreatefailed:Die LAF-Datei konnte nicht erzeugt werden. err.msg.novalidmessprogramm:Es wurd kein valides Messprogramm ausgewählt +err.msg.print.noContact:Der Druckdienst antwortet nicht oder hat ein nicht näher erfasstes Problem. err.msg.deskriptorvalidation:Die Deskriptoren haben das falsche Format.<br />Richtig wäre: D: 99 99 99 99 99 99 99 99 99 99 99 99' probecreated:Probe(n) wurde(n) erzeugt.