Yoshie Muranaka | b1a7191 | 2020-04-29 10:52:39 -0700 | [diff] [blame] | 1 | <template> |
MichalX Szopinski | 25b631b | 2020-09-24 13:32:31 +0200 | [diff] [blame] | 2 | <b-button |
| 3 | class="d-flex align-items-center" |
| 4 | variant="primary" |
Yoshie Muranaka | b1a7191 | 2020-04-29 10:52:39 -0700 | [diff] [blame] | 5 | :download="download" |
| 6 | :href="href" |
| 7 | > |
| 8 | {{ $t('global.action.export') }} |
MichalX Szopinski | 25b631b | 2020-09-24 13:32:31 +0200 | [diff] [blame] | 9 | </b-button> |
Yoshie Muranaka | b1a7191 | 2020-04-29 10:52:39 -0700 | [diff] [blame] | 10 | </template> |
| 11 | |
| 12 | <script> |
| 13 | export 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> |