-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathRepeatItem.vue
227 lines (206 loc) · 5 KB
/
RepeatItem.vue
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!--
Nextcloud - Tasks
@author Sunik Kupfer
@copyright 2023 Sunik Kupfer <mail@sunik.de>
@author Raimund Schlüßler
@copyright 2018 Raimund Schlüßler <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
License as published by the Free Software Foundation; either
version 3 of the License, or any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU AFFERO GENERAL PUBLIC LICENSE for more details.
You should have received a copy of the GNU Affero General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
-->
<template>
<div v-click-outside="() => setValue()"
:class="{
'property__item--clearable': isRecurring && !readOnly,
'property__item--readonly': readOnly
}"
class="property__item">
<div class="item__content" @click="setEditing(true)">
<div class="content__icon">
<component :is="icon" :size="20" />
</div>
<span v-show="!editing" class="content__name">
<RepeatSummary class="property-repeat__summary__content"
:recurrence-rule="value" />
</span>
<div v-if="editing" class="content__input">
<RepeatFreqInterval v-if="!readOnly && !disabled"
v-model:frequency="frequency"
v-model:interval="interval"
@change-frequency="changeFrequency"
@change-interval="changeInterval" />
</div>
</div>
<div class="item__actions">
<NcActions v-show="editing" class="actions__set">
<NcActionButton @click="setValue()">
<template #icon>
<Check :size="20" />
</template>
{{ t('tasks', 'Set value') }}
</NcActionButton>
</NcActions>
<NcActions v-show="editing" class="actions__clear">
<NcActionButton @click="clearValue">
<template #icon>
<Delete :size="20" />
</template>
{{ t('tasks', 'Delete value') }}
</NcActionButton>
</NcActions>
</div>
</div>
</template>
<script>
import { translate as t } from '@nextcloud/l10n'
import RepeatSummary from './RepeatItem/RepeatSummary.vue'
import RepeatFreqInterval from './RepeatItem/RepeatFreqInterval.vue'
import Pencil from 'vue-material-design-icons/Pencil.vue'
import Check from 'vue-material-design-icons/Check.vue'
import { NcActions as Actions, NcActionButton as ActionButton } from '@nextcloud/vue'
import editableItem from '../../mixins/editableItem.js'
import logger from '../../utils/logger.js'
export default {
name: 'RepeatItem',
components: {
RepeatSummary,
RepeatFreqInterval,
Actions,
ActionButton,
Pencil,
Check,
},
mixins: [editableItem],
props: {
/**
* The Recurrence object
*/
value: {
type: Object,
required: true,
},
disabled: {
type: Boolean,
default: false,
},
readOnly: {
type: Boolean,
required: true,
},
placeholder: {
type: String,
default: '',
},
icon: {
type: String,
default: null,
},
},
data() {
return {
frequency: this.value.frequency,
interval: this.value.interval,
}
},
methods: {
t,
isRecurring() {
return this.value.frequency !== 'NONE'
},
changeFrequency(value) {
this.frequency = value
// TODO: There should be a better way than using structuredClone
this.newValue = structuredClone(this.value)
this.newValue.frequency = value
},
changeInterval(value) {
logger.info('change Interval to ' + value)
this.interval = value
this.newValue = structuredClone(this.value)
this.newValue.interval = value
},
},
}
</script>
<style lang="scss" scoped>
.property__item {
border-bottom: 1px solid var(--color-border);
padding: 0;
position: relative;
margin-bottom: 0;
width: 100%;
color: var(--color-text-lighter);
display: flex;
& * {
cursor: pointer;
}
.item {
&__content {
display: flex;
line-height: 44px;
min-width: 0;
flex-grow: 1;
.content {
&__icon {
display: flex;
height: 44px;
width: 44px;
min-width: 44px;
justify-content: center;
.material-design-icon__svg {
vertical-align: middle;
}
}
&__name {
font-weight: bold;
flex-grow: 1;
padding-right: 14px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
&__input {
display: flex;
flex-grow: 1;
flex-wrap: wrap;
align-content: center;
input[type='number'] {
width: 50px;
flex-basis: 50px;
flex-shrink: 0;
background: none repeat scroll 0 0 var(--color-background-dark);
margin: 0;
min-height: 0;
}
input[type='range'] {
flex-grow: 1;
flex-shrink: 1;
min-width: 100px;
flex-basis: 100px;
border: medium none;
box-shadow: none;
margin-left: 5px;
}
}
}
}
&__actions {
display: flex;
flex-wrap: nowrap;
}
}
&--readonly * {
cursor: default;
}
&--clearable:hover .actions__clear {
display: inline-block !important;
}
}
</style>