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
120
121
122
123
124
|
<template>
<div :class="classList">
<label :for="id" @dblclick="edit()" :title="editing ? '':title">{{label}}</label>
<div @dblclick="edit()" v-if="!editing" :title="title">{{text}}</div>
<input :id="id" v-model="value" v-else @keypress="checkEnter($event)" :title="inputTitle"/>
</div>
</template>
<script>
import LocalisationService from '@js/Services/LocalisationService';
import MiningItem from '@js/Models/Queue/MiningItem';
import MessageService from '@js/Services/MessageService';
export default {
props: {
item : {
type: MiningItem
},
field: {
type: String
}
},
data() {
return {
editing : false,
value : this.item.getResultField(this.field),
title : LocalisationService.translate('TitleClickToEdit'),
inputTitle: LocalisationService.translate('TitleEnterToExit')
};
},
computed: {
label() {
if(['label', 'url', 'username', 'password'].indexOf(this.field) !== -1) {
return LocalisationService.translate(`Label${this.field.capitalize()}`);
}
return this.field;
},
text() {
return this.field === 'password' ? '':this.value;
},
classList() {
return `mining-property ${this.field}`;
},
id() {
return `property${this.field}`;
}
},
methods: {
edit() {
this.editing = true;
},
checkEnter($event) {
if($event.key === 'Enter') {
$event.preventDefault();
this.editing = false;
this.item.setResultField(this.field, this.value);
MessageService
.send({type: 'popup.mining.update', payload: this.item});
}
}
},
watch : {
value(value) {
this.item.setResultField(this.field, value);
}
}
};
</script>
<style lang="scss">
.mining-property {
padding : .5rem;
label {
cursor : pointer;
display : block;
font-weight : bold;
color : var(--element-active-fg-color)
}
div {
cursor : pointer;
padding : .25rem;
box-sizing : border-box;
border-radius : 3px;
border : none;
line-height : 2rem;
white-space : nowrap;
text-overflow : ellipsis;
overflow : hidden;
box-shadow : 0 0 0 1px transparent;
transition : box-shadow .15s ease-in-out;
&:hover {
box-shadow : 0 0 0 1px var(--element-hover-bg-color);
}
}
input {
width : 100%;
padding : .25rem;
box-sizing : border-box;
box-shadow : 0 0 0 1px var(--element-active-fg-color);
border-radius : 3px;
border : none;
line-height : 2rem;
}
&.password {
div {
font-family : "Font Awesome 5 Free", sans-serif;
font-size : .5rem;
letter-spacing : .25rem;
font-weight : bold;
}
}
}
</style>
|