blob: 59642f5201ae2676c61ede1271d14b5f422fb3a2 [file] [log] [blame]
Yoshie Muranakab1a71912020-04-29 10:52:39 -07001<template>
MichalX Szopinski25b631b2020-09-24 13:32:31 +02002 <b-button
3 class="d-flex align-items-center"
4 variant="primary"
Yoshie Muranakab1a71912020-04-29 10:52:39 -07005 :download="download"
6 :href="href"
7 >
8 {{ $t('global.action.export') }}
MichalX Szopinski25b631b2020-09-24 13:32:31 +02009 </b-button>
Yoshie Muranakab1a71912020-04-29 10:52:39 -070010</template>
11
12<script>
13export default {
14 props: {
15 data: {
16 type: Array,
17 default: () => []
18 },
19 fileName: {
20 type: String,
21 default: 'data'
22 }
23 },
24 computed: {
25 dataForExport() {
26 return JSON.stringify(this.data);
27 },
28 download() {
29 return `${this.fileName}.json`;
30 },
31 href() {
32 return `data:text/json;charset=utf-8,${this.dataForExport}`;
33 }
34 }
35};
36</script>