mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
* start updating colors for tasks controls * finish updating controls colors * change hoevr behavior * change transition duration * update color with transition * refactor menu wip * wip * upgrade vue deps * fix warnings * fix menu * misc fixes * more fixes * fix badge * fix margins in menu * wip tooltips * tooltips * fix checklist colors * add badges * fix quick add input * add transition to task controls too * add batch add * fix task filtering * finish tasks badges * fix menu * upgrade deps * fix shop items using all the same image * fix animation * disable client tests until we remove phantomjs * revert changes to tasks colors * fix opacity in task modal inputs * remove client unit tests from travis * wip task dropdown * fix z-index for task footer/header * fixes and add files * fixes * bigger clickable area * more space to open task dropdown * droddown position * fix menu position * make sure other dropdowns get closed correctly * fixes * start to fix z-index * draggable = false for task dropdown * fix for dropdown position * implement move to top / bottom * fix push to bottom * typo * fix drag and drop * use standard code * wider click area for dropdown * unify badge look * fix padding * misc fixes * more fixes * make dropdown scrollable * misc fixes * fix padding for notes * use existing code instead of new props
81 lines
2.5 KiB
JavaScript
81 lines
2.5 KiB
JavaScript
import { shouldDo } from 'common/script/cron';
|
|
|
|
// Return all the tags belonging to an user task
|
|
export function getTagsFor (store) {
|
|
return (task) => {
|
|
return store.state.user.data.tags
|
|
.filter(tag => task.tags && task.tags.indexOf(tag.id) !== -1)
|
|
.map(tag => tag.name);
|
|
};
|
|
}
|
|
|
|
function getTaskColorByValue (value) {
|
|
if (value < -20) {
|
|
return 'task-worst';
|
|
} else if (value < -10) {
|
|
return 'task-worse';
|
|
} else if (value < -1) {
|
|
return 'task-bad';
|
|
} else if (value < 1) {
|
|
return 'task-neutral';
|
|
} else if (value < 5) {
|
|
return 'task-good';
|
|
} else if (value < 10) {
|
|
return 'task-better';
|
|
} else {
|
|
return 'task-best';
|
|
}
|
|
}
|
|
|
|
export function canDelete () {
|
|
return (task) => {
|
|
let isUserChallenge = Boolean(task.userId);
|
|
let activeChallenge = isUserChallenge && task.challenge && task.challenge.id && !task.challenge.broken;
|
|
return !activeChallenge;
|
|
};
|
|
}
|
|
|
|
export function getTaskClasses (store) {
|
|
const userPreferences = store.state.user.data.preferences;
|
|
|
|
// Purpose is one of 'controls', 'editModal', 'createModal', 'content'
|
|
return (task, purpose, dueDate) => {
|
|
if (!dueDate) dueDate = new Date();
|
|
const type = task.type;
|
|
|
|
switch (purpose) {
|
|
case 'createModal':
|
|
return 'task-purple';
|
|
case 'editModal':
|
|
return type === 'reward' ? 'task-purple' : getTaskColorByValue(task.value);
|
|
case 'controlCreate':
|
|
return {
|
|
up: task.up ? 'task-purple' : 'task-habit-disabled',
|
|
down: task.down ? 'task-purple' : 'task-habit-disabled',
|
|
};
|
|
case 'control':
|
|
switch (type) {
|
|
case 'daily':
|
|
if (task.completed || !shouldDo(dueDate, task, userPreferences)) return 'task-daily-todo-disabled';
|
|
return getTaskColorByValue(task.value);
|
|
case 'todo':
|
|
if (task.completed) return 'task-daily-todo-disabled';
|
|
return getTaskColorByValue(task.value);
|
|
case 'habit':
|
|
return {
|
|
up: task.up ? getTaskColorByValue(task.value) : 'task-habit-disabled',
|
|
down: task.down ? getTaskColorByValue(task.value) : 'task-habit-disabled',
|
|
};
|
|
case 'reward':
|
|
return 'task-reward';
|
|
}
|
|
break;
|
|
case 'content':
|
|
if (type === 'daily' && (task.completed || !shouldDo(dueDate, task, userPreferences)) || type === 'todo' && task.completed) {
|
|
return 'task-daily-todo-content-disabled';
|
|
}
|
|
break;
|
|
}
|
|
};
|
|
}
|