From 8047ae3d83ba0718fb7a42907036157e5c680b85 Mon Sep 17 00:00:00 2001
From: "Andrey V.Kosteltsev" <AKosteltsev@IBS.RU>
Date: Mon, 4 Jul 2022 23:59:32 +0300
Subject: IBS: _sila UI theme

---
 src/components/_sila/Global/TableToolbarExport.vue | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 src/components/_sila/Global/TableToolbarExport.vue

(limited to 'src/components/_sila/Global/TableToolbarExport.vue')

diff --git a/src/components/_sila/Global/TableToolbarExport.vue b/src/components/_sila/Global/TableToolbarExport.vue
new file mode 100644
index 00000000..69646ea6
--- /dev/null
+++ b/src/components/_sila/Global/TableToolbarExport.vue
@@ -0,0 +1,36 @@
+<template>
+  <b-button
+    class="d-flex align-items-center"
+    variant="primary"
+    :download="download"
+    :href="href"
+  >
+    {{ $t('global.action.export') }}
+  </b-button>
+</template>
+
+<script>
+export default {
+  props: {
+    data: {
+      type: Array,
+      default: () => [],
+    },
+    fileName: {
+      type: String,
+      default: 'data',
+    },
+  },
+  computed: {
+    dataForExport() {
+      return JSON.stringify(this.data);
+    },
+    download() {
+      return `${this.fileName}.json`;
+    },
+    href() {
+      return `data:text/json;charset=utf-8,${this.dataForExport}`;
+    },
+  },
+};
+</script>
-- 
cgit v1.2.3

