changeset 3965:2aaa1948b525 diagram-cleanup

client: diagrams: moved downloadPDF function to mixin and thereby unified how titles are created
author Markus Kottlaender <markus@intevation.de>
date Fri, 12 Jul 2019 15:32:15 +0200
parents afc7bca44df4
children c10897e0273b
files client/src/components/fairway/AvailableFairwayDepth.vue client/src/components/fairway/AvailableFairwayDepthLNWL.vue client/src/components/fairway/Fairwayprofile.vue client/src/components/gauge/HydrologicalConditions.vue client/src/components/gauge/Waterlevel.vue client/src/lib/mixins.js
diffstat 6 files changed, 10 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/fairway/AvailableFairwayDepth.vue	Fri Jul 12 15:18:15 2019 +0200
+++ b/client/src/components/fairway/AvailableFairwayDepth.vue	Fri Jul 12 15:32:15 2019 +0200
@@ -160,14 +160,6 @@
     }
   },
   methods: {
-    downloadPDF() {
-      let title = `Available Fairway Depth: ${this.featureName}`;
-      this.generatePDF({
-        templateData: this.templateData,
-        diagramTitle: title
-      });
-      this.pdf.doc.save(`Available Fairway Depth: ${this.featureName}`);
-    },
     addDiagramLegend(position, offset, color) {
       let x = offset.x,
         y = offset.y;
--- a/client/src/components/fairway/AvailableFairwayDepthLNWL.vue	Fri Jul 12 15:18:15 2019 +0200
+++ b/client/src/components/fairway/AvailableFairwayDepthLNWL.vue	Fri Jul 12 15:32:15 2019 +0200
@@ -155,14 +155,6 @@
       };
       return style[index];
     },
-    downloadPDF() {
-      let title = `Available Fairway Depth vs LNWL: ${this.featureName}`;
-      this.generatePDF({
-        templateData: this.templateData,
-        diagramTitle: title
-      });
-      this.pdf.doc.save(`Available Fairway Depth LNWL: ${this.featureName}`);
-    },
     addDiagramLegend(position, offset, color) {
       let x = offset.x,
         y = offset.y;
--- a/client/src/components/fairway/Fairwayprofile.vue	Fri Jul 12 15:18:15 2019 +0200
+++ b/client/src/components/fairway/Fairwayprofile.vue	Fri Jul 12 15:32:15 2019 +0200
@@ -273,20 +273,6 @@
 
       return { fillColor, fillOpacity, strokeColor, strokeOpacity, strokeDash };
     },
-    downloadPDF() {
-      let fairwayInfo =
-        this.selectedBottleneck + " (" + this.selectedSurvey.date_info + ")";
-
-      this.generatePDF({
-        templateData: this.templateData,
-        diagramTitle: fairwayInfo
-      });
-
-      this.pdf.doc.save(
-        this.title.replace(/\s/g, "_").replace(/[():,]/g, "") + ".pdf"
-      );
-    },
-
     // Diagram legend
     addDiagramLegend(position, offset, color) {
       let x = offset.x,
--- a/client/src/components/gauge/HydrologicalConditions.vue	Fri Jul 12 15:18:15 2019 +0200
+++ b/client/src/components/gauge/HydrologicalConditions.vue	Fri Jul 12 15:32:15 2019 +0200
@@ -172,22 +172,6 @@
           : "DEFAULT"
       );
     },
-    downloadPDF() {
-      let diagramTitle =
-        this.gaugeInfo(this.selectedGauge) +
-        ": Hydrological Conditions " +
-        this.longtermInterval.join(" - ");
-
-      this.generatePDF({
-        templateData: this.templateData,
-        diagramTitle: diagramTitle
-      });
-
-      this.pdf.doc.save(
-        this.selectedGauge.properties.objname +
-          " Hydrological-condition Diagram.pdf"
-      );
-    },
     // Diagram legend
     addDiagramLegend(position, offset, color) {
       let x = offset.x,
--- a/client/src/components/gauge/Waterlevel.vue	Fri Jul 12 15:18:15 2019 +0200
+++ b/client/src/components/gauge/Waterlevel.vue	Fri Jul 12 15:32:15 2019 +0200
@@ -177,23 +177,6 @@
         this.selectedGauge.properties.objname + "-waterlevel-diagram.svg";
       saveAs(blog, filename);
     },
-    downloadPDF() {
-      let diagramTitle =
-        this.gaugeInfo(this.selectedGauge) +
-        ": Waterlevel " +
-        this.dateFrom.toLocaleDateString() +
-        " - " +
-        this.dateTo.toLocaleDateString();
-
-      this.generatePDF({
-        templateData: this.templateData,
-        diagramTitle: diagramTitle
-      });
-
-      this.pdf.doc.save(
-        this.selectedGauge.properties.objname + " Waterlevel-Diagram.pdf"
-      );
-    },
     // Diagram legend
     addDiagramLegend(position, offset, color) {
       let x = offset.x;
--- a/client/src/lib/mixins.js	Fri Jul 12 15:18:15 2019 +0200
+++ b/client/src/lib/mixins.js	Fri Jul 12 15:32:15 2019 +0200
@@ -185,6 +185,16 @@
     ...mapState("user", ["user"])
   },
   methods: {
+    downloadPDF() {
+      this.generatePDF({
+        templateData: this.templateData,
+        diagramTitle: this.title
+      });
+
+      this.pdf.doc.save(
+        this.title.replace(/\s/g, "_").replace(/[():,]/g, "") + ".pdf"
+      );
+    },
     addDiagram(position, offset, width, height) {
       let x = offset.x,
         y = offset.y;