blob: b49b3154da9c3c7b012350896aa2bb91fba6c40f [file] [log] [blame]
Yoshie Muranaka183c2752020-02-12 11:30:49 -08001<template>
2 <transition name="slide">
3 <div v-if="isToolbarActive" class="toolbar-container">
4 <div class="toolbar-content">
5 <p class="toolbar-selected">
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -08006 {{ selectedItemsCount }} {{ $t('global.action.selected') }}
Yoshie Muranaka183c2752020-02-12 11:30:49 -08007 </p>
8 <div class="toolbar-actions d-flex">
9 <b-button
10 v-for="(action, index) in actions"
11 :key="index"
12 variant="primary"
13 class="d-block"
14 @click="$emit('batchAction', action.value)"
15 >
Yoshie Muranakaeaa04802020-02-28 13:21:27 -080016 {{ action.label }}
Yoshie Muranaka183c2752020-02-12 11:30:49 -080017 </b-button>
Yoshie Muranakab1a71912020-04-29 10:52:39 -070018 <slot name="export"></slot>
Yoshie Muranaka183c2752020-02-12 11:30:49 -080019 <b-button
20 variant="primary"
21 class="d-block"
22 @click="$emit('clearSelected')"
23 >
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -080024 {{ $t('global.action.cancel') }}
Yoshie Muranaka183c2752020-02-12 11:30:49 -080025 </b-button>
26 </div>
27 </div>
28 </div>
29 </transition>
30</template>
31
32<script>
33export default {
34 name: 'TableToolbar',
35 props: {
36 selectedItemsCount: {
37 type: Number,
38 required: true
39 },
40 actions: {
41 type: Array,
Yoshie Muranakab1a71912020-04-29 10:52:39 -070042 default: () => [],
Yoshie Muranaka183c2752020-02-12 11:30:49 -080043 validator: prop => {
44 return prop.every(action => {
45 return (
Yoshie Muranakaeaa04802020-02-28 13:21:27 -080046 action.hasOwnProperty('value') && action.hasOwnProperty('label')
Yoshie Muranaka183c2752020-02-12 11:30:49 -080047 );
48 });
49 }
50 }
51 },
52 data() {
53 return {
54 isToolbarActive: false
55 };
56 },
57 watch: {
58 selectedItemsCount: function(selectedItemsCount) {
59 if (selectedItemsCount > 0) {
60 this.isToolbarActive = true;
61 } else {
62 this.isToolbarActive = false;
63 }
64 }
65 }
66};
67</script>
68
69<style lang="scss" scoped>
Derick Montague40865722020-04-13 17:01:19 -050070@import 'src/assets/styles/helpers';
71
Yoshie Muranaka183c2752020-02-12 11:30:49 -080072$toolbar-height: 46px;
73
74.toolbar-container {
75 width: 100%;
76 position: relative;
77}
78
79.toolbar-content {
80 height: $toolbar-height;
81 background-color: $primary;
82 color: $white;
83 position: absolute;
84 left: 0;
85 right: 0;
86 top: -$toolbar-height;
87 display: flex;
88 flex-direction: row;
89 justify-content: space-between;
90}
91
92.toolbar-actions {
93 > :last-child {
94 position: relative;
95 &::before {
96 content: '';
97 position: absolute;
98 height: $toolbar-height / 2;
99 border-left: 2px solid $white;
100 left: -2px;
101 top: $toolbar-height / 4;
102 }
103 }
104}
105
106.toolbar-selected {
107 line-height: $toolbar-height;
108 margin: 0;
109 padding: 0 $spacer;
110}
111
112.slide-enter-active {
113 transition: transform $duration--moderate-02 $entrance-easing--productive;
114}
115.slide-leave-active {
116 transition: transform $duration--moderate-02 $exit-easing--productive;
117}
118.slide-enter,
119.slide-leave-to {
120 transform: translateY($toolbar-height);
121}
122</style>