diff --git a/components/admin/Settings.vue b/components/admin/Settings.vue index e80ba08d..7bf7f548 100644 --- a/components/admin/Settings.vue +++ b/components/admin/Settings.vue @@ -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 } diff --git a/pages/add/_edit.vue b/pages/add/_edit.vue index 74a3cae9..a10a0de4 100644 --- a/pages/add/_edit.vue +++ b/pages/add/_edit.vue @@ -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' }) diff --git a/server/api/controller/event.js b/server/api/controller/event.js index 55d2a845..be3163f7 100644 --- a/server/api/controller/event.js +++ b/server/api/controller/event.js @@ -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)