Files
habitica/website/client/src/components/challenges/closeChallengeModal.vue
Natalie 581271e930 Reporting challenges (#14756)
* initial commit

* update logic to display flagged challenges properly to users and admins

* add report button to pages 'My Challenges' and 'Discover Challenges'

* allow mods to view flagged messages on challengeDetail view

* update showing flagged challenges for group challenges

* update showing flagged challenges for a specific challenge

* disallow closing a flagged challenge

* update notes to reflect apiParams properly

* fix css spacing

* update challenge en locales

* fix spacing

* update title of closeChallengeModal

* let user know flagged challenges cannot be cloned

* fix linting errors

* ensure flagged challenges cannot be declared with a winner and cloned via API

* define a non user challenge properly

* fix logic to check for a nonParticipant and nonLeader user when grabbing flagged challenges

* fix linting of max character of 100 / line

* remove reporting on 'my challenges' and 'discover challenges'

* WIP(challenges): disable clone button and add notes to new functions

* WIP(challenges): smol changes

* WIP(challenges): clone button only disabled for admin and flagged user; other users can still clone but the flag goes along with the clone

* WIP(challenges): stop flags carrying over on cloned challenges

* WIP(challenges): typo fixing, undoing a smol change

* fix(challenges): improved query logic for flags

* WIP(challenges): more smol changes

* fix(challenges): refactor queries

* fix(challenges): correct My Challenges tab logic

* WIP(challenges): fix clone button state

* WIP(challenges): really fixed clone button & clear flags from clones

* WIP(challenge): implement new design for reporting modal

* WIP(challenge): making things pretty

* WIP(challenge): conquering the close button

* WIP(challenge): fixin some spacing

* WIP(challenge): smol fix

* WIP(challenge): making sure the button is actually disabled

* WIP(challenge): fix blockquote css

* fix(tests): no private guilds

* fix(lint): curlies etc

* fix(test): moderator permission

* fix(lint): sure man whatever

* fix(lint): bad vim no tabby

* fix(test): permissions not contrib lol

* fix(challenges): add icon and fix leaky CSS

* fix(challenge): correct clone button behavior

---------

Co-authored-by: Julius Jung <me@matchajune.io>
Co-authored-by: SabreCat <sabe@habitica.com>
Co-authored-by: Sabe Jones <sabrecat@gmail.com>
2023-10-24 09:24:56 -05:00

176 lines
4.0 KiB
Vue

<template>
<div>
<b-modal
id="close-challenge-modal"
:title="$t('endChallenge')"
size="md"
>
<div
slot="modal-header"
class="header-wrap"
>
<h2
v-once
class="text-center"
>
{{ $t('endChallenge') }}
</h2>
</div>
<div class="row text-center">
<span
v-if="isFlagged"
class="col-12"
>
<div>{{ $t('cannotClose') }}</div>
</span>
<span
v-else
class="col-12"
>
<div class="col-12">
<div class="support-habitica">
<!-- @TODO: Add challenge achievement badge here-->
</div>
</div>
<div class="col-12">
<strong v-once>{{ $t('selectChallengeWinnersDescription') }}</strong>
</div>
<div class="col-12">
<member-search-dropdown
:text="winnerText"
:members="members"
:challenge-id="challengeId"
@member-selected="selectMember"
/>
</div>
<div class="col-12">
<button
v-once
class="btn btn-primary"
@click="closeChallenge"
>
{{ $t('awardWinners') }}
</button>
</div>
</span>
<div class="col-12">
<hr>
<div class="or">
{{ $t('or') }}
</div>
</div>
<div class="col-12">
<strong v-once>{{ $t('doYouWantedToDeleteChallenge') }}</strong>
</div>
<div class="col-12">
<button
v-once
class="btn btn-danger"
@click="deleteChallenge()"
>
{{ $t('deleteChallenge') }}
</button>
</div>
</div>
<div
slot="modal-footer"
class="footer-wrap"
></div>
</b-modal>
</div>
</template>
<style lang='scss'>
@import '~@/assets/scss/colors.scss';
#close-challenge-modal {
h2 {
color: $purple-200
}
#close-challenge-modal_modal_body {
padding-bottom: 2em;
}
.header-wrap {
width: 100%;
padding-top: 2em;
}
.support-habitica {
background-image: url('~@/assets/svg/for-css/support-habitica-gems.svg');
width: 325px;
height: 89px;
margin: 0 auto;
}
.modal-footer, .modal-header {
border: none !important;
}
.footer-wrap {
display: none;
}
.col-12 {
margin-top: 2em;
}
.or {
margin-top: -2em;
background: $white;
width: 40px;
margin-right: auto;
margin-left: auto;
font-weight: bold;
}
}
</style>
<script>
import memberSearchDropdown from '@/components/members/memberSearchDropdown';
export default {
components: {
memberSearchDropdown,
},
props: ['challengeId', 'members', 'prize', 'flagCount'],
data () {
return {
winner: {},
};
},
computed: {
winnerText () {
if (!this.winner.profile) return this.$t('selectMember');
return this.winner.profile.name;
},
isFlagged () {
return this.flagCount > 0;
},
},
methods: {
selectMember (member) {
this.winner = member;
},
async closeChallenge () {
this.challenge = await this.$store.dispatch('challenges:selectChallengeWinner', {
challengeId: this.challengeId,
winnerId: this.winner._id,
});
this.$root.$emit('bv::hide::modal', 'close-challenge-modal');
this.$router.push('/challenges/myChallenges');
},
async deleteChallenge () {
if (!window.confirm(this.$t('sureDelCha'))) return; // eslint-disable-line no-alert
this.challenge = await this.$store.dispatch('challenges:deleteChallenge', {
challengeId: this.challengeId,
prize: this.prize,
});
this.$root.$emit('bv::hide::modal', 'close-challenge-modal');
this.$router.push('/challenges/myChallenges');
},
},
};
</script>