Disabled challenge button when loading (#9686)

This commit is contained in:
Keith Holliday
2017-12-06 20:16:40 -05:00
committed by GitHub
parent d136162d48
commit 0184d774c2

View File

@@ -57,8 +57,8 @@
You do not have enough gems to create a Tavern challenge You do not have enough gems to create a Tavern challenge
// @TODO if buy gems button is added, add analytics tracking to it // @TODO if buy gems button is added, add analytics tracking to it
// see https://github.com/HabitRPG/habitica/blob/develop/website/views/options/social/challenges.jade#L134 // see https://github.com/HabitRPG/habitica/blob/develop/website/views/options/social/challenges.jade#L134
button.btn.btn-primary(v-once, v-if='creating && !cloning', @click='createChallenge()') {{$t('createChallengeAddTasks')}} button.btn.btn-primary(v-if='creating && !cloning', @click='createChallenge()', :disabled='loading') {{$t('createChallengeAddTasks')}}
button.btn.btn-primary(v-once, v-if='cloning', @click='createChallenge()') {{$t('createChallengeCloneTasks')}} button.btn.btn-primary(v-once, v-if='cloning', @click='createChallenge()', :disabled='loading') {{$t('createChallengeCloneTasks')}}
button.btn.btn-primary(v-once, v-if='!creating && !cloning', @click='updateChallenge()') {{$t('updateChallenge')}} button.btn.btn-primary(v-once, v-if='!creating && !cloning', @click='updateChallenge()') {{$t('updateChallenge')}}
.col-12.text-center .col-12.text-center
p(v-once) {{$t('challengeMinimum')}} p(v-once) {{$t('challengeMinimum')}}
@@ -228,6 +228,7 @@ export default {
showCategorySelect: false, showCategorySelect: false,
categoryOptions, categoryOptions,
categoriesHashByKey, categoriesHashByKey,
loading: false,
groups: [], groups: [],
}; };
}, },
@@ -354,6 +355,7 @@ export default {
this.$store.state.workingChallenge = {}; this.$store.state.workingChallenge = {};
}, },
async createChallenge () { async createChallenge () {
this.loading = true;
// @TODO: improve error handling, add it to updateChallenge, make errors translatable. Suggestion: `<% fieldName %> is required` where possible, where `fieldName` is inserted as the translatable string that's used for the field header. // @TODO: improve error handling, add it to updateChallenge, make errors translatable. Suggestion: `<% fieldName %> is required` where possible, where `fieldName` is inserted as the translatable string that's used for the field header.
let errors = []; let errors = [];
@@ -367,6 +369,7 @@ export default {
if (errors.length > 0) { if (errors.length > 0) {
alert(errors.join('\n')); alert(errors.join('\n'));
this.loading = false;
return; return;
} }