Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 1 | <template> |
| 2 | <transition name="slide"> |
| 3 | <div v-if="isToolbarActive" class="toolbar-container"> |
| 4 | <div class="toolbar-content"> |
| 5 | <p class="toolbar-selected"> |
Yoshie Muranaka | 547b5fc | 2020-02-24 15:42:40 -0800 | [diff] [blame] | 6 | {{ selectedItemsCount }} {{ $t('global.action.selected') }} |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 7 | </p> |
| 8 | <div class="toolbar-actions d-flex"> |
Dixsie Wolmers | 27d68af | 2021-05-02 18:20:27 -0500 | [diff] [blame] | 9 | <slot name="toolbar-buttons"></slot> |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 10 | <b-button |
| 11 | v-for="(action, index) in actions" |
| 12 | :key="index" |
Yoshie Muranaka | ed06dc1 | 2020-06-16 12:12:27 -0700 | [diff] [blame] | 13 | :data-test-id="`table-button-${action.value}Selected`" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 14 | variant="primary" |
| 15 | class="d-block" |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 16 | @click="$emit('batch-action', action.value)" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 17 | > |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 18 | {{ action.label }} |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 19 | </b-button> |
| 20 | <b-button |
SurenNeware | e409b73 | 2020-08-10 19:00:34 +0530 | [diff] [blame] | 21 | variant="secondary" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 22 | class="d-block" |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 23 | @click="$emit('clear-selected')" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 24 | > |
Yoshie Muranaka | 547b5fc | 2020-02-24 15:42:40 -0800 | [diff] [blame] | 25 | {{ $t('global.action.cancel') }} |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 26 | </b-button> |
| 27 | </div> |
| 28 | </div> |
| 29 | </div> |
| 30 | </transition> |
| 31 | </template> |
| 32 | |
| 33 | <script> |
Ed Tanous | dbd37e0 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 34 | import { useI18n } from 'vue-i18n'; |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 35 | export default { |
| 36 | name: 'TableToolbar', |
| 37 | props: { |
| 38 | selectedItemsCount: { |
| 39 | type: Number, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 40 | required: true, |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 41 | }, |
| 42 | actions: { |
| 43 | type: Array, |
Yoshie Muranaka | b1a7191 | 2020-04-29 10:52:39 -0700 | [diff] [blame] | 44 | default: () => [], |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 45 | validator: (prop) => { |
| 46 | return prop.every((action) => { |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 47 | return ( |
Yoshie Muranaka | efd7c88 | 2020-10-30 09:32:06 -0700 | [diff] [blame] | 48 | Object.prototype.hasOwnProperty.call(action, 'value') && |
| 49 | Object.prototype.hasOwnProperty.call(action, 'label') |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 50 | ); |
| 51 | }); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 52 | }, |
| 53 | }, |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 54 | }, |
| 55 | data() { |
| 56 | return { |
Ed Tanous | dbd37e0 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 57 | $t: useI18n().t, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 58 | isToolbarActive: false, |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 59 | }; |
| 60 | }, |
| 61 | watch: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 62 | selectedItemsCount: function (selectedItemsCount) { |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 63 | if (selectedItemsCount > 0) { |
| 64 | this.isToolbarActive = true; |
| 65 | } else { |
| 66 | this.isToolbarActive = false; |
| 67 | } |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 68 | }, |
| 69 | }, |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 70 | }; |
| 71 | </script> |
| 72 | |
| 73 | <style lang="scss" scoped> |
Ed Tanous | 9c72979 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 74 | @import '@/assets/styles/bmc/helpers/_index.scss'; |
| 75 | @import '@/assets/styles/bootstrap/_helpers.scss'; |
| 76 | |
| 77 | @import 'bootstrap/dist/css/bootstrap.css'; |
| 78 | |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 79 | $toolbar-height: 46px; |
| 80 | |
| 81 | .toolbar-container { |
| 82 | width: 100%; |
| 83 | position: relative; |
Ed Tanous | 9c72979 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 84 | //z-index: $zindex-dropdown + 1; |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | .toolbar-content { |
| 88 | height: $toolbar-height; |
Yoshie Muranaka | 01da818 | 2020-07-08 15:46:43 -0700 | [diff] [blame] | 89 | background-color: theme-color('primary'); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 90 | color: $white; |
| 91 | position: absolute; |
| 92 | left: 0; |
| 93 | right: 0; |
| 94 | top: -$toolbar-height; |
| 95 | display: flex; |
| 96 | flex-direction: row; |
| 97 | justify-content: space-between; |
| 98 | } |
| 99 | |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 100 | .toolbar-selected { |
| 101 | line-height: $toolbar-height; |
| 102 | margin: 0; |
| 103 | padding: 0 $spacer; |
| 104 | } |
| 105 | |
Sneha Patel | e516d4d | 2021-05-24 14:11:26 -0500 | [diff] [blame] | 106 | // Using v-deep to style export slot child-element |
| 107 | // depricated and vue-js 3 |
| 108 | .toolbar-actions ::v-deep .btn { |
| 109 | position: relative; |
| 110 | &:after { |
| 111 | content: ''; |
| 112 | position: absolute; |
| 113 | left: 0; |
| 114 | height: 1.5rem; |
| 115 | width: 1px; |
| 116 | background: rgba($white, 0.6); |
| 117 | } |
| 118 | &:last-child, |
| 119 | &:first-child { |
| 120 | &:after { |
| 121 | width: 0; |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 126 | .slide-enter-active { |
| 127 | transition: transform $duration--moderate-02 $entrance-easing--productive; |
| 128 | } |
| 129 | .slide-leave-active { |
| 130 | transition: transform $duration--moderate-02 $exit-easing--productive; |
| 131 | } |
SurenNeware | 151dd24 | 2020-11-10 20:15:05 +0530 | [diff] [blame] | 132 | .slide-enter, // Remove this vue2 based only class when switching to vue3 |
| 133 | .slide-enter-from, // This is vue3 based only class modified from 'slide-enter' |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 134 | .slide-leave-to { |
| 135 | transform: translateY($toolbar-height); |
| 136 | } |
| 137 | </style> |