Client Fixes (#9056)

* remove console.log calls used for debugging

* open member modal when clicking on user name or avatar in chat

* misc fixes to strings, payments, ...

* simplify code

* secure statsComputed
This commit is contained in:
Matteo Pagliazzi
2017-09-21 19:49:27 +02:00
committed by GitHub
parent 7a74d4c296
commit 81fc727d41
6 changed files with 50 additions and 23 deletions

View File

@@ -11,13 +11,20 @@
.hr-middle(v-once) {{ msg.timestamp }} .hr-middle(v-once) {{ msg.timestamp }}
.row(v-if='user._id !== msg.uuid') .row(v-if='user._id !== msg.uuid')
.col-4 .col-4
avatar(v-if='cachedProfileData[msg.uuid]', avatar(
:member="cachedProfileData[msg.uuid]", :avatarOnly="true", v-if='cachedProfileData[msg.uuid]',
:hideClassBadge='true') :member="cachedProfileData[msg.uuid]",
:avatarOnly="true",
:hideClassBadge='true',
@click.native="showMemberModal(msg.uuid)",
)
.card.col-8 .card.col-8
.message-hidden(v-if='msg.flagCount > 0 && user.contributor.admin') Message Hidden .message-hidden(v-if='msg.flagCount > 0 && user.contributor.admin') Message Hidden
.card-block .card-block
h3.leader(:class='userLevelStyle(cachedProfileData[msg.uuid])') h3.leader(
:class='userLevelStyle(cachedProfileData[msg.uuid])'
@click="showMemberModal(msg.uuid)",
)
| {{msg.user}} | {{msg.user}}
.svg-icon(v-html="icons[`tier${cachedProfileData[msg.uuid].contributor.level}`]", v-if='cachedProfileData[msg.uuid] && cachedProfileData[msg.uuid].contributor && cachedProfileData[msg.uuid].contributor.level') .svg-icon(v-html="icons[`tier${cachedProfileData[msg.uuid].contributor.level}`]", v-if='cachedProfileData[msg.uuid] && cachedProfileData[msg.uuid].contributor && cachedProfileData[msg.uuid].contributor.level')
p {{msg.timestamp | timeAgo}} p {{msg.timestamp | timeAgo}}
@@ -39,11 +46,16 @@
span.action.float-right(v-if='likeCount(msg) > 0') span.action.float-right(v-if='likeCount(msg) > 0')
.svg-icon(v-html="icons.liked") .svg-icon(v-html="icons.liked")
| + {{ likeCount(msg) }} | + {{ likeCount(msg) }}
// @TODO can we avoid duplicating all this code? Cannot we just push everything
// to the right if the user is the author?
.row(v-if='user._id === msg.uuid') .row(v-if='user._id === msg.uuid')
.card.col-8 .card.col-8
.message-hidden(v-if='msg.flagCount > 0 && user.contributor.admin') Message Hidden - {{ msg.flagCount }} Flags .message-hidden(v-if='msg.flagCount > 0 && user.contributor.admin') Message Hidden - {{ msg.flagCount }} Flags
.card-block .card-block
h3.leader(:class='userLevelStyle(cachedProfileData[msg.uuid])') h3.leader(
:class='userLevelStyle(cachedProfileData[msg.uuid])',
@click="showMemberModal(msg.uuid)",
)
| {{msg.user}} | {{msg.user}}
.svg-icon(v-html="icons[`tier${cachedProfileData[msg.uuid].contributor.level}`]", v-if='cachedProfileData[msg.uuid] && cachedProfileData[msg.uuid].contributor && cachedProfileData[msg.uuid].contributor.level') .svg-icon(v-html="icons[`tier${cachedProfileData[msg.uuid].contributor.level}`]", v-if='cachedProfileData[msg.uuid] && cachedProfileData[msg.uuid].contributor && cachedProfileData[msg.uuid].contributor.level')
p {{msg.timestamp | timeAgo}} p {{msg.timestamp | timeAgo}}
@@ -66,15 +78,19 @@
.svg-icon(v-html="icons.liked") .svg-icon(v-html="icons.liked")
| + {{ likeCount(msg) }} | + {{ likeCount(msg) }}
.col-4 .col-4
avatar(v-if='cachedProfileData[msg.uuid]', avatar(
:member="cachedProfileData[msg.uuid]", :avatarOnly="true", v-if='cachedProfileData[msg.uuid]',
:hideClassBadge='true') :member="cachedProfileData[msg.uuid]",
:avatarOnly="true",
:hideClassBadge='true',
@click.native="showMemberModal(msg.uuid)",
)
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '~client/assets/scss/colors.scss'; @import '~client/assets/scss/colors.scss';
// @TODO: Move this to an scss? // @TODO: Move this to an scss
.tier1 { .tier1 {
color: #c42870; color: #c42870;
} }
@@ -118,7 +134,9 @@
} }
// End of tier colors // End of tier colors
h3 { h3 { // this is the user name
cursor: pointer;
.svg-icon { .svg-icon {
width: 10px; width: 10px;
display: inline-block; display: inline-block;
@@ -362,6 +380,12 @@ export default {
chatId: message.id, chatId: message.id,
}); });
}, },
showMemberModal (memberId) {
// @TODO move to action or anyway move from here because it's super duplicate
this.$store.state.profileUser = this.cachedProfileData[memberId];
this.$store.state.profileOptions.startingPage = 'profile';
this.$root.$emit('show::modal', 'profile');
},
}, },
}; };
</script> </script>

