# HG changeset patch # User Markus Kottlaender # Date 1562938335 -7200 # Node ID 2aaa1948b5252d8497748c946c0281f1e7a0cc30 # Parent afc7bca44df4c73584d9220c1b0d32458bf4bc5d client: diagrams: moved downloadPDF function to mixin and thereby unified how titles are created diff -r afc7bca44df4 -r 2aaa1948b525 client/src/components/fairway/AvailableFairwayDepth.vue --- 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; diff -r afc7bca44df4 -r 2aaa1948b525 client/src/components/fairway/AvailableFairwayDepthLNWL.vue --- 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; diff -r afc7bca44df4 -r 2aaa1948b525 client/src/components/fairway/Fairwayprofile.vue --- 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, diff -r afc7bca44df4 -r 2aaa1948b525 client/src/components/gauge/HydrologicalConditions.vue --- 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, diff -r afc7bca44df4 -r 2aaa1948b525 client/src/components/gauge/Waterlevel.vue --- 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; diff -r afc7bca44df4 -r 2aaa1948b525 client/src/lib/mixins.js --- 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;