Make sure we don't submit the event form twice

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-10-01 18:25:57 +02:00
parent 06f5f525dd
commit 75b3a52077
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -267,13 +267,18 @@
</span> </span>
<!-- If an event has been published we can't make it draft anymore --> <!-- If an event has been published we can't make it draft anymore -->
<span class="navbar-item" v-if="event.draft === true"> <span class="navbar-item" v-if="event.draft === true">
<b-button type="is-primary" outlined @click="createOrUpdateDraft">{{ <b-button
$t("Save draft") type="is-primary"
}}</b-button> outlined
@click="createOrUpdateDraft"
:disabled="saving"
>{{ $t("Save draft") }}</b-button
>
</span> </span>
<span class="navbar-item"> <span class="navbar-item">
<b-button <b-button
type="is-primary" type="is-primary"
:disabled="saving"
@click="createOrUpdatePublish" @click="createOrUpdatePublish"
@keyup.enter="createOrUpdatePublish" @keyup.enter="createOrUpdatePublish"
> >
@ -457,6 +462,8 @@ export default class EditEvent extends Vue {
endsOnNull = false; endsOnNull = false;
saving = false;
displayNameAndUsername = displayNameAndUsername; displayNameAndUsername = displayNameAndUsername;
formatList = formatList; formatList = formatList;
@ -517,6 +524,7 @@ export default class EditEvent extends Vue {
} }
createOrUpdatePublish(e: Event): void { createOrUpdatePublish(e: Event): void {
e.preventDefault();
if (this.validateForm()) { if (this.validateForm()) {
this.event.draft = false; this.event.draft = false;
this.createOrUpdateDraft(e); this.createOrUpdateDraft(e);
@ -552,6 +560,7 @@ export default class EditEvent extends Vue {
} }
async createEvent(): Promise<void> { async createEvent(): Promise<void> {
this.saving = true;
const variables = await this.buildVariables(); const variables = await this.buildVariables();
try { try {
@ -575,11 +584,13 @@ export default class EditEvent extends Vue {
params: { uuid: data.createEvent.uuid }, params: { uuid: data.createEvent.uuid },
}); });
} catch (err) { } catch (err) {
this.saving = false;
console.error(err); console.error(err);
} }
} }
async updateEvent(): Promise<void> { async updateEvent(): Promise<void> {
this.saving = true;
const variables = await this.buildVariables(); const variables = await this.buildVariables();
try { try {
@ -601,6 +612,7 @@ export default class EditEvent extends Vue {
params: { uuid: this.eventId as string }, params: { uuid: this.eventId as string },
}); });
} catch (err) { } catch (err) {
this.saving = false;
console.error(err); console.error(err);
} }
} }