fix: Front end validation on switch.

Add a watcher on limitedPlaces and set to default values options related to occupancy when toogle to false.
Increase min places to 1 instead of 0.

See issue: #307
This commit is contained in:
Leo Mouyna 2019-12-10 22:40:33 +01:00 committed by Thomas Citharel
parent 60e95a6e36
commit d333bb08f1
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -92,7 +92,7 @@
<div class="box" v-if="limitedPlaces"> <div class="box" v-if="limitedPlaces">
<b-field :label="$t('Number of places')"> <b-field :label="$t('Number of places')">
<b-numberinput controls-position="compact" min="0" v-model="event.options.maximumAttendeeCapacity" /> <b-numberinput controls-position="compact" min="1" v-model="event.options.maximumAttendeeCapacity" />
</b-field> </b-field>
<!-- <!--
<b-field> <b-field>
@ -344,7 +344,7 @@ export default class EditEvent extends Vue {
this.unmodifiedEvent = JSON.parse(JSON.stringify(this.event.toEditJSON())); this.unmodifiedEvent = JSON.parse(JSON.stringify(this.event.toEditJSON()));
this.pictureFile = await buildFileFromIPicture(this.event.picture); this.pictureFile = await buildFileFromIPicture(this.event.picture);
this.limitedPlaces = this.event.options.maximumAttendeeCapacity !== 0; this.limitedPlaces = this.event.options.maximumAttendeeCapacity > 0;
} }
} }
@ -574,6 +574,15 @@ export default class EditEvent extends Vue {
return new EventModel(result.data.event); return new EventModel(result.data.event);
} }
@Watch('limitedPlaces')
updatedEventCapacityOptions(limitedPlaces: boolean) {
if (! limitedPlaces) {
this.event.options.maximumAttendeeCapacity = 0
this.event.options.remainingAttendeeCapacity = 0
this.event.options.showRemainingAttendeeCapacity = false
}
}
@Watch('needsApproval') @Watch('needsApproval')
updateEventJoinOptions(needsApproval) { updateEventJoinOptions(needsApproval) {
if (needsApproval === true) { if (needsApproval === true) {