diff --git a/backend/src/graphql/posts.js b/backend/src/graphql/posts.js index f1b62a286..7d57b8510 100644 --- a/backend/src/graphql/posts.js +++ b/backend/src/graphql/posts.js @@ -38,8 +38,10 @@ export const createPostMutation = () => { id } eventStart + eventEnd eventLocationName eventVenue + eventIsOnline eventLocation { lng lat diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index a6ce30c2e..d84ace942 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -31,30 +31,29 @@
- {{ datePickerStart }}, {{ formData.eventStart }} + {{ formData.eventStart }}
- + /> -->
- - + +
@@ -72,11 +71,11 @@
- +
- - {{ formData.eventLocation.length }}/{{ formSchema.eventLocation.max }} - + + {{ formData.eventLocationName.length }}/{{ formSchema.eventLocationName.max }} +
@@ -95,8 +94,8 @@
Online Event @@ -201,13 +200,6 @@ export default { }, }, - // input _EventInput { - // eventStart: String! - // eventEnd: String! - // eventLocation: String - // eventVenue: String ort - // } - data() { const { title, @@ -216,10 +208,10 @@ export default { categories, eventStart, eventEnd, - eventLocation, + eventLocationName, eventVenue, - eventOnline, - datePickerStart, + eventIsOnline, + eventLocation, } = this.contribution const { sensitive: imageBlurred = false, @@ -231,7 +223,6 @@ export default { categoriesActive: this.$env.CATEGORIES_ACTIVE, links, hours: Array.from({ length: 10 }).map((_, i) => i + 8), - datePickerStart: null, formData: { title: title || '', content: content || '', @@ -240,12 +231,12 @@ export default { imageType, imageBlurred, categoryIds: categories ? categories.map((category) => category.id) : [], - eventStart: null, - eventEnd: null, - eventLocation: '', - eventVenue: '', - eventOnline: true, - datePickerStart: null, + eventStart: eventStart || null, + eventEnd: eventEnd || null, + eventLocation: eventLocation || { lng: 51.0, lat: 17.0}, + eventLocationName: eventLocationName || '', + eventVenue: eventVenue || '', + eventIsOnline: eventIsOnline || true, }, formSchema: { title: { required: true, min: 3, max: 100 }, @@ -261,9 +252,9 @@ export default { return [] }, }, - datePickerStart: { required: true }, - eventVenue: { required: true, min: 3, max: 100 }, - eventLocation: { min: 3, max: 100 }, + eventStart: { required: this.creatEvent ? true : false }, + eventVenue: { required: this.creatEvent ? true : false, min: 3, max: 100 }, + eventLocationName: { required: this.creatEvent ? true : false, min: 3, max: 100 }, }, loading: false, users: [], @@ -278,6 +269,19 @@ export default { ...mapGetters({ currentUser: 'auth/user', }), + eventInput() { + if ( this.creatEvent ) { + return { + eventStart: this.formData.eventStart, + // TODO: eventEnd: this.formData.eventEnd, + // TODO: eventLocationName: this.formData.eventLocationName, + eventVenue: this.formData.eventVenue, + // TODO: eventIsOnline: this.formData.eventIsOnline, + eventLocation: JSON.stringify(this.formData.eventLocation) + } + } + return undefined + }, contentLength() { return this.$filters.removeHtml(this.formData.content).length }, @@ -295,15 +299,7 @@ export default { }, }, methods: { - xxx() { - console.log('xxx') - this.formData.datePickerStart = this.datePickerStart - }, submit() { - if (creatEvent) { - alert('EVENT speichern') - return - } let image = null const { title, content, categoryIds } = this.formData @@ -318,6 +314,8 @@ export default { } } this.loading = true + alert(JSON.stringify(this.eventInput)) + this.$apollo .mutate({ mutation: this.contribution.id ? PostMutations().UpdatePost : PostMutations().CreatePost, @@ -328,11 +326,12 @@ export default { id: this.contribution.id || null, image, groupId: this.groupId, - postType: 'Article', - eventInput: '$eventInput', + postType: !this.creatEvent ? 'Article' : 'Event', + eventInput: this.eventInput, }, }) .then(({ data }) => { + console.log(data) this.loading = false this.$toast.success(this.$t('contribution.success')) const result = data[this.contribution.id ? 'UpdatePost' : 'CreatePost'] @@ -343,6 +342,7 @@ export default { }) }) .catch((err) => { + console.error(data) this.$toast.error(err.message) this.loading = false }) diff --git a/webapp/graphql/PostMutations.js b/webapp/graphql/PostMutations.js index 8880a93b0..047d8cd39 100644 --- a/webapp/graphql/PostMutations.js +++ b/webapp/graphql/PostMutations.js @@ -4,30 +4,46 @@ export default () => { return { CreatePost: gql` mutation ( - $title: String! - $content: String! - $categoryIds: [ID] - $image: ImageInput - $groupId: ID + $id: ID + $title: String! + $slug: String + $content: String! + $categoryIds: [ID] + $groupId: ID + $postType: PostType + $eventInput: _EventInput + ) { + CreatePost( + id: $id + title: $title + slug: $slug + content: $content + categoryIds: $categoryIds + groupId: $groupId + postType: $postType + eventInput: $eventInput ) { - CreatePost( - title: $title - content: $content - categoryIds: $categoryIds - image: $image - groupId: $groupId - ) { - title - slug - content - contentExcerpt - language - image { - url - sensitive - } + id + slug + title + content + disabled + deleted + postType + author { + name + } + categories { + id + } + eventStart + eventVenue + eventLocation { + lng + lat } } + } `, UpdatePost: gql` mutation (