vikunja-frontend/src/components/tasks/partials/repeatAfter.vue

114 lines
2.8 KiB
Vue
Raw Normal View History

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">
<x-button type="secondary" class="is-small" @click="() => setRepeatAfter(1, 'days')">Every Day</x-button>
<x-button type="secondary" class="is-small" @click="() => setRepeatAfter(1, 'weeks')">Every Week</x-button>
<x-button type="secondary" class="is-small" @click="() => setRepeatAfter(1, 'months')">Every Month</x-button>
2021-01-16 21:09:11 +01:00
</div>
<div class="is-flex is-align-items-center mb-2">
<label for="repeatMode" class="is-fullwidth">
Repeat mode:
</label>
<div class="control">
<div class="select">
<select @change="updateData" v-model="task.repeatMode" id="repeatMode">
<option :value="repeatModes.REPEAT_MODE_DEFAULT">Default</option>
<option :value="repeatModes.REPEAT_MODE_MONTH">Monthly</option>
<option :value="repeatModes.REPEAT_MODE_FROM_CURRENT_DATE">From Current Date</option>
</select>
</div>
</div>
</div>
<div class="is-flex" v-if="task.repeatMode !== repeatModes.REPEAT_MODE_MONTH">
<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"
type="number"
/>
</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>
2020-11-28 16:02:38 +01:00
</div>
</div>
2019-11-24 14:16:24 +01:00
</div>
</div>
</div>
</template>
<script>
import repeatModes from '@/models/taskRepeatModes'
export default {
name: 'repeatAfter',
data() {
return {
task: {},
repeatAfter: {
amount: 0,
type: '',
},
repeatModes: repeatModes,
}
},
props: {
value: {
default: () => {},
required: true,
2019-11-24 14:16:24 +01:00
},
disabled: {
default: false,
2019-11-24 14:16:24 +01:00
},
},
watch: {
value(newVal) {
this.task = newVal
if (typeof newVal.repeatAfter !== 'undefined') {
this.repeatAfter = newVal.repeatAfter
}
2019-11-24 14:16:24 +01: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()
},
},
}
2019-11-24 14:16:24 +01:00
</script>
<style lang="scss" scoped>
p {
padding-top: 6px;
}
2021-01-16 21:09:11 +01:00
.input {
min-width: 2rem;
}
2019-11-24 14:16:24 +01:00
</style>