2017-08-26 02:56:21 +00:00
|
|
|
<template lang="pug">
|
|
|
|
|
b-modal#challenge-member-modal(title="User Progress", size='lg')
|
2018-07-14 02:58:28 +00:00
|
|
|
.row.award-row
|
|
|
|
|
.col-12.text-center
|
|
|
|
|
button.btn.btn-primary(v-once, @click='closeChallenge()') {{ $t('awardWinners') }}
|
2017-08-26 02:56:21 +00:00
|
|
|
.row
|
|
|
|
|
task-column.col-6(
|
|
|
|
|
v-for="column in columns",
|
|
|
|
|
:type="column",
|
|
|
|
|
:key="column",
|
|
|
|
|
:taskListOverride='tasksByType[column]')
|
|
|
|
|
</template>
|
|
|
|
|
|
2018-07-14 02:58:28 +00:00
|
|
|
<style scoped>
|
|
|
|
|
.award-row {
|
|
|
|
|
padding-top: 1rem;
|
|
|
|
|
padding-bottom: 1rem;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
2017-08-26 02:56:21 +00:00
|
|
|
<script>
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
import Column from '../tasks/column';
|
|
|
|
|
|
|
|
|
|
export default {
|
2018-07-14 02:58:28 +00:00
|
|
|
props: ['challengeId'],
|
2017-08-26 02:56:21 +00:00
|
|
|
components: {
|
|
|
|
|
TaskColumn: Column,
|
|
|
|
|
},
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
columns: ['habit', 'daily', 'todo', 'reward'],
|
|
|
|
|
tasksByType: {
|
|
|
|
|
habit: [],
|
|
|
|
|
daily: [],
|
|
|
|
|
todo: [],
|
|
|
|
|
reward: [],
|
|
|
|
|
},
|
2018-07-14 02:58:28 +00:00
|
|
|
memberId: '',
|
2017-08-26 02:56:21 +00:00
|
|
|
};
|
|
|
|
|
},
|
2018-07-14 02:58:28 +00:00
|
|
|
mounted () {
|
|
|
|
|
this.$root.$on('habitica:challenge:member-progress', (data) => {
|
|
|
|
|
if (!data.progressMemberId) return;
|
|
|
|
|
this.memberId = data.progressMemberId;
|
|
|
|
|
this.$root.$emit('bv::show::modal', 'challenge-member-modal');
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
beforeDestroy () {
|
|
|
|
|
this.$root.$off('habitica:challenge:member-progress');
|
|
|
|
|
},
|
2017-08-26 02:56:21 +00:00
|
|
|
watch: {
|
|
|
|
|
async memberId (id) {
|
|
|
|
|
if (!id) return;
|
2017-09-22 21:47:16 +00:00
|
|
|
this.tasksByType = {
|
|
|
|
|
habit: [],
|
|
|
|
|
daily: [],
|
|
|
|
|
todo: [],
|
|
|
|
|
reward: [],
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-21 19:25:27 +00:00
|
|
|
let response = await axios.get(`/api/v4/challenges/${this.challengeId}/members/${this.memberId}`);
|
2017-08-26 02:56:21 +00:00
|
|
|
let tasks = response.data.data.tasks;
|
|
|
|
|
tasks.forEach((task) => {
|
|
|
|
|
this.tasksByType[task.type].push(task);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
2018-07-14 02:58:28 +00:00
|
|
|
methods: {
|
|
|
|
|
async closeChallenge () {
|
|
|
|
|
this.challenge = await this.$store.dispatch('challenges:selectChallengeWinner', {
|
|
|
|
|
challengeId: this.challengeId,
|
|
|
|
|
winnerId: this.memberId,
|
|
|
|
|
});
|
|
|
|
|
this.$router.push('/challenges/myChallenges');
|
|
|
|
|
},
|
|
|
|
|
},
|
2017-08-26 02:56:21 +00:00
|
|
|
};
|
|
|
|
|
</script>
|