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">
|
2021-06-24 01:24:57 +02:00
|
|
|
<x-button type="secondary" class="is-small" @click="() => setRepeatAfter(1, 'days')">{{ $t('task.repeat.everyDay') }}</x-button>
|
|
|
|
<x-button type="secondary" class="is-small" @click="() => setRepeatAfter(1, 'weeks')">{{ $t('task.repeat.everyWeek') }}</x-button>
|
|
|
|
<x-button type="secondary" class="is-small" @click="() => setRepeatAfter(1, 'months')">{{ $t('task.repeat.everyMonth') }}</x-button>
|
2021-01-16 21:09:11 +01:00
|
|
|
</div>
|
2021-04-14 10:24:07 +02:00
|
|
|
<div class="is-flex is-align-items-center mb-2">
|
|
|
|
<label for="repeatMode" class="is-fullwidth">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('task.repeat.mode') }}:
|
2021-04-14 10:24:07 +02:00
|
|
|
</label>
|
|
|
|
<div class="control">
|
|
|
|
<div class="select">
|
|
|
|
<select @change="updateData" v-model="task.repeatMode" id="repeatMode">
|
2021-06-24 01:24:57 +02:00
|
|
|
<option :value="repeatModes.REPEAT_MODE_DEFAULT">{{ $t('misc.default') }}</option>
|
|
|
|
<option :value="repeatModes.REPEAT_MODE_MONTH">{{ $t('task.repeat.monthly') }}</option>
|
|
|
|
<option :value="repeatModes.REPEAT_MODE_FROM_CURRENT_DATE">{{ $t('task.repeat.fromCurrentDate') }}</option>
|
2021-04-14 10:24:07 +02:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="is-flex" v-if="task.repeatMode !== repeatModes.REPEAT_MODE_MONTH">
|
|
|
|
<p class="pr-4">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('task.repeat.each') }}
|
2021-04-14 10:24:07 +02:00
|
|
|
</p>
|
|
|
|
<div class="field has-addons is-fullwidth">
|
|
|
|
<div class="control">
|
|
|
|
<input
|
2021-08-20 17:00:03 +02:00
|
|
|
:disabled="disabled || null"
|
2021-04-14 10:24:07 +02:00
|
|
|
@change="updateData"
|
|
|
|
class="input"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('task.repeat.specifyAmount')"
|
2021-04-14 10:24:07 +02:00
|
|
|
v-model="repeatAfter.amount"
|
|
|
|
type="number"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="control">
|
|
|
|
<div class="select">
|
2021-08-20 17:00:03 +02:00
|
|
|
<select :disabled="disabled || null" @change="updateData" v-model="repeatAfter.type">
|
2021-06-24 01:24:57 +02:00
|
|
|
<option value="hours">{{ $t('task.repeat.hours') }}</option>
|
|
|
|
<option value="days">{{ $t('task.repeat.days') }}</option>
|
|
|
|
<option value="weeks">{{ $t('task.repeat.weeks') }}</option>
|
|
|
|
<option value="months">{{ $t('task.repeat.months') }}</option>
|
|
|
|
<option value="years">{{ $t('task.repeat.years') }}</option>
|
2021-04-14 10:24:07 +02:00
|
|
|
</select>
|
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>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-09-10 16:21:33 +02:00
|
|
|
import repeatModes from '@/models/constants/taskRepeatModes'
|
2020-06-14 14:43:01 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
name: 'repeatAfter',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
task: {},
|
|
|
|
repeatAfter: {
|
|
|
|
amount: 0,
|
|
|
|
type: '',
|
2020-08-11 20:18:59 +02:00
|
|
|
},
|
2021-09-10 16:21:33 +02:00
|
|
|
repeatModes,
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
props: {
|
2021-08-23 21:18:12 +02:00
|
|
|
modelValue: {
|
2021-04-14 10:24:07 +02:00
|
|
|
default: () => {},
|
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
|
|
|
},
|
2021-08-23 21:18:12 +02:00
|
|
|
emits: ['update:modelValue', 'change'],
|
2020-09-05 22:35:52 +02:00
|
|
|
watch: {
|
2021-08-23 21:18:12 +02:00
|
|
|
modelValue: {
|
2021-09-08 11:59:38 +02:00
|
|
|
handler(value) {
|
|
|
|
this.task = value
|
|
|
|
if (typeof value.repeatAfter !== 'undefined') {
|
|
|
|
this.repeatAfter = value.repeatAfter
|
|
|
|
}
|
|
|
|
},
|
|
|
|
immediate: true,
|
2019-11-24 14:16:24 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
updateData() {
|
2021-08-15 11:25:06 +02:00
|
|
|
if (this.task.repeatMode !== repeatModes.REPEAT_MODE_DEFAULT && this.repeatAfter.amount === 0) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
this.task.repeatAfter = this.repeatAfter
|
2021-08-23 21:18:12 +02:00
|
|
|
this.$emit('update:modelValue', this.task)
|
2020-09-05 22:35:52 +02:00
|
|
|
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;
|
|
|
|
}
|
2019-11-24 14:16:24 +01:00
|
|
|
</style>
|