minor with 2w recurrent event frequency

This commit is contained in:
lesion
2023-03-20 12:40:19 +01:00
parent 8f221fb69c
commit b8e096ee39
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 Geolocation from './Geolocation.vue'
import { mapActions, mapState } from 'vuex' import { mapActions, mapState } from 'vuex'
import { DateTime } from 'luxon' import { DateTime } from 'luxon'
import tzNames from './tz.json'
import { mdiAlert, mdiArrowRight, mdiMap } from '@mdi/js' import { mdiAlert, mdiArrowRight, mdiMap } from '@mdi/js'
const locales = require('../../locales/index') const locales = require('../../locales/index')
@@ -128,6 +127,7 @@ export default {
}, },
filteredTimezones () { filteredTimezones () {
const current_timezone = DateTime.local().zoneName const current_timezone = DateTime.local().zoneName
const tzNames = Intl.supportedValuesOf('timeZone')
tzNames.unshift(current_timezone) tzNames.unshift(current_timezone)
return tzNames 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)) } if (this.event.tags) { this.event.tags.forEach(tag => formData.append('tags[]', tag.tag || tag)) }
try { try {
if (this.edit) { const ret = this.edit ? await this.$axios.$put('/event', formData) : await this.$axios.$post('/event', formData)
const ret = await this.$axios.$put('/event', formData) if (!this.date.recurrent) {
this.$router.push(`/event/${ret.slug}`) this.$router.push(`/event/${ret.slug}`)
} else { } else {
const ret = await this.$axios.$post('/event', formData) this.$router.push('/')
this.$router.push(`/event/${ret.slug}`)
} }
this.$nextTick(() => { this.$nextTick(() => {
this.$root.$message(this.$auth.loggedIn ? (this.edit ? 'event.saved' : 'event.added') : 'event.added_anon', { color: 'success' }) 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 * 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}"`) log.debug(`Create recurrent event [${e.id}] ${e.title}"`)
const event = { const event = {
parentId: e.id, parentId: e.id,
@@ -684,7 +684,6 @@ const eventController = {
const type = recurrent.type const type = recurrent.type
cursor = cursor.hour(start_date.hour()).minute(start_date.minute()).second(0) cursor = cursor.hour(start_date.hour()).minute(start_date.minute()).second(0)
if (!frequency) { return } if (!frequency) { return }
// each week or 2 // each week or 2
@@ -693,7 +692,7 @@ const eventController = {
if (cursor.isBefore(startAt)) { if (cursor.isBefore(startAt)) {
cursor = cursor.add(7, 'day') cursor = cursor.add(7, 'day')
} }
if (frequency[0] === '2') { if (frequency[0] === '2' && !firstOccurrence) {
cursor = cursor.add(7, 'day') cursor = cursor.add(7, 'day')
} }
} else if (frequency === '1m') { } else if (frequency === '1m') {
@@ -741,9 +740,9 @@ const eventController = {
const creations = events.map(e => { const creations = events.map(e => {
if (e.child.length) { if (e.child.length) {
if (e.child.find(c => c.is_visible)) return 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) return Promise.all(creations)