View File

@@ -10,7 +10,7 @@
h3(v-once) {{ $t('tavernChat') }} h3(v-once) {{ $t('tavernChat') }}
.row .row
textarea(placeholder="Friendly reminder: this is an all-ages chat, so please keep content and language appropriate! Consult the Community Guidelines in the sidebar if you have questions.", v-model='newMessage', @keydown='updateCarretPosition') textarea(:placeholder="$t('tavernCommunityGuidelinesPlaceholder')", v-model='newMessage', @keydown='updateCarretPosition')
autocomplete(:text='newMessage', v-on:select="selectedAutocomplete", :coords='coords', :chat='group.chat') autocomplete(:text='newMessage', v-on:select="selectedAutocomplete", :coords='coords', :chat='group.chat')
button.btn.btn-secondary.send-chat.float-right(v-once, @click='sendMessage()') {{ $t('send') }} button.btn.btn-secondary.send-chat.float-right(v-once, @click='sendMessage()') {{ $t('send') }}
button.btn.btn-secondary.float-left(v-once, @click='fetchRecentMessages()') {{ $t('fetchRecentMessages') }} button.btn.btn-secondary.float-left(v-once, @click='fetchRecentMessages()') {{ $t('fetchRecentMessages') }}
@@ -50,6 +50,7 @@
.toggle-down(@click="sections.staff = !sections.staff", v-if="!sections.staff") .toggle-down(@click="sections.staff = !sections.staff", v-if="!sections.staff")
.svg-icon(v-html="icons.downIcon") .svg-icon(v-html="icons.downIcon")
.section.row(v-if="sections.staff") .section.row(v-if="sections.staff")
// @TODO open member modal when clicking on a staff member
.col-4.staff(v-for='user in staff', :class='{staff: user.type === "Staff", moderator: user.type === "Moderator", bailey: user.name === "It\'s Bailey"}') .col-4.staff(v-for='user in staff', :class='{staff: user.type === "Staff", moderator: user.type === "Moderator", bailey: user.name === "It\'s Bailey"}')
div div
.title {{user.name}} .title {{user.name}}

View File

