Fixes #12966 pass the group to groupChallenges so the leader only check can be used to display the create challenge button (#13221)

Co-authored-by: SpeedyLom <speedylomuk@gmail.com>
This commit is contained in:
Sabe Jones
2021-04-29 15:08:53 -05:00
committed by GitHub
parent 1d3cf368a1
commit 5479c76f08
2 changed files with 12 additions and 4 deletions

View File

@@ -20,6 +20,7 @@
{{ $t('challengeDetails') }}
</p>
<button
v-if="canCreateChallenges"
class="btn btn-secondary"
@click="createChallenge()"
>
@@ -36,6 +37,7 @@
/>
<div class="col-12 text-center">
<button
v-if="canCreateChallenges"
class="btn btn-secondary"
@click="createChallenge()"
>
@@ -86,7 +88,7 @@ export default {
directives: {
markdown: markdownDirective,
},
props: ['groupId'],
props: ['group'],
data () {
return {
challenges: [],
@@ -98,6 +100,12 @@ export default {
},
computed: {
...mapState({ user: 'user.data' }),
canCreateChallenges () {
if (this.group.leaderOnly.challenges) {
return this.group.leader._id === this.user._id;
}
return true;
},
},
watch: {
async groupId () {
@@ -109,8 +117,8 @@ export default {
},
methods: {
async loadChallenges () {
this.groupIdForChallenges = this.groupId;
if (this.groupId === 'party' && this.user.party._id) this.groupIdForChallenges = this.user.party._id;
this.groupIdForChallenges = this.group._id;
if (this.group._id === 'party' && this.user.party._id) this.groupIdForChallenges = this.user.party._id;
this.challenges = await this.$store.dispatch('challenges:getGroupChallenges', { groupId: this.groupIdForChallenges });
},
createChallenge () {