changeset 4794:a2b5021de297

client: waterlevel: improve button style and downloaded file naming
author Fadi Abbud <fadi.abbud@intevation.de>
date Fri, 25 Oct 2019 16:12:43 +0200
parents d6d73ca5496a
children fe838fc3ca69
files client/src/components/gauge/Waterlevel.vue
diffstat 1 files changed, 8 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/gauge/Waterlevel.vue	Fri Oct 25 15:09:10 2019 +0200
+++ b/client/src/components/gauge/Waterlevel.vue	Fri Oct 25 16:12:43 2019 +0200
@@ -60,7 +60,7 @@
               { disabled: !waterlevels.length }
             ]"
             :href="csvLink"
-            :download="csvFileName"
+            :download="`${fileName}.csv`"
           >
             <translate>Export as CSV</translate>
           </a>
@@ -68,10 +68,10 @@
             @click="downloadImage"
             id="downloadimage"
             :class="[
-              'btn btn-sm btn-info d-block w-100 mt-2',
+              'btn btn-sm btn-info text-white d-block w-100 mt-2',
               { disabled: !waterlevels.length }
             ]"
-            :download="imageFilename"
+            :download="`${fileName}.png`"
           >
             <translate>Export as Image</translate>
           </a>
@@ -194,21 +194,10 @@
         "data:text/csv;charset=utf-8," + encodeURIComponent(this.waterlevelsCSV)
       );
     },
-    imageFilename() {
-      return (
-        this.downloadFilename(
-          this.$gettext("Waterlevel"),
-          this.selectedGauge.properties.objname
-        ) + ".png"
-      );
-    },
-    csvFileName() {
-      if (!this.dateFromD || !this.dateToD) return "";
-      return (
-        this.downloadFilename(
-          this.$gettext("Waterlevel"),
-          this.selectedGauge.properties.objname
-        ) + ".csv"
+    fileName() {
+      return this.downloadFilename(
+        this.$gettext("Waterlevel"),
+        this.selectedGauge.properties.objname
       );
     },
     hasPredictions() {
@@ -241,7 +230,6 @@
           : "DEFAULT"
       );
     },
-
     downloadSVG() {
       let svg = document.getElementById(this.containerId).firstElementChild;
       let svgXML = new XMLSerializer().serializeToString(svg);
@@ -260,12 +248,7 @@
         templateData: this.templateData,
         diagramTitle: diagramTitle
       });
-      this.pdf.doc.save(
-        this.downloadFilename(
-          this.$gettext("Waterlevel"),
-          this.selectedGauge.properties.objname
-        ) + ".pdf"
-      );
+      this.pdf.doc.save(this.fileName + ".pdf");
     },
     applyChange() {
       if (this.form.template.hasOwnProperty("properties")) {