2019-11-24 14:16:24 +01:00
|
|
|
<template>
|
2021-01-16 21:09:11 +01:00
|
|
|
<div class="control repeat-after-input">
|
|
|
|
<div class="buttons has-addons is-centered mt-2">
|
|
|
|
<button class="button is-small" @click="() => setRepeatAfter(1, 'days')">Every Day</button>
|
|
|
|
<button class="button is-small" @click="() => setRepeatAfter(1, 'weeks')">Every Week</button>
|
|
|
|
<button class="button is-small" @click="() => setRepeatAfter(1, 'months')">Every Month</button>
|
|
|
|
</div>
|
|
|
|
<div class="columns is-align-items-center">
|
|
|
|
<div class="is-flex column">
|
|
|
|
<p class="pr-4">
|
|
|
|
Each
|
|
|
|
</p>
|
|
|
|
<div class="field has-addons is-fullwidth">
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
:disabled="disabled"
|
|
|
|
@change="updateData"
|
|
|
|
class="input"
|
|
|
|
placeholder="Specify an amount..."
|
|
|
|
v-model="repeatAfter.amount"/>
|
|
|
|
</div>
|
|
|
|
<div class="control">
|
|
|
|
<div class="select">
|
|
|
|
<select :disabled="disabled" @change="updateData" v-model="repeatAfter.type">
|
|
|
|
<option value="hours">Hours</option>
|
|
|
|
<option value="days">Days</option>
|
|
|
|
<option value="weeks">Weeks</option>
|
|
|
|
<option value="months">Months</option>
|
|
|
|
<option value="years">Years</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
2020-11-28 16:02:38 +01:00
|
|
|
</div>
|
2020-06-14 14:43:01 +02:00
|
|
|
</div>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
2021-01-16 21:09:11 +01:00
|
|
|
<fancycheckbox
|
|
|
|
:disabled="disabled"
|
|
|
|
@change="updateData"
|
|
|
|
class="column"
|
|
|
|
v-model="task.repeatFromCurrentDate"
|
|
|
|
v-tooltip="'When marking the task as done, all dates will be set relative to the current date rather than the date they had before.'"
|
|
|
|
>
|
|
|
|
Repeat from current date
|
|
|
|
</fancycheckbox>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-09-05 22:35:52 +02:00
|
|
|
import Fancycheckbox from '../../input/fancycheckbox'
|
2020-06-14 14:43:01 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
name: 'repeatAfter',
|
|
|
|
components: {Fancycheckbox},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
task: {},
|
|
|
|
repeatAfter: {
|
|
|
|
amount: 0,
|
|
|
|
type: '',
|
2020-08-11 20:18:59 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
default: () => {
|
2020-08-11 20:18:59 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
required: true,
|
2019-11-24 14:16:24 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
disabled: {
|
|
|
|
default: false,
|
2019-11-24 14:16:24 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
value(newVal) {
|
|
|
|
this.task = newVal
|
|
|
|
if (typeof newVal.repeatAfter !== 'undefined') {
|
|
|
|
this.repeatAfter = newVal.repeatAfter
|
2020-06-25 21:08:01 +02:00
|
|
|
}
|
2019-11-24 14:16:24 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.task = this.value
|
|
|
|
if (typeof this.value.repeatAfter !== 'undefined') {
|
|
|
|
this.repeatAfter = this.value.repeatAfter
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
updateData() {
|
|
|
|
this.task.repeatAfter = this.repeatAfter
|
|
|
|
this.$emit('input', this.task)
|
|
|
|
this.$emit('change')
|
2019-11-24 14:16:24 +01:00
|
|
|
},
|
2021-01-16 21:09:11 +01:00
|
|
|
setRepeatAfter(amount, type) {
|
|
|
|
this.repeatAfter.amount = amount
|
|
|
|
this.repeatAfter.type = type
|
|
|
|
this.updateData()
|
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
}
|
2019-11-24 14:16:24 +01:00
|
|
|
</script>
|
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
p {
|
|
|
|
padding-top: 6px;
|
|
|
|
}
|
2020-06-14 14:43:01 +02:00
|
|
|
|
2021-01-16 21:09:11 +01:00
|
|
|
.input {
|
|
|
|
min-width: 2rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.fancycheckbox {
|
|
|
|
padding: 0;
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
2019-11-24 14:16:24 +01:00
|
|
|
</style>
|