fix: online_locations and hide/show address in edit mode

online_locations are not removed, and fix limit via gui to max 3 urls.
In edit mode if event is online do not show address field with null value
This commit is contained in:
sedum 2024-08-11 00:26:09 +02:00
parent 319d546336
commit 684547cb8b
2 changed files with 13 additions and 14 deletions

View file

@ -56,9 +56,7 @@ v-row.mb-4
v-dialog(v-model='whereInputAdvancedDialog' destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly' dense) v-dialog(v-model='whereInputAdvancedDialog' destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly' dense)
WhereInputAdvanced(ref='whereAdvanced' :place.sync='value' :event='event' WhereInputAdvanced(ref='whereAdvanced' :place.sync='value' :event='event'
@close='whereInputAdvancedDialog = false && this.$refs.address.blur()' @close='whereInputAdvancedDialog = false && this.$refs.address.blur()')
:onlineLocations.sync="onlineLocations"
@update:onlineLocations="selectLocations")
</template> </template>
@ -90,7 +88,7 @@ export default {
computed: { computed: {
...mapState(['settings']), ...mapState(['settings']),
isOnLine () { isOnLine () {
return this.settings.allow_online_event && this.place.name === 'online' return this.settings.allow_online_event && this.value.name === 'online'
}, },
showAdvancedDialogButton () { showAdvancedDialogButton () {
@ -183,17 +181,16 @@ export default {
this.event.online_locations = [] this.event.online_locations = []
if (this.onlineLocations) { if (this.onlineLocations) {
// Insert up to 3 online location: the main one and 2 fallback
if (this.onlineLocations.length > 3) {
this.$nextTick(() => this.onlineLocations = this.onlineLocations.slice(0, 3))
}
// Remove duplicates
this.$nextTick(() => this.onlineLocations = [...new Set(this.onlineLocations)])
this.onlineLocations.forEach((item, i) => { this.onlineLocations.forEach((item, i) => {
if (!item.startsWith('http')) { this.onlineLocations[i] = `https://${item}` } if (!item.startsWith('http')) { item = `https://${item}` }
this.event.online_locations[i] = this.onlineLocations[i] this.onlineLocations[i] = item
}) })
// Remove duplicates
this.onlineLocations = [...new Set(this.onlineLocations)]
// Insert up to 3 online location: the main one and 2 fallback
this.onlineLocations = this.onlineLocations.slice(0, 3)
this.event.online_locations = this.onlineLocations
} }
}, },
} }

View file

@ -244,8 +244,10 @@ export default {
formData.append('place_longitude', this.event.place.longitude || '') formData.append('place_longitude', this.event.place.longitude || '')
} }
if (this.event.online_locations) { if (this.event.online_locations.length) {
this.event.online_locations.forEach(l => formData.append('online_locations[]', l)) this.event.online_locations.forEach(l => formData.append('online_locations[]', l))
} else {
formData.append('online_locations', [])
} }
formData.append('description', this.event.description) formData.append('description', this.event.description)