client lint first pass

This commit is contained in:
Matteo Pagliazzi
2019-10-11 20:35:49 +02:00
parent 07cffe9e16
commit a625e83b53
104 changed files with 1053 additions and 893 deletions
@@ -147,6 +147,7 @@ import notifications from '@/mixins/notifications';
import copyIcon from '@/assets/svg/copy.svg';
export default {
mixins: [notifications],
data () {
return {
icons: Object.freeze({
@@ -189,6 +190,5 @@ export default {
this.text(this.$t('usernameCopied'));
},
},
mixins: [notifications],
};
</script>
@@ -67,7 +67,7 @@ function _mapCategories (guilds) {
guilds.forEach(guild => {
if (!guild.categories) return;
guild.categorySlugs = guild.categories.map(cat => {
if (!cat) return;
if (!cat) return undefined;
return cat.slug;
});
});
@@ -198,7 +198,7 @@ export default {
_mapCategories(guilds);
this.guilds.push(...guilds);
this.lastPageLoaded++;
this.lastPageLoaded += 1;
this.loading = false;
},
createGroup () {
@@ -448,7 +448,8 @@ export default {
const groupId = this.searchId === 'party' ? this.user.party._id : this.searchId;
if (this.hasUnreadMessages(groupId)) {
// Delay by 1sec to make sure it returns after other requests that don't have the notification marked as read
// Delay by 1sec to make sure it returns after
// other requests that don't have the notification marked as read
setTimeout(() => {
this.$store.dispatch('chat:markChatSeen', { groupId });
this.$delete(this.user.newMessages, groupId);
@@ -476,7 +477,7 @@ export default {
}
},
async join () {
if (this.group.cancelledPlan && !confirm(this.$t('aboutToJoinCancelledGroupPlan'))) {
if (this.group.cancelledPlan && !window.confirm(this.$t('aboutToJoinCancelledGroupPlan'))) {
return;
}
await this.$store.dispatch('guilds:join', { groupId: this.group._id, type: 'guild' });
@@ -490,7 +491,7 @@ export default {
});
// @TODO: Get challenges and ask to keep or remove
if (!confirm('Are you sure you want to leave?')) return;
if (!window.confirm('Are you sure you want to leave?')) return;
const keep = true;
this.leave(keep);
},
@@ -362,7 +362,7 @@ export default {
async submit () {
if (this.$store.state.user.data.balance < 1 && !this.workingGroup.id) {
// @TODO: Add proper notifications
alert(this.$t('notEnoughGems'));
window.alert(this.$t('notEnoughGems'));
return;
// @TODO return $rootScope.openModal('buyGems', {track:"Gems > Gems > Create Group"});
}
@@ -376,12 +376,12 @@ export default {
if (!this.isParty && (!this.workingGroup.categories || this.workingGroup.categories.length === 0)) errors.push(this.$t('categoiresRequired'));
if (errors.length > 0) {
alert(errors.join('\n'));
window.alert(errors.join('\n'));
return;
}
// @TODO: Add proper notifications
if (!this.workingGroup.id && !confirm(this.$t('confirmGuild'))) return;
if (!this.workingGroup.id && !window.confirm(this.$t('confirmGuild'))) return;
if (!this.workingGroup.privateGuild) {
this.workingGroup.privacy = 'public';
@@ -330,9 +330,6 @@ export default {
type: 'guild', // Guild or Party @TODO enum this
};
},
mounted () {
this.activePage = this.PAGES.BENEFITS;
},
computed: {
newGroupIsReady () {
return Boolean(this.newGroup.name);
@@ -343,6 +340,9 @@ export default {
// @TODO: can we move this to payment mixin?
...mapState({ user: 'user.data' }),
},
mounted () {
this.activePage = this.PAGES.BENEFITS;
},
methods: {
launchModal () {
this.changePage(this.PAGES.CREATE_GROUP);
@@ -370,12 +370,17 @@ export default {
}
this.paymentMethod = paymentMethod;
if (this.paymentMethod === this.PAYMENTS.STRIPE) {
this.showStripe(paymentData);
} else if (this.paymentMethod === this.PAYMENTS.AMAZON) {
if (this.paymentMethod === this.PAYMENTS.AMAZON) {
paymentData.type = 'subscription';
return paymentData;
}
if (this.paymentMethod === this.PAYMENTS.STRIPE) {
this.showStripe(paymentData);
}
return null;
},
},
};
@@ -103,17 +103,8 @@ import positiveIcon from '@/assets/svg/positive.svg';
const INVITE_DEFAULTS = { text: '', error: null, valid: null };
export default {
computed: {
...mapState({ user: 'user.data' }),
cannotSubmit () {
const filteredInvites = filter(this.invites, invite => invite.text.length > 0 && !invite.valid);
if (filteredInvites.length > 0) return true;
return false;
},
inviter () {
return this.user.profile.name;
},
},
mixins: [notifications],
props: ['group', 'groupType'],
data () {
return {
invites: [clone(INVITE_DEFAULTS), clone(INVITE_DEFAULTS)],
@@ -122,36 +113,61 @@ export default {
}),
};
},
computed: {
...mapState({ user: 'user.data' }),
cannotSubmit () {
const filteredInvites = filter(
this.invites,
invite => invite.text.length > 0 && !invite.valid,
);
if (filteredInvites.length > 0) return true;
return false;
},
inviter () {
return this.user.profile.name;
},
},
methods: {
checkInviteList: debounce(function checkList () {
this.invites = filter(this.invites, (invite, index) => invite.text.length > 0 || index === this.invites.length - 1);
this.invites = filter(
this.invites,
(invite, index) => invite.text.length > 0 || index === this.invites.length - 1,
);
while (this.invites.length < 2) this.invites.push(clone(INVITE_DEFAULTS));
forEach(this.invites, (value, index) => {
if (value.text.length < 1 || isEmail(value.text)) {
return this.fillErrors(index);
}
if (isUUID(value.text)) {
this.$store.dispatch('user:userLookup', { uuid: value.text })
.then(res => this.fillErrors(index, res));
} else {
let searchUsername = value.text;
if (searchUsername[0] === '@') searchUsername = searchUsername.slice(1, searchUsername.length);
this.$store.dispatch('user:userLookup', { username: searchUsername })
return this.$store.dispatch('user:userLookup', { uuid: value.text })
.then(res => this.fillErrors(index, res));
}
let searchUsername = value.text;
if (searchUsername[0] === '@') searchUsername = searchUsername.slice(1, searchUsername.length);
return this.$store.dispatch('user:userLookup', { username: searchUsername })
.then(res => this.fillErrors(index, res));
});
}, 250),
expandInviteList () {
if (this.invites[this.invites.length - 1].text.length > 0) this.invites.push(clone(INVITE_DEFAULTS));
if (this.invites[this.invites.length - 1].text.length > 0) {
this.invites.push(clone(INVITE_DEFAULTS));
}
},
fillErrors (index, res) {
if (!res || res.status === 200) {
this.invites[index].error = null;
if (this.invites[index].text.length < 1) return this.invites[index].valid = null;
return this.invites[index].valid = true;
if (this.invites[index].text.length < 1) {
this.invites[index].valid = null;
return;
}
this.invites[index].valid = true;
return;
}
this.invites[index].error = res.response.data.message;
return this.invites[index].valid = false;
this.invites[index].valid = false;
},
close () {
this.invites = [clone(INVITE_DEFAULTS), clone(INVITE_DEFAULTS)];
@@ -179,14 +195,13 @@ export default {
groupId: this.group._id,
});
const invitesSent = invitationDetails.emails.length + invitationDetails.uuids.length + invitationDetails.usernames.length;
const invitesSent = invitationDetails.emails.length
+ invitationDetails.uuids.length + invitationDetails.usernames.length;
const invitationString = invitesSent > 1 ? 'invitationsSent' : 'invitationSent';
this.text(this.$t(invitationString));
this.close();
},
},
mixins: [notifications],
props: ['group', 'groupType'],
};
</script>
@@ -277,22 +277,6 @@ export default {
userIdToMessage: '',
};
},
mounted () {
this.$root.$on('habitica:show-member-modal', data => {
// @TODO: Remove store
this.$store.state.memberModalOptions.challengeId = data.challengeId;
this.$store.state.memberModalOptions.groupId = data.groupId;
this.$store.state.memberModalOptions.group = data.group;
this.$store.state.memberModalOptions.memberCount = data.memberCount;
this.$store.state.memberModalOptions.viewingMembers = data.viewingMembers;
this.$store.state.memberModalOptions.fetchMoreMembers = data.fetchMoreMembers;
this.$root.$emit('bv::show::modal', 'members-modal');
this.getMembers();
});
},
destroyed () {
this.$root.$off('habitica:show-member-modal');
},
computed: {
...mapState({ user: 'user.data' }),
isLeader () {
@@ -324,7 +308,11 @@ export default {
if (!isEmpty(this.sortOption)) {
// Use the memberlist filtered by searchTerm
sortedMembers = orderBy(sortedMembers, [this.sortOption.value], [this.sortOption.direction]);
sortedMembers = orderBy(
sortedMembers,
[this.sortOption.value],
[this.sortOption.direction],
);
}
return sortedMembers;
@@ -351,6 +339,22 @@ export default {
}
},
},
mounted () {
this.$root.$on('habitica:show-member-modal', data => {
// @TODO: Remove store
this.$store.state.memberModalOptions.challengeId = data.challengeId;
this.$store.state.memberModalOptions.groupId = data.groupId;
this.$store.state.memberModalOptions.group = data.group;
this.$store.state.memberModalOptions.memberCount = data.memberCount;
this.$store.state.memberModalOptions.viewingMembers = data.viewingMembers;
this.$store.state.memberModalOptions.fetchMoreMembers = data.fetchMoreMembers;
this.$root.$emit('bv::show::modal', 'members-modal');
this.getMembers();
});
},
destroyed () {
this.$root.$off('habitica:show-member-modal');
},
methods: {
sendMessage (member) {
this.$root.$emit('habitica::new-inbox-message', {
@@ -423,14 +427,14 @@ export default {
groupId: this.groupId,
memberId,
});
alert(this.$t('managerAdded'));
window.alert(this.$t('managerAdded'));
},
async removeManager (memberId) {
await this.$store.dispatch('guilds:removeManager', {
groupId: this.groupId,
memberId,
});
alert(this.$t('managerRemoved'));
window.alert(this.$t('managerRemoved'));
},
close () {
this.$root.$emit('bv::hide::modal', 'members-modal');
@@ -488,7 +492,7 @@ export default {
groupData.leader = member._id;
await this.$store.dispatch('guilds:update', { group: groupData });
alert(this.$t('leaderChanged'));
window.alert(this.$t('leaderChanged'));
groupData.leader = member;
this.$root.$emit('updatedGroup', groupData);
@@ -101,9 +101,6 @@ export default {
],
};
},
created () {
this.fetchGuilds();
},
computed: {
...mapState({
guilds: 'myGuilds',
@@ -121,6 +118,9 @@ export default {
});
},
},
created () {
this.fetchGuilds();
},
methods: {
updateSearch (eventData) {
this.search = eventData.searchTerm;
@@ -152,15 +152,6 @@ export default {
},
mixins: [groupUtilities],
props: ['guild', 'displayLeave', 'displayGemBank'],
computed: {
...mapState({ user: 'user.data' }),
isOwner () {
return this.guild.leader && this.guild.leader === this.user._id;
},
isMember () {
return this.isMemberOfGroup(this.user, this.guild);
},
},
data () {
return {
MAX_SUMMARY_SIZE_FOR_GUILDS,
@@ -172,6 +163,15 @@ export default {
}),
};
},
computed: {
...mapState({ user: 'user.data' }),
isOwner () {
return this.guild.leader && this.guild.leader === this.user._id;
},
isMember () {
return this.isMemberOfGroup(this.user, this.guild);
},
},
methods: {
showSuggested (guildId) {
const habiticaHelpingGuildId = '5481ccf3-5d2d-48a9-a871-70a7380cee5a';
@@ -181,7 +181,7 @@ export default {
},
async join () {
// @TODO: This needs to be in the notifications where users will now accept invites
if (this.guild.cancelledPlan && !confirm(window.env.t('aboutToJoinCancelledGroupPlan'))) {
if (this.guild.cancelledPlan && !window.confirm(window.env.t('aboutToJoinCancelledGroupPlan'))) {
return;
}
await this.$store.dispatch('guilds:join', { groupId: this.guild._id, type: 'guild' });
@@ -200,7 +200,10 @@ export default {
for (const uuid in this.group.quest.members) {
if (this.group.quest.members[uuid]) count += 1;
}
if (!confirm(this.$t('questConfirm', { questmembers: count, totalmembers: this.group.memberCount }))) return;
if (!window.confirm(this.$t('questConfirm', {
questmembers: count,
totalmembers: this.group.memberCount,
}))) return;
this.questForceStart();
},
async questForceStart () {
@@ -209,7 +212,7 @@ export default {
this.close();
},
async questCancel () {
if (!confirm(this.$t('sureCancel'))) return;
if (!window.confirm(this.$t('sureCancel'))) return;
const quest = await this.$store.dispatch('quests:sendAction', { groupId: this.group._id, action: 'quests/cancel' });
this.group.quest = quest;
this.close();
@@ -271,13 +271,13 @@ export default {
this.$root.$emit('bv::show::modal', 'participant-list');
},
async questAbort () {
if (!confirm(this.$t('sureAbort'))) return;
if (!confirm(this.$t('doubleSureAbort'))) return;
if (!window.confirm(this.$t('sureAbort'))) return;
if (!window.confirm(this.$t('doubleSureAbort'))) return;
const quest = await this.$store.dispatch('quests:sendAction', { groupId: this.group._id, action: 'quests/abort' });
this.group.quest = quest;
},
async questLeave () {
if (!confirm(this.$t('sureLeave'))) return;
if (!window.confirm(this.$t('sureLeave'))) return;
const quest = await this.$store.dispatch('quests:sendAction', { groupId: this.group._id, action: 'quests/leave' });
this.group.quest = quest;
},
@@ -147,6 +147,12 @@ export default {
quests,
};
},
computed: {
...mapState({ user: 'user.data' }),
questData () {
return quests.quests[this.selectedQuest];
},
},
mounted () {
const userQuests = this.user.items.quests;
for (const key in userQuests) {
@@ -161,12 +167,6 @@ export default {
destroyed () {
this.$root.$off('selectQuest', this.selectQuest);
},
computed: {
...mapState({ user: 'user.data' }),
questData () {
return quests.quests[this.selectedQuest];
},
},
methods: {
selectQuest (quest) {
this.selectedQuest = quest.key;