blob: 69646ea68282ff1a54393eca3ff9decfcf667934 [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,
Derick Montague602e98a2020-10-21 16:20:00 -050017 default: () => [],
Yoshie Muranakab1a71912020-04-29 10:52:39 -070018 },
19 fileName: {
20 type: String,
Derick Montague602e98a2020-10-21 16:20:00 -050021 default: 'data',
22 },
Yoshie Muranakab1a71912020-04-29 10:52:39 -070023 },
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}`;
Derick Montague602e98a2020-10-21 16:20:00 -050033 },
34 },
Yoshie Muranakab1a71912020-04-29 10:52:39 -070035};
36</script>