changeset 4493:b4880e7d4082

client: ImportOverview: change place of save button
author Fadi Abbud <fadi.abbud@intevation.de>
date Fri, 27 Sep 2019 15:49:52 +0200
parents e289d3f32b75
children a82d75a1b497
files client/src/components/importoverview/ImportOverview.vue
diffstat 1 files changed, 24 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/importoverview/ImportOverview.vue	Fri Sep 27 14:20:42 2019 +0200
+++ b/client/src/components/importoverview/ImportOverview.vue	Fri Sep 27 15:49:52 2019 +0200
@@ -4,7 +4,10 @@
       icon="clipboard-check"
       :title="importReviewLabel"
       :closeCallback="$parent.close"
-      :actions="[{ callback: loadUpdatedLogs, icon: 'sync' }]"
+      :actions="[
+        { callback: saveImportsView, icon: 'download' },
+        { callback: loadUpdatedLogs, icon: 'sync' }
+      ]"
     />
     <div class="position-relative">
       <UISpinnerOverlay v-if="loading" />
@@ -101,16 +104,6 @@
           <LogDetail :entry="entry"></LogDetail>
         </template>
       </UITableBody>
-      <a
-        :class="[
-          'btn btn-xs btn-info d-block mt-2',
-          { disabled: !imports.length }
-        ]"
-        :href="importsCSV"
-        download="log.txt"
-      >
-        <translate class="text-white">Export as CSV</translate>
-      </a>
     </div>
   </div>
 </template>
@@ -184,21 +177,6 @@
     countryLabel() {
       return this.$gettext("Country");
     },
-    importsCSV() {
-      if (!this.imports.length) return;
-      return (
-        "data:text/csv;charset=utf-8," +
-        encodeURIComponent(
-          this.imports
-            .map(el => {
-              return ` ${el.id}, ${el.kind}, ${el.enqueued}, ${el.user ||
-                " "}, ${el.country || " "}, ${el.signer || " "}, ${el.state ||
-                " "}, ${el.warnings || " "}`;
-            })
-            .join("\n")
-        )
-      );
-    },
     importReviewLabel() {
       return this.$gettext("Import review");
     },
@@ -252,6 +230,26 @@
     }
   },
   methods: {
+    saveImportsView() {
+      let element = document.createElement("a");
+      element.setAttribute("download", "log.txt");
+      element.setAttribute("href", this.csvLink());
+      element.click();
+    },
+    csvLink() {
+      return (
+        "data:text/csv;charset=utf-8," +
+        encodeURIComponent(
+          this.imports
+            .map(el => {
+              return ` ${el.id}, ${el.kind}, ${el.enqueued}, ${el.user ||
+                " "}, ${el.country || " "}, ${el.signer || " "}, ${el.state ||
+                " "}, ${el.warnings || " "}`;
+            })
+            .join("\n")
+        )
+      );
+    },
     showSingleRessource(id) {
       id = id * 1;
       this.loadDetails(id)