Mercurial > gemma
diff client/src/lib/mixins.js @ 3798:e008197e2215 yworks-svg2pdf
client: improve pdf generation
* Use generatePDF() from HydrologicalConditions.vue to unify code.
* Split out formatting of gaugeInfo, used from Waterlevel.vue
and HydrologicalConditions.vue.
* Make paper width and size setting in generatePDF() more readable
by grouping the conditions more logically.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Thu, 04 Jul 2019 10:15:46 +0200 |
parents | 243316850889 |
children | f4deb4aae485 |
line wrap: on
line diff
--- a/client/src/lib/mixins.js Thu Jul 04 10:12:19 2019 +0200 +++ b/client/src/lib/mixins.js Thu Jul 04 10:15:46 2019 +0200 @@ -70,6 +70,18 @@ ...mapState("user", ["user"]) }, methods: { + gaugeInfo(selectedGauge) { + // returns string with formatted gauge info + return ( + selectedGauge.properties.objname + + " (" + + selectedGauge.id + .split(".")[1] + .replace(/[()]/g, "") + .split(",")[3] + + ")" + ); + }, generatePDF(params) { // creates a new jsPDF object into this.pdf.doc let templateData = params["templateData"]; @@ -81,8 +93,13 @@ this.templateData.properties.paperSize ); // pdf width and height in millimeter (landscape) - this.pdf.width = templateData.properties.paperSize === "a3" ? 420 : 297; - this.pdf.height = templateData.properties.paperSize === "a4" ? 297 : 210; + if (templateData.properties.paperSize === "a3") { + this.pdf.width = 420; + this.pdf.height = 297; + } else { + this.pdf.width = 297; + this.pdf.height = 210; + } // check the template elements if (templateData) { let defaultFontSize = 11,