mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
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>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<report-challenge-modal />
|
||||
<challenge-modal @updatedChallenge="updatedChallenge" />
|
||||
<leave-challenge-modal
|
||||
:challenge-id="challenge._id"
|
||||
@@ -9,11 +10,27 @@
|
||||
:members="members"
|
||||
:challenge-id="challenge._id"
|
||||
:prize="challenge.prize"
|
||||
:flag-count="challenge.flagCount"
|
||||
/>
|
||||
<challenge-member-progress-modal :challenge-id="challenge._id" />
|
||||
<div class="col-12 col-md-8 standard-page">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6">
|
||||
<div
|
||||
v-if="canViewFlags"
|
||||
class="flagged"
|
||||
>
|
||||
<div
|
||||
v-if="flaggedNotHidden"
|
||||
>
|
||||
{{ $t("flaggedNotHidden") }}
|
||||
</div>
|
||||
<div
|
||||
v-else-if="flaggedAndHidden"
|
||||
>
|
||||
{{ $t("flaggedAndHidden") }}
|
||||
</div>
|
||||
</div>
|
||||
<h1 v-markdown="challenge.name"></h1>
|
||||
<div>
|
||||
<span class="mr-1 ml-0 d-block">
|
||||
@@ -41,7 +58,7 @@
|
||||
createdBy string (helps with RTL languages)-->
|
||||
<!-- @TODO: Implement in V2 strong.margin-left
|
||||
(v-once).svg-icon.calendar-icon(v-html="icons.calendarIcon")
|
||||
| {{$t('endDate')}}
|
||||
{{$t('endDate')}}
|
||||
// "endDate": "End Date: <% endDate %>",-->
|
||||
<!-- span {{challenge.endDate}}-->
|
||||
</div>
|
||||
@@ -169,13 +186,16 @@
|
||||
v-if="isLeader || isAdmin"
|
||||
class="button-container"
|
||||
>
|
||||
<button
|
||||
v-once
|
||||
class="btn btn-primary"
|
||||
@click="cloneChallenge()"
|
||||
>
|
||||
{{ $t('clone') }}
|
||||
</button>
|
||||
<div>
|
||||
<button
|
||||
class="btn"
|
||||
:disabled="flaggedAndHidden"
|
||||
:class="flaggedAndHidden ? 'disabled btn-disabled' : 'btn-primary'"
|
||||
@click="cloneChallenge()"
|
||||
>
|
||||
{{ $t('clone') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="isLeader || isAdmin"
|
||||
@@ -201,6 +221,17 @@
|
||||
{{ $t('endChallenge') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
class="button-container"
|
||||
>
|
||||
<button
|
||||
v-once
|
||||
class="btn btn-danger"
|
||||
@click="reportChallenge()"
|
||||
>
|
||||
{{ $t('report') }}
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<sidebar-section :title="$t('challengeSummary')">
|
||||
<p v-markdown="challenge.summary"></p>
|
||||
@@ -249,6 +280,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
.btn-disabled {
|
||||
background-color: $gray-700;
|
||||
color: $gray-50;
|
||||
box-shadow: none;
|
||||
cursor: arrow;
|
||||
|
||||
&:hover {
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
.calendar-icon {
|
||||
width: 12px;
|
||||
display: inline-block;
|
||||
@@ -312,6 +354,15 @@
|
||||
margin-right: .5em;
|
||||
}
|
||||
}
|
||||
|
||||
.flagged {
|
||||
margin-left: 0em;
|
||||
color: $red-10;
|
||||
|
||||
span {
|
||||
margin-left: 0em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
@@ -332,6 +383,7 @@ import challengeModal from './challengeModal';
|
||||
import challengeMemberProgressModal from './challengeMemberProgressModal';
|
||||
import challengeMemberSearchMixin from '@/mixins/challengeMemberSearch';
|
||||
import leaveChallengeModal from './leaveChallengeModal';
|
||||
import reportChallengeModal from './reportChallengeModal';
|
||||
import sidebarSection from '../sidebarSection';
|
||||
import userLink from '../userLink';
|
||||
import groupLink from '../groupLink';
|
||||
@@ -350,6 +402,7 @@ export default {
|
||||
components: {
|
||||
closeChallengeModal,
|
||||
leaveChallengeModal,
|
||||
reportChallengeModal,
|
||||
challengeModal,
|
||||
challengeMemberProgressModal,
|
||||
memberSearchDropdown,
|
||||
@@ -401,6 +454,20 @@ export default {
|
||||
canJoin () {
|
||||
return !this.isMember;
|
||||
},
|
||||
// canViewFlags should allow only moderators/admins to see flags
|
||||
canViewFlags () {
|
||||
const isModerator = this.hasPermission(this.user, 'moderator');
|
||||
if (isModerator && this.challenge.flagCount > 0) return true;
|
||||
return false;
|
||||
},
|
||||
// flaggedNotHidden should allow mods/admins & challenge owner to see flags
|
||||
flaggedNotHidden () {
|
||||
return this.challenge.flagCount === 1;
|
||||
},
|
||||
// flaggedAndHidden should only allow admin to see challenge & flags
|
||||
flaggedAndHidden () {
|
||||
return this.challenge.flagCount > 1;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
'challenge.name': {
|
||||
@@ -589,6 +656,14 @@ export default {
|
||||
challenge: this.challenge,
|
||||
});
|
||||
},
|
||||
reportChallenge () {
|
||||
this.$root.$emit('habitica::report-challenge', {
|
||||
challenge: this.challenge,
|
||||
});
|
||||
},
|
||||
async showCannotCloneModal () {
|
||||
this.$root.$emit('bv::show::modal', 'cannot-clone-modal');
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user