mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
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:
@@ -20,6 +20,7 @@
|
|||||||
{{ $t('challengeDetails') }}
|
{{ $t('challengeDetails') }}
|
||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
|
v-if="canCreateChallenges"
|
||||||
class="btn btn-secondary"
|
class="btn btn-secondary"
|
||||||
@click="createChallenge()"
|
@click="createChallenge()"
|
||||||
>
|
>
|
||||||
@@ -36,6 +37,7 @@
|
|||||||
/>
|
/>
|
||||||
<div class="col-12 text-center">
|
<div class="col-12 text-center">
|
||||||
<button
|
<button
|
||||||
|
v-if="canCreateChallenges"
|
||||||
class="btn btn-secondary"
|
class="btn btn-secondary"
|
||||||
@click="createChallenge()"
|
@click="createChallenge()"
|
||||||
>
|
>
|
||||||
@@ -86,7 +88,7 @@ export default {
|
|||||||
directives: {
|
directives: {
|
||||||
markdown: markdownDirective,
|
markdown: markdownDirective,
|
||||||
},
|
},
|
||||||
props: ['groupId'],
|
props: ['group'],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
challenges: [],
|
challenges: [],
|
||||||
@@ -98,6 +100,12 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({ user: 'user.data' }),
|
...mapState({ user: 'user.data' }),
|
||||||
|
canCreateChallenges () {
|
||||||
|
if (this.group.leaderOnly.challenges) {
|
||||||
|
return this.group.leader._id === this.user._id;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
async groupId () {
|
async groupId () {
|
||||||
@@ -109,8 +117,8 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async loadChallenges () {
|
async loadChallenges () {
|
||||||
this.groupIdForChallenges = this.groupId;
|
this.groupIdForChallenges = this.group._id;
|
||||||
if (this.groupId === 'party' && this.user.party._id) this.groupIdForChallenges = this.user.party._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 });
|
this.challenges = await this.$store.dispatch('challenges:getGroupChallenges', { groupId: this.groupIdForChallenges });
|
||||||
},
|
},
|
||||||
createChallenge () {
|
createChallenge () {
|
||||||
|
|||||||
@@ -176,7 +176,7 @@
|
|||||||
:title="$t('challenges')"
|
:title="$t('challenges')"
|
||||||
:tooltip="$t('challengeDetails')"
|
:tooltip="$t('challengeDetails')"
|
||||||
>
|
>
|
||||||
<group-challenges :group-id="searchId" />
|
<group-challenges :group="group" />
|
||||||
</sidebar-section>
|
</sidebar-section>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
|
|||||||
Reference in New Issue
Block a user