blob: a12ae801b52dc8b26a4a9fd6d488667c2b4d2b05 [file] [log] [blame]
Yoshie Muranaka0e893f02020-02-18 13:39:45 -08001<template>
Yoshie Muranakabe3af332020-05-11 08:23:04 -07002 <span>
3 <b-link
4 v-if="value === 'export'"
5 class="align-bottom btn-link py-0"
6 :download="download"
7 :href="href"
8 :title="title"
9 :aria-label="title"
10 >
11 <slot name="icon">
12 {{ $t('global.action.export') }}
13 </slot>
14 </b-link>
15 <b-button
16 v-else
17 variant="link"
18 class="py-0"
19 :aria-label="title"
20 :title="title"
21 :disabled="!enabled"
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053022 @click="$emit('click-table-action', value)"
Yoshie Muranakabe3af332020-05-11 08:23:04 -070023 >
24 <slot name="icon">
25 {{ title }}
26 </slot>
27 </b-button>
28 </span>
Yoshie Muranaka0e893f02020-02-18 13:39:45 -080029</template>
30
31<script>
Yoshie Muranakabe3af332020-05-11 08:23:04 -070032import { omit } from 'lodash';
33
Yoshie Muranaka0e893f02020-02-18 13:39:45 -080034export default {
35 name: 'TableRowAction',
36 props: {
37 value: {
38 type: String,
Derick Montague602e98a2020-10-21 16:20:00 -050039 required: true,
Yoshie Muranaka0e893f02020-02-18 13:39:45 -080040 },
41 enabled: {
42 type: Boolean,
Derick Montague602e98a2020-10-21 16:20:00 -050043 default: true,
Yoshie Muranaka0e893f02020-02-18 13:39:45 -080044 },
45 title: {
46 type: String,
Derick Montague602e98a2020-10-21 16:20:00 -050047 default: null,
Yoshie Muranakabe3af332020-05-11 08:23:04 -070048 },
49 rowData: {
50 type: Object,
Derick Montague602e98a2020-10-21 16:20:00 -050051 default: () => {},
Yoshie Muranakabe3af332020-05-11 08:23:04 -070052 },
53 exportName: {
54 type: String,
Derick Montague602e98a2020-10-21 16:20:00 -050055 default: 'export',
56 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -070057 },
58 computed: {
59 dataForExport() {
60 return JSON.stringify(omit(this.rowData, 'actions'));
61 },
62 download() {
63 return `${this.exportName}.json`;
64 },
65 href() {
66 return `data:text/json;charset=utf-8,${this.dataForExport}`;
Derick Montague602e98a2020-10-21 16:20:00 -050067 },
68 },
Yoshie Muranaka0e893f02020-02-18 13:39:45 -080069};
70</script>