@@ -83,7 +83,7 @@ import planGemLimits from '../../../common/script/libs/planGemLimits';
import paymentsMixin from 'client/mixins/payments'; import paymentsMixin from 'client/mixins/payments';
import notificationsMixin from 'client/mixins/notifications'; import notificationsMixin from 'client/mixins/notifications';
// @TODO: EMAILS.TECH_ASSISTANCE_EMAIL // @TODO: EMAILS.TECH_ASSISTANCE_EMAIL, load from config
const TECH_ASSISTANCE_EMAIL = 'admin@habitica.com'; const TECH_ASSISTANCE_EMAIL = 'admin@habitica.com';
export default { export default {
@@ -104,6 +104,7 @@ export default {
subscription: {key: ''}, subscription: {key: ''},
message: '', message: '',
}, },
amazonPayments: {},
assistanceEmailObject: { assistanceEmailObject: {
hrefTechAssistanceEmail: `<a href="mailto:${TECH_ASSISTANCE_EMAIL}">${TECH_ASSISTANCE_EMAIL}</a>`, hrefTechAssistanceEmail: `<a href="mailto:${TECH_ASSISTANCE_EMAIL}">${TECH_ASSISTANCE_EMAIL}</a>`,
}, },

View File

@@ -64,7 +64,7 @@ export default {
description: sub ? this.$t('subscribe') : this.$t('checkout'), description: sub ? this.$t('subscribe') : this.$t('checkout'),
// image: '/apple-touch-icon-144-precomposed.png', // image: '/apple-touch-icon-144-precomposed.png',
panelLabel: sub ? this.$t('subscribe') : this.$t('checkout'), panelLabel: sub ? this.$t('subscribe') : this.$t('checkout'),
async token (res) { token: async (res) => {
let url = '/stripe/checkout?a=a'; // just so I can concat &x=x below let url = '/stripe/checkout?a=a'; // just so I can concat &x=x below
if (data.groupToCreate) { if (data.groupToCreate) {
@@ -89,6 +89,7 @@ export default {
let newGroup = response.data.data; let newGroup = response.data.data;
if (newGroup && newGroup._id) { if (newGroup && newGroup._id) {
// @TODO this does not do anything as we reload just below
// @TODO: Just append? or $emit? // @TODO: Just append? or $emit?
this.$router.push(`/group-plans/${newGroup._id}/task-information`); this.$router.push(`/group-plans/${newGroup._id}/task-information`);
// @TODO action // @TODO action

View File

@@ -1,6 +1,6 @@
{ {
"iAcceptCommunityGuidelines": "I agree to abide by the Community Guidelines", "iAcceptCommunityGuidelines": "I agree to abide by the Community Guidelines",
"tavernCommunityGuidelinesPlaceholder": "Friendly reminder: this is an all-ages chat, so please keep content and language appropriate! Consult the Community Guidelines below if you have questions.", "tavernCommunityGuidelinesPlaceholder": "Friendly reminder: this is an all-ages chat, so please keep content and language appropriate! Consult the Community Guidelines in the sidebar if you have questions.",
"commGuideHeadingWelcome": "Welcome to Habitica!", "commGuideHeadingWelcome": "Welcome to Habitica!",
"commGuidePara001": "Greetings, adventurer! Welcome to Habitica, the land of productivity, healthy living, and the occasional rampaging gryphon. We have a cheerful community full of helpful people supporting each other on their way to self-improvement.", "commGuidePara001": "Greetings, adventurer! Welcome to Habitica, the land of productivity, healthy living, and the occasional rampaging gryphon. We have a cheerful community full of helpful people supporting each other on their way to self-improvement.",
"commGuidePara002": "To help keep everyone safe, happy, and productive in the community, we have some guidelines. We have carefully crafted them to make them as friendly and easy-to-read as possible. Please take the time to read them.", "commGuidePara002": "To help keep everyone safe, happy, and productive in the community, we have some guidelines. We have carefully crafted them to make them as friendly and easy-to-read as possible. Please take the time to read them.",

View File

@@ -15,16 +15,16 @@ function equipmentStatBonusComputed (stat, user) {
let equipped = user.items.gear.equipped; let equipped = user.items.gear.equipped;
let equippedKeys = values(!equipped.toObject ? equipped : equipped.toObject()); let equippedKeys = values(!equipped.toObject ? equipped : equipped.toObject());
/* eslint-disable no-console */
console.log(equippedKeys);
each(equippedKeys, (equippedItem) => { each(equippedKeys, (equippedItem) => {
console.log(equippedItem, gear[equippedItem]); let item = gear[equippedItem];
/* eslint-enable no-console */
let equipmentStat = gear[equippedItem][stat]; if (item) {
let classBonusMultiplier = gear[equippedItem].klass === user.stats.class || let equipmentStat = item[stat];
gear[equippedItem].specialClass === user.stats.class ? 0.5 : 0; let classBonusMultiplier = item.klass === user.stats.class ||
gearBonus += equipmentStat; item.specialClass === user.stats.class ? 0.5 : 0;
classBonus += equipmentStat * classBonusMultiplier; gearBonus += equipmentStat;
classBonus += equipmentStat * classBonusMultiplier;
}
}); });
return { return {