minor with 2w recurrent event frequency

This commit is contained in:
lesion 2023-03-20 12:40:19 +01:00
parent 8f221fb69c
commit b8e096ee39
No known key found for this signature in database
GPG key ID: 352918250B012177
3 changed files with 8 additions and 11 deletions

View file

@ -72,7 +72,6 @@ import SMTP from './SMTP.vue'
import Geolocation from './Geolocation.vue'
import { mapActions, mapState } from 'vuex'
import { DateTime } from 'luxon'
import tzNames from './tz.json'
import { mdiAlert, mdiArrowRight, mdiMap } from '@mdi/js'
const locales = require('../../locales/index')
@ -128,6 +127,7 @@ export default {
},
filteredTimezones () {
const current_timezone = DateTime.local().zoneName
const tzNames = Intl.supportedValuesOf('timeZone')
tzNames.unshift(current_timezone)
return tzNames
}

View file

@ -250,13 +250,11 @@ export default {
}
if (this.event.tags) { this.event.tags.forEach(tag => formData.append('tags[]', tag.tag || tag)) }
try {
if (this.edit) {
const ret = await this.$axios.$put('/event', formData)
const ret = this.edit ? await this.$axios.$put('/event', formData) : await this.$axios.$post('/event', formData)
if (!this.date.recurrent) {
this.$router.push(`/event/${ret.slug}`)
} else {
const ret = await this.$axios.$post('/event', formData)
this.$router.push(`/event/${ret.slug}`)
this.$router.push('/')
}
this.$nextTick(() => {
this.$root.$message(this.$auth.loggedIn ? (this.edit ? 'event.saved' : 'event.added') : 'event.added_anon', { color: 'success' })

View file

@ -663,7 +663,7 @@ const eventController = {
/**
* Ensure we have the next instance of a recurrent event
*/
async _createRecurrentOccurrence(e, startAt) {
async _createRecurrentOccurrence(e, startAt, firstOccurrence) {
log.debug(`Create recurrent event [${e.id}] ${e.title}"`)
const event = {
parentId: e.id,
@ -684,7 +684,6 @@ const eventController = {
const type = recurrent.type
cursor = cursor.hour(start_date.hour()).minute(start_date.minute()).second(0)
if (!frequency) { return }
// each week or 2
@ -693,7 +692,7 @@ const eventController = {
if (cursor.isBefore(startAt)) {
cursor = cursor.add(7, 'day')
}
if (frequency[0] === '2') {
if (frequency[0] === '2' && !firstOccurrence) {
cursor = cursor.add(7, 'day')
}
} else if (frequency === '1m') {
@ -741,9 +740,9 @@ const eventController = {
const creations = events.map(e => {
if (e.child.length) {
if (e.child.find(c => c.is_visible)) return
return eventController._createRecurrentOccurrence(e, dayjs.unix(e.child[0].start_datetime + 1))
return eventController._createRecurrentOccurrence(e, dayjs.unix(e.child[0].start_datetime + 1), false)
}
return eventController._createRecurrentOccurrence(e, dayjs())
return eventController._createRecurrentOccurrence(e, dayjs(), true)
})
return Promise.all(creations)