8
8
hide: 0
9
9
}"
10
10
:open-group =" 'id' + _uid"
11
+ :class =" {
12
+ 'force-toolbar': contextMenuOpen || editing,
13
+ }"
11
14
class =" self"
12
15
popover-class =" force-tooltip"
13
16
trigger =" hover"
14
17
placement =" left"
15
18
offset =" 24"
16
19
@click.native =" onClick"
20
+ @mouseenter.native =" onContextMenuMouseEnter"
21
+ @mouseleave.native =" onContextMenuMouseLeave"
17
22
>
18
23
<span
19
24
v-show =" isExpandableType"
58
63
<VueIcon
59
64
v-tooltip =" editErrorMessage"
60
65
v-if =" !editValid"
61
- class =" icon-button warning"
66
+ class =" small-icon warning"
62
67
icon =" warning"
63
68
/>
64
69
<template v-else >
65
- <VueIcon
70
+ <VueButton
66
71
v-tooltip =" $t('DataField.edit.cancel.tooltip')"
67
- class =" icon-button medium "
68
- icon =" cancel"
72
+ class =" icon-button flat "
73
+ icon-left =" cancel"
69
74
@click =" cancelEdit()"
70
75
/>
71
- <VueIcon
76
+ <VueButton
72
77
v-tooltip =" $t('DataField.edit.submit.tooltip')"
73
- class =" icon-button"
74
- icon =" save"
78
+ class =" icon-button flat "
79
+ icon-left =" save"
75
80
@click =" submitEdit()"
76
81
/>
77
82
</template >
86
91
v-html =" formattedValue"
87
92
/>
88
93
<span class =" actions" >
89
- <VueIcon
94
+ <VueButton
90
95
v-tooltip =" 'Edit value'"
91
96
v-if =" isValueEditable"
92
- class =" edit-value icon-button"
93
- icon =" edit"
97
+ class =" edit-value icon-button flat "
98
+ icon-left =" edit"
94
99
@click =" openEdit()"
95
100
/>
96
101
<template v-if =" quickEdits " >
97
- <VueIcon
102
+ <VueButton
98
103
v-tooltip =" info.title || 'Quick edit'"
99
104
v-for =" (info, index) of quickEdits"
100
105
:key =" index"
101
106
:class =" info.class"
102
- :icon =" info.icon"
107
+ :icon-left =" info.icon"
103
108
class =" quick-edit icon-button"
104
109
@click =" quickEdit(info, $event)"
105
110
/>
106
111
</template >
107
- <VueIcon
112
+ <VueButton
108
113
v-tooltip =" 'Add new value'"
109
114
v-if =" isSubfieldsEditable && !addingValue"
110
- class =" add-value icon-button"
111
- icon =" add_circle"
115
+ class =" add-value icon-button flat "
116
+ icon-left =" add_circle"
112
117
@click =" addNewValue()"
113
118
/>
114
- <VueIcon
119
+ <VueButton
115
120
v-tooltip =" 'Remove value'"
116
121
v-if =" removable"
117
- class =" remove-field icon-button"
118
- icon =" delete"
122
+ class =" remove-field icon-button flat "
123
+ icon-left =" delete"
119
124
@click =" removeField()"
120
125
/>
126
+
127
+ <!-- Context menu -->
128
+ <VueDropdown
129
+ :open.sync =" contextMenuOpen"
130
+ >
131
+ <VueButton
132
+ slot =" trigger"
133
+ icon-left =" more_vert"
134
+ class =" icon-button flat"
135
+ />
136
+
137
+ <div
138
+ class =" context-menu-dropdown"
139
+ @mouseenter =" onContextMenuMouseEnter"
140
+ @mouseleave =" onContextMenuMouseLeave"
141
+ >
142
+ <VueDropdownButton
143
+ icon-left =" flip_to_front"
144
+ @click =" copyToClipboard"
145
+ >
146
+ {{ $t('DataField.contextMenu.copyValue') }}
147
+ </VueDropdownButton >
148
+ </div >
149
+ </VueDropdown >
121
150
</span >
122
151
</template >
123
152
@@ -186,7 +215,8 @@ import {
186
215
sortByKey ,
187
216
openInEditor ,
188
217
escape ,
189
- specialTokenToString
218
+ specialTokenToString ,
219
+ copyToClipboard
190
220
} from ' src/util'
191
221
192
222
import DataFieldEdit from ' ../mixins/data-field-edit'
@@ -228,6 +258,7 @@ export default {
228
258
229
259
data () {
230
260
return {
261
+ contextMenuOpen: false ,
231
262
limit: Array .isArray (this .field .value ) ? 10 : Infinity ,
232
263
expanded: this .depth === 0 && this .field .key !== ' $route' && (subFieldCount (this .field .value ) < 5 )
233
264
}
@@ -399,6 +430,10 @@ export default {
399
430
},
400
431
401
432
methods: {
433
+ copyToClipboard () {
434
+ copyToClipboard (this .field .value )
435
+ },
436
+
402
437
onClick (event ) {
403
438
// Cancel if target is interactive
404
439
if (event .target .tagName === ' INPUT' || event .target .className .includes (' button' )) {
@@ -422,7 +457,18 @@ export default {
422
457
}
423
458
},
424
459
425
- hyphen : v => v .replace (/ \s / g , ' -' )
460
+ hyphen : v => v .replace (/ \s / g , ' -' ),
461
+
462
+ onContextMenuMouseEnter () {
463
+ clearTimeout (this .$_contextMenuTimer )
464
+ },
465
+
466
+ onContextMenuMouseLeave () {
467
+ clearTimeout (this .$_contextMenuTimer )
468
+ this .$_contextMenuTimer = setTimeout (() => {
469
+ this .contextMenuOpen = false
470
+ }, 4000 )
471
+ }
426
472
}
427
473
}
428
474
</script >
@@ -460,16 +506,20 @@ export default {
460
506
top - 1px
461
507
.icon-button
462
508
user-select none
463
- width 16 px
509
+ width 20 px
464
510
height @width
465
511
& :first-child
466
512
margin-left 6px
467
513
& :not (:last-child )
468
514
margin-right 6px
515
+ .icon-button >>> .vue-ui-icon ,
516
+ .small-icon
517
+ width 16px
518
+ height @width
469
519
.warning >>> svg
470
520
fill $orange
471
521
& :hover ,
472
- & .editing
522
+ & .force-toolbar
473
523
.actions
474
524
visibility visible
475
525
.colon
@@ -499,6 +549,10 @@ export default {
499
549
.vue-ui-dark-mode &
500
550
color : #24 24 24
501
551
552
+ .edit-overlay
553
+ display inline - flex
554
+ align-items center
555
+
502
556
.key
503
557
color #88 13 91
504
558
.vue-ui-dark-mode &
@@ -599,4 +653,9 @@ export default {
599
653
600
654
.remove-field
601
655
margin-left 10px
656
+
657
+ .context-menu-dropdown
658
+ .vue-ui-button
659
+ display block
660
+ width 100%
602
661
</style >
0 commit comments