diff --git a/backend/src/schema/resolvers/helpers/events.js b/backend/src/schema/resolvers/helpers/events.js index 41f8b0d74..bb573021f 100644 --- a/backend/src/schema/resolvers/helpers/events.js +++ b/backend/src/schema/resolvers/helpers/events.js @@ -1,29 +1,32 @@ import { UserInputError } from 'apollo-server' export const validateEventParams = (params) => { + let locationName = null if (params.postType && params.postType === 'Event') { const { eventInput } = params validateEventDate(eventInput.eventStart) params.eventStart = eventInput.eventStart - validateEventEnd(eventInput.eventStart, eventInput.eventEnd) - params.eventEnd = eventInput.eventEnd + if (eventInput.eventEnd) { + validateEventEnd(eventInput.eventStart, eventInput.eventEnd) + params.eventEnd = eventInput.eventEnd + } else { + params.eventEnd = null + } if (eventInput.eventLocationName && !eventInput.eventVenue) { throw new UserInputError('Event venue must be present if event location is given!') } params.eventVenue = eventInput.eventVenue - params.eventLocationName = eventInput.eventLocationName + params.eventLocationName = eventInput.eventLocationName && eventInput.eventLocationName.trim() + if (params.eventLocationName) { + locationName = params.eventLocationName + } else { + params.eventLocationName = null + } params.eventIsOnline = !!eventInput.eventIsOnline } delete params.eventInput - let locationName - if (params.eventLocationName.trim()) { - locationName = params.eventLocationName - } else { - params.eventLocationName = null - locationName = null - } return locationName } @@ -38,7 +41,6 @@ const validateEventDate = (dateString) => { } const validateEventEnd = (start, end) => { - if (end === null) return const endDate = new Date(end) if (endDate.toString() === 'Invalid Date') throw new UserInputError('Event end date must be a valid date!') diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index b1b9b3935..6db9f7e02 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -307,6 +307,7 @@ export default { min: 3, max: 100, validator: (_, value = '') => { + if (this.formData.eventIsOnline) return [] if (!value.trim()) { return [new Error(this.$t('common.validations.eventLocationNameNotEmpty'))] } @@ -329,7 +330,7 @@ export default { eventVenue: this.formData.eventVenue, eventEnd: this.formData.eventEnd, eventIsOnline: this.formData.eventIsOnline, - eventLocationName: this.formData.eventLocationName, + eventLocationName: !this.formData.eventIsOnline ? this.formData.eventLocationName : null, } } return undefined diff --git a/webapp/locales/de.json b/webapp/locales/de.json index 5acab107e..1ce7d2f61 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -115,9 +115,9 @@ "validations": { "categories": "es müssen eine bis drei Themen ausgewählt werden", "email": "muss eine gültige E-Mail-Adresse sein", - "eventLocationNameLength": "Mindestens {min} Maximal {max}", + "eventLocationNameLength": "Minimum {min}, Maximum {max} Zeichen", "eventLocationNameNotEmpty": "es dürfen nicht nur Freizeichen eingetragen werden", - "eventVenueLength": "Mindestens {min} Maximal {max}", + "eventVenueLength": "Minimum {min}, Maximum {max} Zeichen", "eventVenueNotEmpty": "es dürfen nicht nur Freizeichen eingetragen werden", "url": "muss eine gültige URL sein" }, diff --git a/webapp/locales/en.json b/webapp/locales/en.json index 565f4b80a..f25cc8575 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -115,9 +115,9 @@ "validations": { "categories": "at least one and at most three topics must be selected", "email": "must be a valid e-mail address", - "eventLocationNameLength": "minimal {min} maximal {max}", + "eventLocationNameLength": "minimum {min} or maximum {max} characters", "eventLocationNameNotEmpty": "only empty characters are not allowed", - "eventVenueLength": "minimal {min} maximal {max}", + "eventVenueLength": "minimum {min} or maximum {max} characters", "eventVenueNotEmpty": "only empty characters are not allowed", "url": "must be a valid URL" },