50
50
</div >
51
51
52
52
<!-- Table -->
53
- <div class =" col table-responsive pivottable" >
53
+ <div class =" p-0 position-relative col table-responsive pivottable" >
54
54
<pivot-table
55
55
ref =" pivottable"
56
56
:data =" data"
70
70
<slot name =" loading" ></slot >
71
71
</template >
72
72
</pivot-table >
73
+ <transition name =" copied-alert" >
74
+ <div v-if =" showCopiedAlert" class =" alert alert-secondary pivot-copied-alert" >
75
+ Copied to clipboard
76
+ </div >
77
+ </transition >
73
78
</div >
74
79
75
80
<div v-if =" showSettings" class =" table-option-button circle-background bg-primary dropdown-toggle" data-toggle =" dropdown" aria-haspopup =" true" aria-expanded =" false" v-b-tooltip:hover title =" Show menu" ></div >
76
81
<div class =" dropdown-menu" aria-labelledby =" dropdownMenuButton" >
77
- <a class =" dropdown-item" href =" #!" @click =" _clickedSaveButton('csv')" >Save table in CSV</a >
78
- <a class =" dropdown-item" href =" #!" @click =" _clickedSaveButton('tsv')" >Save table in TSV</a >
82
+ <button ref =" pivot-copy-button" class =" dropdown-item" >Copy table to clipboard</button >
83
+ <button class =" dropdown-item" @click =" _clickedSaveButton('csv')" >Save table in CSV</button >
84
+ <button class =" dropdown-item" @click =" _clickedSaveButton('tsv')" >Save table in TSV</button >
79
85
</div >
80
86
</div >
81
87
</div >
82
88
</template >
83
89
84
90
<script >
91
+ import Clipboard from ' clipboard'
85
92
import PivotTable from ' ./PivotTable.vue'
86
93
import naturalSort from ' javascript-natural-sort'
87
94
import Draggable from ' vuedraggable'
@@ -161,12 +168,23 @@ export default {
161
168
colFields: this .fields .colFields ,
162
169
fieldsOrder: this .fields .fieldsOrder
163
170
},
164
- dragging: false
171
+ dragging: false ,
172
+ showCopiedAlert: false
165
173
}
166
174
},
167
175
created () {
168
176
this ._sortFields (this .internal .fieldsOrder )
169
177
},
178
+ mounted () {
179
+ const self = this
180
+ const clipboard = new Clipboard (self .$refs [' pivot-copy-button' ], {
181
+ target : () => self .$refs .pivottable .$el
182
+ })
183
+ clipboard .on (' success' , (e ) => {
184
+ e .clearSelection ()
185
+ self .onPivotTableCopied (e)
186
+ })
187
+ },
170
188
computed: {
171
189
dragAreaClass : function () {
172
190
return this .dragging ? ' drag-area--highlight' : null
@@ -239,6 +257,10 @@ export default {
239
257
this .internal .fieldsOrder = { ... this .internal .fieldsOrder , [label]: ' desc' }
240
258
}
241
259
this ._sortFields (this .internal .fieldsOrder )
260
+ },
261
+ onPivotTableCopied () {
262
+ this .showCopiedAlert = true
263
+ setTimeout (() => { this .showCopiedAlert = false }, 700 )
242
264
}
243
265
}
244
266
}
@@ -360,6 +382,7 @@ $carret-bold-svg: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/200
360
382
}
361
383
362
384
.pivottable {
385
+ margin : 0 15px ;
363
386
& ~ .table-option-button {
364
387
opacity : 0 ;
365
388
}
@@ -381,4 +404,18 @@ $hamburger-svg: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/
381
404
border-width : 2px !important ;
382
405
left : $base-space * 3 + 10rem - $border-space * 3 ;
383
406
}
407
+
408
+ .pivot-copied-alert {
409
+ position : absolute ;
410
+ bottom : 1rem ;
411
+ right : 1rem ;
412
+ }
413
+
414
+ .copied-alert-enter-active {
415
+ opacity : 0.6 ;
416
+ }
417
+ .copied-alert-leave-active {
418
+ opacity : 0 ;
419
+ transition : all 0.7s ease ;
420
+ }
384
421
</style >
0 commit comments