dayjs / restart with recurrent

This commit is contained in:
les
2020-11-17 00:34:56 +01:00
parent f088c20811
commit a1f7998398
9 changed files with 50 additions and 77 deletions

View File

@@ -1,5 +1,16 @@
<template lang="pug">
v-row
v-btn-toggle.col-md-4(@change='changeType' color='primary' :value='value.type')
v-btn(value='normal') {{$t('event.normal')}}
v-btn(value='multidate') {{$t('event.multidate')}}
v-menu(v-if='settings.allow_recurrent_event' offset-y open-on-hover)
template(v-slot:activator="{ on, attrs }")
v-btn(value='recurrent' v-on='on') {{$t('event.recurrent')}}
v-list
v-list-item(v-for='f in frequencies' :key='f.value'
@click='selectFrequency(f.value)') {{f.text}}
v-menu(
v-model="datePickerMenu"
:close-on-content-click="false"
@@ -19,21 +30,11 @@ v-row
v-on="on")
v-date-picker(
:min='today'
v-model="value.date"
:value="value.date"
:range="value.type === 'multidate'"
:locale='settings.locale'
@input="pick")
v-btn-toggle.col-md-4(@change='changeType' color='primary' :value='value.type')
v-btn(value='normal') {{$t('event.normal')}}
v-btn(value='multidate') {{$t('event.multidate')}}
v-menu(v-if='settings.allow_recurrent_event' offset-y open-on-hover)
template(v-slot:activator="{ on, attrs }")
v-btn(value='recurrent' v-on='on') {{$t('event.recurrent')}}
v-list
v-list-item(v-for='f in frequencies' :key='f.value'
@click='selectFrequency(f.value)') {{f.text}}
p.col-12 {{$t(`event.${value.type}_description`)}}
//- v-btn-toggle(v-if="type === 'recurrent'" v-model='value.recurrent.frequency' color='primary')
//- v-btn(v-for='f in frequencies' :value='f.value') {{f.text}}
@@ -59,7 +60,6 @@ v-row
</template>
<script>
// import VInput from 'vuetify/es5/components/VInput'
import dayjs from 'dayjs'
import { mapState } from 'vuex'
import List from '@/components/List'
@@ -223,10 +223,11 @@ export default {
selectFrequency (f) {
this.$emit('input', { recurrent: { frequency: f }, date: null, type: 'recurrent' })
},
pick (value) {
pick (date) {
if (this.value.type === 'normal' || this.value.type === 'recurrent' || this.value.date.length === 2) {
this.datePickerMenu = false
}
this.$emit('input', { date, type: this.value.type, recurrent: this.value.recurrent })
}
}
}

View File

@@ -180,25 +180,19 @@ export default {
const formData = new FormData()
if (this.date.type === 'multidate') {
console.error('sono in multidate!')
start_datetime = dayjs(this.date.date[0])
.set('hour', start_hour).set('minute', start_minute)
.hour(start_hour).minute(start_minute)
end_datetime = dayjs(this.date.date[1])
.set('hour', end_hour).set('minute', end_minute)
.hour(end_hour).minute(end_minute)
} else if (this.date.type === 'normal') {
start_datetime = dayjs(this.date.date).set('hour', start_hour).set('minute', start_minute)
end_datetime = dayjs(this.date.date).set('hour', end_hour).set('minute', end_minute)
start_datetime = dayjs(this.date.date).hour(start_hour).minute(start_minute)
end_datetime = dayjs(this.date.date).hour(end_hour).minute(end_minute)
if (end_hour < start_hour) {
end_datetime = end_datetime.add(1, 'day')
}
} else if (this.date.type === 'recurrent') {
start_datetime = dayjs().set('hour', start_hour).set('minute', start_minute)
end_datetime = dayjs().set('hour', end_hour).set('minute', end_minute)
// const recurrent = {
// frequency: this.event.recurrent.frequency,
// days: this.event.recurrent.type === 'ordinal' ? _.map(this.date, d => dayjs(d).date()) : _.map(this.date, d => dayjs(d).day() + 1),
// type: this.event.recurrent.type
// }
start_datetime = dayjs(this.date.date).set('hour', start_hour).set('minute', start_minute)
end_datetime = dayjs(this.date.date).set('hour', end_hour).set('minute', end_minute)
if (end_hour < start_hour) {
end_datetime = end_datetime.add(1, 'day')
}