mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
add summary field to challenges and guilds (#8960)
* create new summary field for challenges * finish implementating summary for challenges, add some support for guilds * make small improvements to challenges code * fix lint errors * add more code to support summaries for guilds (still more needed) * fix existing tests by adding summary field * make existing tests pass * WIP make "Public Challenges" text translatable * change "leader" locale key to "guildOrPartyLeader" to make searches for it easier * remove v-once from h2 headings * remove failed attempt to localise text in <script> * add quick-and-dirty error checking for guild not having categories * make "Public Challenges" text translatable * rename final ...PlaceHolder strings to ...Placeholder (lower-case "h") for consistency with existing Placeholder strings
This commit is contained in:
@@ -4,17 +4,16 @@
|
||||
.form-group
|
||||
label
|
||||
strong(v-once) {{$t('name')}} *
|
||||
b-form-input(type="text", :placeholder="$t('newGuildPlaceHolder')", v-model="workingGuild.name")
|
||||
|
||||
b-form-input(type="text", :placeholder="$t('newGuildPlaceholder')", v-model="workingGuild.name")
|
||||
.form-group(v-if='workingGuild.id && members.length > 0')
|
||||
label
|
||||
strong(v-once) {{$t('leader')}} *
|
||||
strong(v-once) {{$t('guildOrPartyLeader')}} *
|
||||
select.form-control(v-model="workingGuild.newLeader")
|
||||
option(v-for='member in members', :value="member._id") {{ member.profile.name }}
|
||||
|
||||
.form-group
|
||||
label
|
||||
strong(v-once) {{$t('privacySettings')}}*
|
||||
strong(v-once) {{$t('privacySettings')}} *
|
||||
br
|
||||
label.custom-control.custom-checkbox
|
||||
input.custom-control-input(type="checkbox", v-model="workingGuild.onlyLeaderCreatesChallenges")
|
||||
@@ -43,16 +42,18 @@
|
||||
span.custom-control-indicator
|
||||
span.custom-control-description(v-once) {{ $t('allowGuildInvationsFromNonMembers') }}
|
||||
|
||||
.form-group
|
||||
label
|
||||
strong(v-once) {{$t('description')}} *
|
||||
div.description-count {{charactersRemaining}} {{ $t('charactersRemaining') }}
|
||||
textarea.form-control(:placeholder="isParty ? $t('partyDescriptionPlaceHolder') : $t('guildDescriptionPlaceHolder')", v-model="workingGuild.description")
|
||||
|
||||
.form-group(v-if='!creatingParty')
|
||||
label
|
||||
strong(v-once) {{$t('guildInformation')}} *
|
||||
textarea.form-control(:placeholder="isParty ? $t('partyInformationPlaceHolder'): $t('guildInformationPlaceHolder')", v-model="workingGuild.guildInformation")
|
||||
strong(v-once) {{$t('guildSummary')}} *
|
||||
div.summary-count {{charactersRemaining}} {{ $t('charactersRemaining') }}
|
||||
textarea.form-control.summary-textarea(:placeholder="$t('guildSummaryPlaceholder')", v-model="workingGuild.summary")
|
||||
// @TODO: need summary only for PUBLIC GUILDS, not for tavern, private guilds, or party
|
||||
|
||||
.form-group
|
||||
label
|
||||
strong(v-once) {{$t('groupDescription')}} *
|
||||
a.float-right {{ $t('markdownFormattingHelp') }}
|
||||
b-form-input.description-textarea(type="text", textarea, :placeholder="creatingParty ? $t('partyDescriptionPlaceholder') : $t('guildDescriptionPlaceholder')", v-model="workingGuild.description")
|
||||
|
||||
.form-group(v-if='creatingParty && !workingGuild.id')
|
||||
span
|
||||
@@ -60,7 +61,7 @@
|
||||
|
||||
.form-group(style='position: relative;', v-if='!creatingParty && !isParty')
|
||||
label
|
||||
strong(v-once) {{$t('categories')}}*
|
||||
strong(v-once) {{$t('categories')}} *
|
||||
div.category-wrap(@click.prevent="toggleCategorySelect")
|
||||
span.category-select(v-if='workingGuild.categories.length === 0') {{$t('none')}}
|
||||
.category-label(v-for='category in workingGuild.categories') {{$t(categoriesHashByKey[category])}}
|
||||
@@ -74,11 +75,12 @@
|
||||
span.custom-control-indicator
|
||||
span.custom-control-description(v-once) {{ $t(group.label) }}
|
||||
button.btn.btn-primary(@click.prevent="toggleCategorySelect") {{$t('close')}}
|
||||
// @TODO: need categories only for PUBLIC GUILDS, not for tavern, private guilds, or party
|
||||
|
||||
.form-group(v-if='inviteMembers && !workingGuild.id')
|
||||
label
|
||||
strong(v-once) Invite via Email or User ID
|
||||
p Invite users via a valid email or 36-digit User ID. If an email isn’t registered yet, we’ll invite them to join.
|
||||
p(v-once) {{$t('inviteMembersHowTo')}} *
|
||||
|
||||
div
|
||||
div(v-for='(member, index) in membersToInvite')
|
||||
@@ -108,19 +110,27 @@
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
.description-count, .gem-description {
|
||||
.summary-count, .gem-description {
|
||||
font-size: 12px;
|
||||
line-height: 1.33;
|
||||
text-align: center;
|
||||
margin-top: 1em;
|
||||
color: $gray-200;
|
||||
}
|
||||
|
||||
.description-count {
|
||||
.summary-count {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.gem-description {
|
||||
margin-top: 1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.summary-textarea {
|
||||
height: 90px;
|
||||
}
|
||||
|
||||
.description-textarea {
|
||||
height: 220px;
|
||||
}
|
||||
|
||||
.item-with-icon {
|
||||
@@ -139,10 +149,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.description-count {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.icon {
|
||||
margin-left: .5em;
|
||||
display: inline-block;
|
||||
@@ -161,6 +167,8 @@ import toggleSwitch from 'client/components/ui/toggleSwitch';
|
||||
import gemIcon from 'assets/svg/gem.svg';
|
||||
import informationIcon from 'assets/svg/information.svg';
|
||||
|
||||
import { MAX_SUMMARY_SIZE_FOR_GUILDS } from '../../../common/script/constants';
|
||||
|
||||
// @TODO: Not sure the best way to pass party creating status
|
||||
// Since we need the modal in the header, passing props doesn't work
|
||||
// because we can't import the create group in the index of groups
|
||||
@@ -184,8 +192,8 @@ export default {
|
||||
name: '',
|
||||
type: 'guild',
|
||||
privacy: 'private',
|
||||
summary: '',
|
||||
description: '',
|
||||
guildInformation: '',
|
||||
categories: [],
|
||||
onlyLeaderCreatesChallenges: true,
|
||||
guildLeaderCantBeMessaged: true,
|
||||
@@ -282,9 +290,8 @@ export default {
|
||||
this.workingGuild.name = editingGroup.name;
|
||||
this.workingGuild.type = editingGroup.type;
|
||||
this.workingGuild.privacy = editingGroup.privacy;
|
||||
if (editingGroup.description) this.workingGuild.description = editingGroup.description;
|
||||
if (editingGroup.information) this.workingGuild.information = editingGroup.information;
|
||||
if (editingGroup.summary) this.workingGuild.summary = editingGroup.summary;
|
||||
if (editingGroup.description) this.workingGuild.description = editingGroup.description;
|
||||
if (editingGroup._id) this.workingGuild.id = editingGroup._id;
|
||||
if (editingGroup.leader._id) this.workingGuild.newLeader = editingGroup.leader._id;
|
||||
if (editingGroup._id) this.getMembers();
|
||||
@@ -292,7 +299,8 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
charactersRemaining () {
|
||||
return 500 - this.workingGuild.description.length;
|
||||
let currentLength = this.workingGuild.summary ? this.workingGuild.summary.length : 0;
|
||||
return MAX_SUMMARY_SIZE_FOR_GUILDS - currentLength;
|
||||
},
|
||||
title () {
|
||||
if (this.creatingParty) return this.$t('createParty');
|
||||
@@ -339,14 +347,26 @@ export default {
|
||||
}
|
||||
|
||||
if (!this.workingGuild.name || !this.workingGuild.description) {
|
||||
// @TODO: Add proper notifications
|
||||
// @TODO: Add proper notifications - split this out into two, make errors translatable. Suggestion: `<% fieldName %> is required` for all errors where possible, where `fieldName` is inserted as the translatable string that's used for the field header.
|
||||
alert('Enter a name and description');
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.workingGuild.description.length > 500) {
|
||||
if (!this.workingGuild.summary) {
|
||||
// @TODO: Add proper notifications. Summary is mandatory for only public guilds (not tavern, private guilds, parties)
|
||||
alert('Enter a summary');
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.workingGuild.summary.length > MAX_SUMMARY_SIZE_FOR_GUILDS) {
|
||||
// @TODO: Add proper notifications. Summary is mandatory for only public guilds (not tavern, private guilds, parties)
|
||||
alert('Summary is too long');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.workingGuild.categories || this.workingGuild.categories.length === 0) {
|
||||
// @TODO: Add proper notifications
|
||||
alert('Description is too long');
|
||||
alert('One or more categories must be selected');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user