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