blob: c67855527347e2d6a6bdd6f82d6dc24aefacfd4c [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>
Ed Tanousdbd37e02024-03-23 14:56:34 -070013import { useI18n } from 'vue-i18n';
Yoshie Muranakab1a71912020-04-29 10:52:39 -070014export default {
15 props: {
16 data: {
17 type: Array,
Derick Montague602e98a2020-10-21 16:20:00 -050018 default: () => [],
Yoshie Muranakab1a71912020-04-29 10:52:39 -070019 },
20 fileName: {
21 type: String,
Derick Montague602e98a2020-10-21 16:20:00 -050022 default: 'data',
23 },
Yoshie Muranakab1a71912020-04-29 10:52:39 -070024 },
Ed Tanousdbd37e02024-03-23 14:56:34 -070025 data() {
26 return {
27 $t: useI18n().t,
28 };
29 },
Yoshie Muranakab1a71912020-04-29 10:52:39 -070030 computed: {
31 dataForExport() {
32 return JSON.stringify(this.data);
33 },
34 download() {
35 return `${this.fileName}.json`;
36 },
37 href() {
38 return `data:text/json;charset=utf-8,${this.dataForExport}`;
Derick Montague602e98a2020-10-21 16:20:00 -050039 },
40 },
Yoshie Muranakab1a71912020-04-29 10:52:39 -070041};
42</script>