changeset 3249:d91c1200dc6b

client: diagram-template: cleanup code * remove unnecessary form.papersize data
author Fadi Abbud <fadi.abbud@intevation.de>
date Mon, 13 May 2019 16:16:55 +0200
parents 3159ee3bcb16
children 246754028bf4
files client/src/components/gauge/HydrologicalConditions.vue client/src/components/gauge/Waterlevel.vue
diffstat 2 files changed, 12 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/gauge/HydrologicalConditions.vue	Mon May 13 13:13:37 2019 +0200
+++ b/client/src/components/gauge/HydrologicalConditions.vue	Mon May 13 16:16:55 2019 +0200
@@ -349,7 +349,6 @@
         })
           .then(response => {
             this.templateData = response.data.template_data;
-            this.form.paperSize = this.templateData.properties.paperSize;
           })
           .catch(e => {
             const { status, data } = e.response;
--- a/client/src/components/gauge/Waterlevel.vue	Mon May 13 13:13:37 2019 +0200
+++ b/client/src/components/gauge/Waterlevel.vue	Mon May 13 16:16:55 2019 +0200
@@ -107,8 +107,7 @@
       scale: null,
       axes: null,
       form: {
-        template: null,
-        form: null
+        template: null
       },
       templates: [],
       defaultTemplate: {
@@ -196,9 +195,15 @@
       );
     },
     downloadPDF() {
-      this.pdf.doc = new jsPDF("l", "mm", this.form.paperSize);
-      this.pdf.width = this.form.paperSize === "a3" ? 420 : 297;
-      this.pdf.height = this.form.paperSize === "a3" ? 297 : 210;
+      this.pdf.doc = new jsPDF(
+        "l",
+        "mm",
+        this.templateData.properties.paperSize
+      );
+      this.pdf.width =
+        this.templateData.properties.paperSize === "a3" ? 420 : 297;
+      this.pdf.height =
+        this.templateData.properties.paperSize === "a3" ? 297 : 210;
       // check the template elements
       if (this.templateData) {
         let defaultFontSize = 11,
@@ -293,7 +298,6 @@
     applyChange() {
       if (this.form.template.hasOwnProperty("properties")) {
         this.templateData = this.defaultTemplate;
-        this.form.paperSize = this.defaultTemplate.properties.paperSize;
         return;
       }
       if (this.form.template) {
@@ -305,7 +309,6 @@
         })
           .then(response => {
             this.templateData = response.data.template_data;
-            this.form.paperSize = this.templateData.properties.paperSize;
           })
           .catch(e => {
             const { status, data } = e.response;
@@ -351,10 +354,10 @@
       var imgData = canvas.toDataURL("image/png");
       // landscape format is used for both a3,a4 papersize
       if (!width) {
-        width = this.form.paperSize === "a3" ? 380 : 290;
+        width = this.templateData.properties.paperSize === "a3" ? 380 : 290;
       }
       if (!height) {
-        height = this.form.paperSize === "a3" ? 130 : 100;
+        height = this.templateData.properties.paperSize === "a3" ? 130 : 100;
       }
       if (["topright", "bottomright"].indexOf(position) !== -1) {
         x = this.pdf.width - offset.x - width;