From 84d7df3d42b161ca5052edd64fcdff5d73fc27d3 Mon Sep 17 00:00:00 2001 From: Bart Enkelaar Date: Sun, 14 Mar 2021 09:17:44 +0100 Subject: [PATCH] 13046 - Fix creating challenge after cloning (#13048) --- .../client/src/components/challenges/challengeModal.vue | 7 +++++++ .../client/src/components/challenges/findChallenges.vue | 2 +- .../client/src/components/challenges/groupChallenges.vue | 2 +- website/client/src/components/challenges/myChallenges.vue | 3 +-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/website/client/src/components/challenges/challengeModal.vue b/website/client/src/components/challenges/challengeModal.vue index 5363eb9742..5e9fe2cbf3 100644 --- a/website/client/src/components/challenges/challengeModal.vue +++ b/website/client/src/components/challenges/challengeModal.vue @@ -459,9 +459,16 @@ export default { }; this.$root.$emit('bv::show::modal', 'challenge-modal'); }); + this.$root.$on('habitica:create-challenge', () => { + this.cloning = false; + this.$store.state.challengeOptions.workingChallenge = {}; + this.$root.$emit('bv::show::modal', 'challenge-modal'); + }); }, beforeDestroy () { this.$root.$off('habitica:clone-challenge'); + this.$root.$off('habitica:update-challenge'); + this.$root.$off('habitica:create-challenge'); }, methods: { async shown () { diff --git a/website/client/src/components/challenges/findChallenges.vue b/website/client/src/components/challenges/findChallenges.vue index 620d788122..55b972a169 100644 --- a/website/client/src/components/challenges/findChallenges.vue +++ b/website/client/src/components/challenges/findChallenges.vue @@ -193,7 +193,7 @@ export default { this.loadChallenges(); }, createChallenge () { - this.$root.$emit('bv::show::modal', 'challenge-modal'); + this.$root.$emit('habitica:create-challenge'); }, async loadChallenges () { this.loading = true; diff --git a/website/client/src/components/challenges/groupChallenges.vue b/website/client/src/components/challenges/groupChallenges.vue index e6d14df15c..fe1c08e57c 100644 --- a/website/client/src/components/challenges/groupChallenges.vue +++ b/website/client/src/components/challenges/groupChallenges.vue @@ -114,7 +114,7 @@ export default { this.challenges = await this.$store.dispatch('challenges:getGroupChallenges', { groupId: this.groupIdForChallenges }); }, createChallenge () { - this.$root.$emit('bv::show::modal', 'challenge-modal'); + this.$root.$emit('habitica:create-challenge'); }, challengeCreated (challenge) { if (challenge.group._id !== this.groupIdForChallenges) return; diff --git a/website/client/src/components/challenges/myChallenges.vue b/website/client/src/components/challenges/myChallenges.vue index 34d3e66817..7d02305729 100644 --- a/website/client/src/components/challenges/myChallenges.vue +++ b/website/client/src/components/challenges/myChallenges.vue @@ -236,8 +236,7 @@ export default { this.loadChallenges(); }, createChallenge () { - this.$store.state.challengeOptions.workingChallenge = {}; - this.$root.$emit('bv::show::modal', 'challenge-modal'); + this.$root.$emit('habitica:create-challenge'); }, async loadChallenges () { this.loading = true;