[Lada-commits] [PATCH] Added a Print-button which sends a selection of proben to a service which still has to be specified

Wald Commits scm-commit at wald.intevation.org
Thu Aug 20 14:37:51 CEST 2015


# HG changeset patch
# User Dustin Demuth <dustin at intevation.de>
# Date 1440074257 -7200
# Node ID 7cbbe0485d0d0e9169fd5a4dff3cd18bf540e965
# Parent  9f5d8885e46455e604f133a1b64a09f91d09c634
Added a Print-button which sends a selection of proben to a service which still has to be specified.

diff -r 9f5d8885e464 -r 7cbbe0485d0d app/controller/FilterResult.js
--- 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();
diff -r 9f5d8885e464 -r 7cbbe0485d0d app/view/grid/FilterResult.js
--- 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('');
diff -r 9f5d8885e464 -r 7cbbe0485d0d resources/i18n/Lada_de-DE.properties
--- 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.
diff -r 9f5d8885e464 -r 7cbbe0485d0d resources/img/printer.png
Binary file resources/img/printer.png has changed


More information about the Lada-commits mailing list