From 41af877ab5f1b5ba178b445782b351467d9055f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Sun, 25 Sep 2022 12:54:07 +0200 Subject: [PATCH] Refine functionality, second step --- webapp/components/Group/GroupForm.vue | 200 +++++++++++++++++--------- webapp/pages/group/create.vue | 1 + 2 files changed, 133 insertions(+), 68 deletions(-) diff --git a/webapp/components/Group/GroupForm.vue b/webapp/components/Group/GroupForm.vue index 978740358..d804c5d08 100644 --- a/webapp/components/Group/GroupForm.vue +++ b/webapp/components/Group/GroupForm.vue @@ -14,7 +14,6 @@ v-model="formData.name" :placeholder="`${$t('group.name')} …`" > - - - + + + + + {{ $t('group.type') }} + + + + - - + + + + {{ $t('group.actionRadius') }} + + + + this.requestGeoData(value), 500) - }, - processLocationsResult(places) { - if (!places.length) { - return [] - } - const result = [] - places.forEach((place) => { - result.push({ - label: place.place_name, - value: place.place_name, - id: place.id, - }) - }) - - return result - }, - async requestGeoData(e) { - const value = e.target ? e.target.value.trim() : '' - if (value === '') { - this.cities = [] - return - } - this.loadingGeo = true - - const place = encodeURIComponent(value) - const lang = this.$i18n.locale() - - const { - data: { queryLocations: res }, - } = await this.$apollo.query({ query: queryLocations(), variables: { place, lang } }) - - this.cities = this.processLocationsResult(res) - this.loadingGeo = false - }, - }, computed: { submitDisable() { if ( @@ -259,5 +244,84 @@ export default { return true }, }, + methods: { + submit() { + const { name, about, description, groupType, actionRadius, locationName, categoryIds } = + this.formData + const variables = { + name, + about, + description, + groupType, + actionRadius, + locationName: locationName.label, + categoryIds, + } + this.update + ? this.$emit('updateGroup', { + ...variables, + id: this.group.id, + }) + : this.$emit('createGroup', variables) + }, + changeGroupType(event) { + this.formData.groupType = event.target.value + }, + changeActionRadius(event) { + this.formData.actionRadius = event.target.value + }, + handleCityInput(value) { + clearTimeout(timeout) + timeout = setTimeout(() => this.requestGeoData(value), 500) + }, + processLocationsResult(places) { + if (!places.length) { + return [] + } + const result = [] + places.forEach((place) => { + result.push({ + label: place.place_name, + value: place.place_name, + id: place.id, + }) + }) + + return result + }, + async requestGeoData(e) { + const value = e.target ? e.target.value.trim() : '' + if (value === '') { + this.cities = [] + return + } + this.loadingGeo = true + + const place = encodeURIComponent(value) + const lang = this.$i18n.locale() + + const { + data: { queryLocations: res }, + } = await this.$apollo.query({ query: queryLocations(), variables: { place, lang } }) + + this.cities = this.processLocationsResult(res) + this.loadingGeo = false + }, + }, } + + diff --git a/webapp/pages/group/create.vue b/webapp/pages/group/create.vue index d0516713f..8c7113b50 100644 --- a/webapp/pages/group/create.vue +++ b/webapp/pages/group/create.vue @@ -54,6 +54,7 @@ export default { this.$toast.success(this.$t('group.groupCreated')) this.$router.history.push('/my-groups') // Wolle: refetch groups on '/my-groups' + // seems to work of its own now, because of implementation of vue apollo queries in '/my-groups' } catch (error) { this.$toast.error(error.message) }