summaryrefslogtreecommitdiff
path: root/src/components/Global
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/Global')
-rw-r--r--src/components/Global/TableToolbar.vue3
-rw-r--r--src/components/Global/TableToolbarExport.vue35
2 files changed, 37 insertions, 1 deletions
diff --git a/src/components/Global/TableToolbar.vue b/src/components/Global/TableToolbar.vue
index 041a9c18..331f0076 100644
--- a/src/components/Global/TableToolbar.vue
+++ b/src/components/Global/TableToolbar.vue
@@ -15,6 +15,7 @@
>
{{ action.label }}
</b-button>
+ <slot name="export"></slot>
<b-button
variant="primary"
class="d-block"
@@ -38,7 +39,7 @@ export default {
},
actions: {
type: Array,
- required: true,
+ default: () => [],
validator: prop => {
return prop.every(action => {
return (
diff --git a/src/components/Global/TableToolbarExport.vue b/src/components/Global/TableToolbarExport.vue
new file mode 100644
index 00000000..ed1d980f
--- /dev/null
+++ b/src/components/Global/TableToolbarExport.vue
@@ -0,0 +1,35 @@
+<template>
+ <b-link
+ class="btn btn-primary d-block align-self-center"
+ :download="download"
+ :href="href"
+ >
+ {{ $t('global.action.export') }}
+ </b-link>
+</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>