lint common

This commit is contained in:
Matteo Pagliazzi
2019-10-09 20:08:36 +02:00
parent 0c27fb24a5
commit e0e9811ab6
330 changed files with 6885 additions and 7668 deletions
@@ -45,43 +45,40 @@ import approvalModal from './approvalModal';
import sync from '@/mixins/sync';
export default {
mixins: [sync],
props: ['task', 'group'],
components: {
approvalModal,
},
mixins: [sync],
props: ['task', 'group'],
computed: {
...mapState({user: 'user.data'}),
...mapState({ user: 'user.data' }),
userIsAssigned () {
return this.task.group.assignedUsers && this.task.group.assignedUsers.indexOf(this.user._id) !== -1;
},
message () {
let assignedUsers = this.task.group.assignedUsers;
let assignedUsersNames = [];
let assignedUsersLength = assignedUsers.length;
const { assignedUsers } = this.task.group;
const assignedUsersNames = [];
const assignedUsersLength = assignedUsers.length;
// @TODO: Eh, I think we only ever display one user name
if (this.group && this.group.members) {
assignedUsers.forEach(userId => {
let index = findIndex(this.group.members, (member) => {
return member._id === userId;
});
let assignedMember = this.group.members[index];
const index = findIndex(this.group.members, member => member._id === userId);
const assignedMember = this.group.members[index];
assignedUsersNames.push(assignedMember.profile.name);
});
}
if (assignedUsersLength === 1 && !this.userIsAssigned) {
return this.$t('assignedToUser', {userName: assignedUsersNames[0]});
} else if (assignedUsersLength > 1 && !this.userIsAssigned) {
return this.$t('assignedToMembers', {userCount: assignedUsersLength});
} else if (assignedUsersLength > 1 && this.userIsAssigned) {
return this.$t('assignedToYouAndMembers', {userCount: assignedUsersLength - 1});
} else if (this.userIsAssigned) {
return this.$t('assignedToUser', { userName: assignedUsersNames[0] });
} if (assignedUsersLength > 1 && !this.userIsAssigned) {
return this.$t('assignedToMembers', { userCount: assignedUsersLength });
} if (assignedUsersLength > 1 && this.userIsAssigned) {
return this.$t('assignedToYouAndMembers', { userCount: assignedUsersLength - 1 });
} if (this.userIsAssigned) {
return this.$t('youAreAssigned');
} else { // if (assignedUsersLength === 0) {
return this.$t('taskIsUnassigned');
}
} // if (assignedUsersLength === 0) {
return this.$t('taskIsUnassigned');
},
userIsManager () {
if (this.group && (this.group.leader.id === this.user._id || this.group.managers[this.user._id])) return true;
@@ -124,13 +121,13 @@ export default {
taskId,
userId: this.user._id,
});
let index = this.task.group.assignedUsers.indexOf(this.user._id);
const index = this.task.group.assignedUsers.indexOf(this.user._id);
this.task.group.assignedUsers.splice(index, 1);
this.sync();
},
approve () {
let userIdToApprove = this.task.group.assignedUsers[0];
const userIdToApprove = this.task.group.assignedUsers[0];
this.$store.dispatch('tasks:approve', {
taskId: this.task._id,
userId: userIdToApprove,
@@ -140,7 +137,7 @@ export default {
},
needsWork () {
if (!confirm(this.$t('confirmNeedsWork'))) return;
let userIdNeedsMoreWork = this.task.group.assignedUsers[0];
const userIdNeedsMoreWork = this.task.group.assignedUsers[0];
this.$store.dispatch('tasks:needsWork', {
taskId: this.task._id,
userId: userIdNeedsMoreWork,
@@ -26,26 +26,24 @@
<script>
import { mapState } from '@/libs/store';
export default {
props: ['task', 'group'],
computed: {
...mapState({user: 'user.data'}),
...mapState({ user: 'user.data' }),
message () {
let approvals = this.task.approvals || [];
let approvalsLength = approvals.length;
let userIsRequesting = approvals.findIndex((approval) => {
return approval.userId.id === this.user._id;
}) !== -1;
const approvals = this.task.approvals || [];
const approvalsLength = approvals.length;
const userIsRequesting = approvals.findIndex(approval => approval.userId.id === this.user._id) !== -1;
if (approvalsLength === 1 && !userIsRequesting) {
return this.$t('userRequestsApproval', {userName: approvals[0].userId.profile.name});
} else if (approvalsLength > 1 && !userIsRequesting) {
return this.$t('userCountRequestsApproval', {userCount: approvalsLength});
} else if (approvalsLength === 1 && userIsRequesting || this.task.group.approval && this.task.group.approval.requested && !this.task.group.approval.approved) {
return this.$t('userRequestsApproval', { userName: approvals[0].userId.profile.name });
} if (approvalsLength > 1 && !userIsRequesting) {
return this.$t('userCountRequestsApproval', { userCount: approvalsLength });
} if (approvalsLength === 1 && userIsRequesting || this.task.group.approval && this.task.group.approval.requested && !this.task.group.approval.approved) {
return this.$t('youAreRequestingApproval');
} else {
return null;
}
return null;
},
userIsAdmin () {
return this.group && (this.group.leader.id === this.user._id || this.group.managers[this.user._id]);
@@ -24,7 +24,7 @@ export default {
props: ['task'],
methods: {
approve (index) {
let userIdToApprove = this.task.group.assignedUsers[index];
const userIdToApprove = this.task.group.assignedUsers[index];
this.$store.dispatch('tasks:approve', {
taskId: this.task._id,
userId: userIdToApprove,
@@ -34,7 +34,7 @@ export default {
},
needsWork (index) {
if (!confirm(this.$t('confirmNeedsWork'))) return;
let userIdNeedsMoreWork = this.task.group.assignedUsers[index];
const userIdNeedsMoreWork = this.task.group.assignedUsers[index];
this.$store.dispatch('tasks:needsWork', {
taskId: this.task._id,
userId: userIdNeedsMoreWork,
@@ -43,8 +43,8 @@ export default {
};
},
created () {
this.$root.$on('handle-broken-task', (task) => {
this.brokenChallengeTask = Object.assign({}, task);
this.$root.$on('handle-broken-task', task => {
this.brokenChallengeTask = { ...task };
this.$root.$emit('bv::show::modal', 'broken-task-modal');
});
},
@@ -64,10 +64,10 @@ export default {
keep: keepOption,
});
await this.$store.dispatch('tasks:fetchUserTasks', {forceLoad: true});
await this.$store.dispatch('tasks:fetchUserTasks', { forceLoad: true });
if (this.brokenChallengeTask.type === 'todo') {
await this.$store.dispatch('tasks:fetchCompletedTodos', {forceLoad: true});
await this.$store.dispatch('tasks:fetchCompletedTodos', { forceLoad: true });
}
this.close();
+39 -43
View File
@@ -261,10 +261,11 @@
</style>
<script>
import Task from './task';
import ClearCompletedTodos from './clearCompletedTodos';
import throttle from 'lodash/throttle';
import isEmpty from 'lodash/isEmpty';
import draggable from 'vuedraggable';
import Task from './task';
import ClearCompletedTodos from './clearCompletedTodos';
import buyMixin from '@/mixins/buy';
import { mapState, mapActions, mapGetters } from '@/libs/store';
import shopItem from '../shops/shopItem';
@@ -287,10 +288,8 @@ import habitIcon from '@/assets/svg/habit.svg';
import dailyIcon from '@/assets/svg/daily.svg';
import todoIcon from '@/assets/svg/todo.svg';
import rewardIcon from '@/assets/svg/reward.svg';
import draggable from 'vuedraggable';
export default {
mixins: [buyMixin, notifications],
components: {
Task,
ClearCompletedTodos,
@@ -298,6 +297,7 @@ export default {
shopItem,
draggable,
},
mixins: [buyMixin, notifications],
// Set default values for props
// allows for better control of props values
// allows for better control of where this component is called
@@ -325,9 +325,9 @@ export default {
pin: svgPin,
});
let typeLabel = '';
let typeFilters = [];
let activeFilter = {};
const typeLabel = '';
const typeFilters = [];
const activeFilter = {};
return {
typeLabel,
@@ -367,21 +367,21 @@ export default {
}),
taskList () {
// @TODO: This should not default to user's tasks. It should require that you pass options in
let filteredTaskList = this.isUser ?
this.getFilteredTaskList({
const filteredTaskList = this.isUser
? this.getFilteredTaskList({
type: this.type,
filterType: this.activeFilter.label,
}) :
this.filterByLabel(this.taskListOverride, this.activeFilter.label);
})
: this.filterByLabel(this.taskListOverride, this.activeFilter.label);
let taggedList = this.filterByTagList(filteredTaskList, this.selectedTags);
let searchedList = this.filterBySearchText(taggedList, this.searchText);
const taggedList = this.filterByTagList(filteredTaskList, this.selectedTags);
const searchedList = this.filterBySearchText(taggedList, this.searchText);
return searchedList;
},
inAppRewards () {
let watchRefresh = this.forceRefresh; // eslint-disable-line
let rewards = inAppRewards(this.user);
const rewards = inAppRewards(this.user);
// Add season rewards if user is affected
// @TODO: Add buff conditional
@@ -392,10 +392,10 @@ export default {
seafoam: 'sand',
};
for (let key in seasonalSkills) {
for (const key in seasonalSkills) {
if (this.getUserBuffs(key)) {
let debuff = seasonalSkills[key];
let item = Object.assign({}, spells.special[debuff]);
const debuff = seasonalSkills[key];
const item = { ...spells.special[debuff] };
item.text = item.text();
item.notes = item.notes();
item.class = `shop_${key}`;
@@ -418,7 +418,7 @@ export default {
},
quickAddPlaceholder () {
const type = this.$t(this.type);
return this.$t('addATask', {type});
return this.$t('addATask', { type });
},
badgeCount () {
// 0 means the badge will not be shown
@@ -426,13 +426,11 @@ export default {
// and for the active and scheduled views of todos.
if (this.type === 'todo' && this.activeFilter.label !== 'complete2') {
return this.taskList.length;
} else if (this.type === 'daily') {
} if (this.type === 'daily') {
if (this.activeFilter.label === 'due') {
return this.taskList.length;
} else if (this.activeFilter.label === 'all') {
return this.taskList.reduce((count, t) => {
return !t.completed && shouldDo(new Date(), t, this.getUserPreferences) ? count + 1 : count;
}, 0);
} if (this.activeFilter.label === 'all') {
return this.taskList.reduce((count, t) => (!t.completed && shouldDo(new Date(), t, this.getUserPreferences) ? count + 1 : count), 0);
}
}
@@ -512,7 +510,7 @@ export default {
const newPosition = where === 'top' ? 0 : list.length;
list.splice(newPosition, 0, moved[0]);
let newOrder = await this.$store.dispatch('tasks:move', {
const newOrder = await this.$store.dispatch('tasks:move', {
taskId: taskIdToMove,
position: newPosition,
});
@@ -522,7 +520,7 @@ export default {
const rewardsList = this.inAppRewards;
const rewardToMove = rewardsList[data.oldIndex];
let newOrder = await this.$store.dispatch('user:movePinnedItem', {
const newOrder = await this.$store.dispatch('user:movePinnedItem', {
path: rewardToMove.path,
position: data.newIndex,
});
@@ -549,10 +547,8 @@ export default {
const text = this.quickAddText;
if (!text) return false;
const tasks = text.split('\n').reverse().filter(taskText => {
return taskText ? true : false;
}).map(taskText => {
const task = taskDefaults({type: this.type, text: taskText}, this.user);
const tasks = text.split('\n').reverse().filter(taskText => (!!taskText)).map(taskText => {
const task = taskDefaults({ type: this.type, text: taskText }, this.user);
task.tags = this.selectedTags;
return task;
});
@@ -624,7 +620,7 @@ export default {
// filter requested tasks by tags
if (!isEmpty(tagList)) {
filteredTaskList = taskList.filter(
task => tagList.every(tag => task.tags.indexOf(tag) !== -1)
task => tagList.every(tag => task.tags.indexOf(tag) !== -1),
);
}
return filteredTaskList;
@@ -634,19 +630,19 @@ export default {
// filter requested tasks by search text
if (searchText) {
// to ensure broadest case insensitive search matching
let searchTextLowerCase = searchText.toLowerCase();
const searchTextLowerCase = searchText.toLowerCase();
filteredTaskList = taskList.filter(
task => {
task =>
// eslint rule disabled for block to allow nested binary expression
/* eslint-disable no-extra-parens */
return (
task.text.toLowerCase().indexOf(searchTextLowerCase) > -1 ||
(task.notes && task.notes.toLowerCase().indexOf(searchTextLowerCase) > -1) ||
(task.checklist && task.checklist.length > 0 &&
task.checklist.some(checkItem => checkItem.text.toLowerCase().indexOf(searchTextLowerCase) > -1))
);
/* eslint-enable no-extra-parens */
});
(
task.text.toLowerCase().indexOf(searchTextLowerCase) > -1
|| (task.notes && task.notes.toLowerCase().indexOf(searchTextLowerCase) > -1)
|| (task.checklist && task.checklist.length > 0
&& task.checklist.some(checkItem => checkItem.text.toLowerCase().indexOf(searchTextLowerCase) > -1))
),
/* eslint-enable no-extra-parens */
);
}
return filteredTaskList;
},
@@ -654,7 +650,7 @@ export default {
if (rewardItem.locked) return;
// Buy armoire and health potions immediately
let itemsToPurchaseImmediately = ['potion', 'armoire'];
const itemsToPurchaseImmediately = ['potion', 'armoire'];
if (itemsToPurchaseImmediately.indexOf(rewardItem.key) !== -1) {
this.makeGenericPurchase(rewardItem);
this.$emit('buyPressed', rewardItem);
@@ -683,8 +679,8 @@ export default {
}
try {
if (!this.$store.dispatch('user:togglePinnedItem', {type: item.pinType, path: item.path})) {
this.text(this.$t('unpinnedItem', {item: item.text}));
if (!this.$store.dispatch('user:togglePinnedItem', { type: item.pinType, path: item.path })) {
this.text(this.$t('unpinnedItem', { item: item.text }));
}
} catch (e) {
this.error(e.message);
@@ -181,13 +181,13 @@ import * as quests from '@/../../common/script/content/quests';
import { CONSTANTS, setLocalSetting, getLocalSetting } from '@/libs/userlocalManager';
export default {
mixins: [notifications, spellsMixin],
components: {
Drawer,
},
directives: {
mousePosition: MouseMoveDirective,
},
mixins: [notifications, spellsMixin],
data () {
return {
spells,
@@ -209,7 +209,7 @@ export default {
}
},
computed: {
...mapState({user: 'user.data'}),
...mapState({ user: 'user.data' }),
openStatus () {
return this.$store.state.spellOptions.spellDrawOpen ? 1 : 0;
},
@@ -253,10 +253,10 @@ export default {
return notes;
},
questProgress () {
let user = this.user;
const { user } = this;
if (!user.party.quest) return 0;
let userQuest = this.quests[user.party.quest.key];
const userQuest = this.quests[user.party.quest.key];
if (!userQuest) {
return 0;
@@ -98,10 +98,10 @@
import markdownDirective from '@/directives/markdown';
export default {
props: ['tags', 'value'],
directives: {
markdown: markdownDirective,
},
props: ['tags', 'value'],
data () {
return {
selectedTags: [],
+23 -25
View File
@@ -547,11 +547,12 @@
<script>
import { mapState, mapGetters, mapActions } from '@/libs/store';
import moment from 'moment';
import axios from 'axios';
import scoreTask from '@/../../common/script/ops/scoreTask';
import Vue from 'vue';
import uuid from 'uuid';
import { mapState, mapGetters, mapActions } from '@/libs/store';
import scoreTask from '@/../../common/script/ops/scoreTask';
import * as Analytics from '@/libs/analytics';
import positiveIcon from '@/assets/svg/positive.svg';
@@ -575,10 +576,8 @@ import notifications from '@/mixins/notifications';
import approvalHeader from './approvalHeader';
import approvalFooter from './approvalFooter';
import MenuDropdown from '../ui/customMenuDropdown';
import uuid from 'uuid';
export default {
mixins: [notifications],
components: {
approvalFooter,
approvalHeader,
@@ -587,6 +586,7 @@ export default {
directives: {
markdown: markdownDirective,
},
mixins: [notifications],
props: ['task', 'isUser', 'group', 'dueDate', 'showOptions'], // @TODO: maybe we should store the group on state?
data () {
return {
@@ -626,23 +626,21 @@ export default {
return this.task.checklist && this.task.checklist.length > 0;
},
canViewchecklist () {
let userIsTaskUser = this.task.userId ? this.task.userId === this.user._id : true;
const userIsTaskUser = this.task.userId ? this.task.userId === this.user._id : true;
return this.hasChecklist && userIsTaskUser;
},
checklistProgress () {
const totalItems = this.task.checklist.length;
const completedItems = this.task.checklist.reduce((total, item) => {
return item.completed ? total + 1 : total;
}, 0);
const completedItems = this.task.checklist.reduce((total, item) => (item.completed ? total + 1 : total), 0);
return `${completedItems}/${totalItems}`;
},
leftControl () {
const task = this.task;
const { task } = this;
if (task.type === 'reward') return false;
return true;
},
rightControl () {
const task = this.task;
const { task } = this;
if (task.type === 'reward') return true;
if (task.type === 'habit') return true;
return false;
@@ -654,7 +652,7 @@ export default {
return this.getTaskClasses(this.task, 'control', this.dueDate);
},
contentClass () {
const type = this.task.type;
const { type } = this.task;
const classes = [];
classes.push(this.getTaskClasses(this.task, 'control', this.dueDate).content);
@@ -685,9 +683,9 @@ export default {
return this.timeTillDue.asDays() <= 0;
},
dueIn () {
const dueIn = this.timeTillDue.asDays() === 0 ?
this.$t('today') :
this.timeTillDue.humanize(true);
const dueIn = this.timeTillDue.asDays() === 0
? this.$t('today')
: this.timeTillDue.humanize(true);
// this.task && is necessary to make sure the computed property updates correctly
return this.task && this.task.date && this.$t('dueIn', { dueIn });
@@ -710,7 +708,7 @@ export default {
toggleChecklistItem (item) {
if (this.castingSpell) return;
item.completed = !item.completed; // @TODO this should go into the action?
this.scoreChecklistItem({taskId: this.task._id, itemId: item.id});
this.scoreChecklistItem({ taskId: this.task._id, itemId: item.id });
},
edit (e, task) {
if (this.isRunningYesterdailies) return;
@@ -748,13 +746,13 @@ export default {
// TODO move to an action
const Content = this.$store.state.content;
const user = this.user;
const task = this.task;
const { user } = this;
const { task } = this;
if (task.group.approval.required) {
task.group.approval.requested = true;
const groupResponse = await axios.get(`/api/v4/groups/${task.group.id}`);
let managers = Object.keys(groupResponse.data.data.managers);
const managers = Object.keys(groupResponse.data.data.managers);
managers.push(groupResponse.data.data.leader._id);
if (managers.indexOf(user._id) !== -1) {
task.group.approval.approved = true;
@@ -762,7 +760,7 @@ export default {
}
try {
scoreTask({task, user, direction});
scoreTask({ task, user, direction });
} catch (err) {
this.text(err.message);
return;
@@ -787,9 +785,9 @@ export default {
Analytics.updateUser();
const response = await axios.post(`/api/v4/tasks/${task._id}/score/${direction}`);
const tmp = response.data.data._tmp || {}; // used to notify drops, critical hits and other bonuses
const crit = tmp.crit;
const drop = tmp.drop;
const quest = tmp.quest;
const { crit } = tmp;
const { drop } = tmp;
const { quest } = tmp;
if (crit) {
const critBonus = crit * 100 - 100;
@@ -834,15 +832,15 @@ export default {
if (drop.type === 'HatchingPotion') {
dropText = Content.hatchingPotions[drop.key].text();
dropNotes = Content.hatchingPotions[drop.key].notes();
this.drop(this.$t('messageDropPotion', {dropText, dropNotes}), drop);
this.drop(this.$t('messageDropPotion', { dropText, dropNotes }), drop);
} else if (drop.type === 'Egg') {
dropText = Content.eggs[drop.key].text();
dropNotes = Content.eggs[drop.key].notes();
this.drop(this.$t('messageDropEgg', {dropText, dropNotes}), drop);
this.drop(this.$t('messageDropEgg', { dropText, dropNotes }), drop);
} else if (drop.type === 'Food') {
dropText = Content.food[drop.key].textA();
dropNotes = Content.food[drop.key].notes();
this.drop(this.$t('messageDropFood', {dropText, dropNotes}), drop);
this.drop(this.$t('messageDropFood', { dropText, dropNotes }), drop);
} else if (drop.type === 'Quest') {
// TODO $rootScope.selectedQuest = Content.quests[drop.key];
// $rootScope.openModal('questDrop', {controller:'PartyCtrl', size:'sm'});
@@ -653,15 +653,15 @@
</style>
<script>
import TagsPopup from './tagsPopup';
import { mapGetters, mapActions, mapState } from '@/libs/store';
import markdownDirective from '@/directives/markdown';
import toggleSwitch from '@/components/ui/toggleSwitch';
import clone from 'lodash/clone';
import Datepicker from 'vuejs-datepicker';
import moment from 'moment';
import uuid from 'uuid';
import draggable from 'vuedraggable';
import toggleSwitch from '@/components/ui/toggleSwitch';
import markdownDirective from '@/directives/markdown';
import { mapGetters, mapActions, mapState } from '@/libs/store';
import TagsPopup from './tagsPopup';
import informationIcon from '@/assets/svg/information.svg';
import difficultyTrivialIcon from '@/assets/svg/difficulty-trivial.svg';
@@ -721,23 +721,23 @@ export default {
con: 'constitution',
per: 'perception',
},
calendarHighlights: { dates: [new Date()]},
calendarHighlights: { dates: [new Date()] },
};
},
mounted () {
this.showAdvancedOptions = !this.user.preferences.advancedCollapsed;
},
watch: {
task () {
this.syncTask();
},
'task.startDate' () {
'task.startDate': function () {
this.calculateMonthlyRepeatDays();
},
'task.frequency' () {
'task.frequency': function () {
this.calculateMonthlyRepeatDays();
},
},
mounted () {
this.showAdvancedOptions = !this.user.preferences.advancedCollapsed;
},
computed: {
...mapGetters({
getTaskClasses: 'tasks:getTaskClasses',
@@ -766,7 +766,7 @@ export default {
return this.onUserPage && this.isChallengeTask;
},
isOriginalChallengeTask () {
let isUserChallenge = Boolean(this.task.userId);
const isUserChallenge = Boolean(this.task.userId);
return !isUserChallenge && (this.challengeId || this.task.challenge && this.task.challenge.id);
},
canDelete () {
@@ -774,25 +774,24 @@ export default {
},
title () {
const type = this.$t(this.task.type);
return this.$t(this.purpose === 'edit' ? 'editATask' : 'createTask', {type});
return this.$t(this.purpose === 'edit' ? 'editATask' : 'createTask', { type });
},
isUserTask () {
return !this.challengeId && !this.groupId;
},
repeatSuffix () {
const task = this.task;
const { task } = this;
if (task.frequency === 'daily') {
return task.everyX === 1 ? this.$t('day') : this.$t('days');
} else if (task.frequency === 'weekly') {
} if (task.frequency === 'weekly') {
return task.everyX === 1 ? this.$t('week') : this.$t('weeks');
} else if (task.frequency === 'monthly') {
} if (task.frequency === 'monthly') {
return task.everyX === 1 ? this.$t('month') : this.$t('months');
} else if (task.frequency === 'yearly') {
} if (task.frequency === 'yearly') {
return task.everyX === 1 ? this.$t('year') : this.$t('years');
} else {
return null;
}
return null;
},
repeatsOn: {
get () {
@@ -825,14 +824,14 @@ export default {
document.removeEventListener('keyup', this.handleEsc);
},
methods: {
...mapActions({saveTask: 'tasks:save', destroyTask: 'tasks:destroy', createTask: 'tasks:create'}),
...mapActions({ saveTask: 'tasks:save', destroyTask: 'tasks:destroy', createTask: 'tasks:create' }),
async syncTask () {
if (this.groupId && this.task.group && this.task.group.approval) {
this.requiresApproval = this.task.group.approval.required;
}
if (this.groupId) {
let members = await this.$store.dispatch('members:getGroupMembers', {
const members = await this.$store.dispatch('members:getGroupMembers', {
groupId: this.groupId,
includeAllPublicFields: true,
});
@@ -873,14 +872,14 @@ export default {
this.showTagsSelect = !this.showTagsSelect;
},
sortedChecklist (data) {
let sorting = clone(this.task.checklist);
let movingItem = sorting[data.oldIndex];
const sorting = clone(this.task.checklist);
const movingItem = sorting[data.oldIndex];
sorting.splice(data.oldIndex, 1);
sorting.splice(data.newIndex, 0, movingItem);
this.task.checklist = sorting;
},
addChecklistItem (e) {
let checkListItem = {
const checkListItem = {
id: uuid.v4(),
text: this.newChecklistItem,
completed: false,
@@ -900,7 +899,7 @@ export default {
},
calculateMonthlyRepeatDays (newRepeatsOn) {
if (!this.task) return;
const task = this.task;
const { task } = this;
const repeatsOn = newRepeatsOn || this.repeatsOn;
if (task.frequency === 'monthly') {
@@ -914,7 +913,7 @@ export default {
const shortDay = this.dayMapping[dayOfWeek];
task.daysOfMonth = [];
task.weeksOfMonth = [week];
for (let key in task.repeat) {
for (const key in task.repeat) {
task.repeat[key] = false;
}
task.repeat[shortDay] = true;
@@ -946,12 +945,10 @@ export default {
tasks: [this.task],
});
Object.assign(this.task, response);
let promises = this.assignedMembers.map(memberId => {
return this.$store.dispatch('tasks:assignTask', {
taskId: this.task._id,
userId: memberId,
});
});
const promises = this.assignedMembers.map(memberId => this.$store.dispatch('tasks:assignTask', {
taskId: this.task._id,
userId: memberId,
}));
Promise.all(promises);
this.task.group.assignedUsers = this.assignedMembers;
this.$emit('taskCreated', this.task);
@@ -984,9 +981,9 @@ export default {
this.requiresApproval = truthy;
},
async toggleAssignment (memberId) {
let assignedIndex = this.assignedMembers.indexOf(memberId);
const assignedIndex = this.assignedMembers.indexOf(memberId);
if (assignedIndex === -1) {
if (assignedIndex === -1) {
if (this.purpose === 'create') {
return;
}
+12 -12
View File
@@ -258,6 +258,11 @@
</style>
<script>
import uuid from 'uuid';
import Vue from 'vue';
import throttle from 'lodash/throttle';
import cloneDeep from 'lodash/cloneDeep';
import draggable from 'vuedraggable';
import TaskColumn from './column';
import TaskModal from './taskModal';
import spells from './spells';
@@ -272,16 +277,11 @@ import todoIcon from '@/assets/svg/todo.svg';
import rewardIcon from '@/assets/svg/reward.svg';
import dragIcon from '@/assets/svg/drag_indicator.svg';
import uuid from 'uuid';
import Vue from 'vue';
import throttle from 'lodash/throttle';
import cloneDeep from 'lodash/cloneDeep';
import { mapState, mapActions } from '@/libs/store';
import taskDefaults from '@/../../common/script/libs/taskDefaults';
import brokenTaskModal from './brokenTaskModal';
import Item from '@/components/inventory/item.vue';
import draggable from 'vuedraggable';
export default {
components: {
@@ -325,7 +325,7 @@ export default {
};
},
computed: {
...mapState({user: 'user.data'}),
...mapState({ user: 'user.data' }),
tagsByType () {
const userTags = this.user.tags;
const tagsByType = {
@@ -362,7 +362,7 @@ export default {
}, 250),
},
methods: {
...mapActions({setUser: 'user:set'}),
...mapActions({ setUser: 'user:set' }),
checkMouseOver: throttle(function throttleSearch () {
if (this.editingTags) return;
this.closeFilterPanel();
@@ -374,7 +374,7 @@ export default {
this.editingTags = true;
},
addTag (eventObj, key) {
this.tagsSnap[key].push({id: uuid.v4(), name: this.newTag});
this.tagsSnap[key].push({ id: uuid.v4(), name: this.newTag });
this.newTag = null;
},
removeTag (index, key) {
@@ -389,7 +389,7 @@ export default {
this.tagsByType.user.tags = this.tagsSnap.tags;
this.tagsByType.challenges.tags = this.tagsSnap.challenges;
this.setUser({tags: this.tagsSnap.tags.concat(this.tagsSnap.challenges)});
this.setUser({ tags: this.tagsSnap.tags.concat(this.tagsSnap.challenges) });
this.cancelTagsEditing();
},
cancelTagsEditing () {
@@ -409,7 +409,7 @@ export default {
},
createTask (type) {
this.openCreateBtn = false;
this.creatingTask = taskDefaults({type, text: ''}, this.user);
this.creatingTask = taskDefaults({ type, text: '' }, this.user);
this.creatingTask.tags = this.selectedTags;
// Necessary otherwise the first time the modal is not rendered
@@ -441,11 +441,11 @@ export default {
this.closeFilterPanel();
},
applyFilters () {
const temporarilySelectedTags = this.temporarilySelectedTags;
const { temporarilySelectedTags } = this;
this.selectedTags = temporarilySelectedTags.slice();
},
toggleTag (tag) {
const temporarilySelectedTags = this.temporarilySelectedTags;
const { temporarilySelectedTags } = this;
const tagI = temporarilySelectedTags.indexOf(tag.id);
if (tagI === -1) {
temporarilySelectedTags.push(tag.id);