diff client/src/components/fairway/AvailableFairwayDepthLNWL.vue @ 4677:fa55e48bbca1

client: improve filename generation for downloads * unify filename for the generated csv files * move function to mixins.js * mark strings in filename for translations * replace whitespace with "-"
author Fadi Abbud <fadi.abbud@intevation.de>
date Tue, 15 Oct 2019 17:16:36 +0200
parents c47c8085cc7e
children b3f65cff13e8
line wrap: on
line diff
--- a/client/src/components/fairway/AvailableFairwayDepthLNWL.vue	Tue Oct 15 16:28:46 2019 +0200
+++ b/client/src/components/fairway/AvailableFairwayDepthLNWL.vue	Tue Oct 15 17:16:36 2019 +0200
@@ -91,7 +91,6 @@
 import { HTTP } from "@/lib/http";
 import { displayError } from "@/lib/errors";
 import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate";
-import sanitize from "sanitize-filename";
 import { localeDateString } from "@/lib/datelocalization";
 
 export default {
@@ -207,11 +206,12 @@
     },
     csvFileName() {
       if (!this.frequencyD) return;
-      return `${this.$gettext("fairwayavailabilityLNWL")}-${
-        this.featureName
-      }-${filters.surveyDate(this.fromDate)}-${filters.surveyDate(
-        this.toDate
-      )}-${this.$gettext(this.frequencyD)}-.csv`;
+      return (
+        this.downloadFilename(
+          this.$gettext("FairwayAvailabilityVsLNWL"),
+          this.featureName
+        ) + ".csv"
+      );
     },
     availability() {
       return this.plainAvailability;
@@ -293,10 +293,12 @@
         templateData: this.templateData,
         diagramTitle: title
       });
-      const filename = `AFDLNWL-${sanitize(
-        this.featureName
-      )}-${this.dateForPDF()}.pdf`;
-      this.pdf.doc.save(filename);
+      this.pdf.doc.save(
+        this.downloadFilename(
+          this.$gettext("FairwayAvailabilityVsLNWL"),
+          this.featureName
+        ) + ".pdf"
+      );
     },
     addDiagramLegend(position, offset, color) {
       let x = offset.x,