mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
Upgrade tests tools and lint migrations and scripts (part 2) (#9998)
* upgrade gulp-babel * upgrade babel-eslint * upgrade eslint-friendly-formatter * start upgrading chai * start to upgrade eslint * restore skipped tests * start to upgrqde monk * fix linting and remove unused file * fix mocha notifications, and common tests * fix unit tests * start to fix initrgration tests * more integration tests fixes * upgrade monk to latest version * lint /scripts * migrations: start moving to /archive unused migrations and run eslint with --fix * lint migrations * fix more integration tests * fix test
This commit is contained in:
@@ -1,83 +0,0 @@
|
||||
import {
|
||||
shouldDo,
|
||||
} from '../cron';
|
||||
import moment from 'moment';
|
||||
|
||||
/*
|
||||
Task classes given everything about the class
|
||||
*/
|
||||
|
||||
// TODO move to the client
|
||||
|
||||
module.exports = function taskClasses (task, filters = [], dayStart = 0, lastCron = Number(new Date()), showCompleted = false, main = false, processingYesterdailies = false) {
|
||||
if (!task) {
|
||||
return '';
|
||||
}
|
||||
let type = task.type;
|
||||
let completed = task.completed;
|
||||
let value = task.value;
|
||||
let priority = task.priority;
|
||||
|
||||
if (main && !task._editing) {
|
||||
for (let filter in filters) {
|
||||
let enabled = filters[filter];
|
||||
if (!task.tags) task.tags = [];
|
||||
if (enabled && task.tags.indexOf(filter) === -1) {
|
||||
return 'hidden';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let classes = task.type;
|
||||
if (task._editing) {
|
||||
classes += ' beingEdited';
|
||||
}
|
||||
|
||||
if (type === 'todo' || type === 'daily') {
|
||||
let dayShouldDo = moment();
|
||||
if (processingYesterdailies) dayShouldDo.subtract(1, 'days');
|
||||
let notDue = !shouldDo(Number(dayShouldDo), task, { dayStart });
|
||||
let isNotDueDaily = type === 'daily' && notDue;
|
||||
|
||||
if (completed || isNotDueDaily) {
|
||||
classes += ' completed';
|
||||
} else {
|
||||
classes += ' uncompleted';
|
||||
}
|
||||
} else if (type === 'habit') {
|
||||
if (task.down && task.up) {
|
||||
classes += ' habit-wide';
|
||||
}
|
||||
if (!task.down && !task.up) {
|
||||
classes += ' habit-narrow';
|
||||
}
|
||||
}
|
||||
|
||||
if (priority === 0.1) {
|
||||
classes += ' difficulty-trivial';
|
||||
} else if (priority === 1) {
|
||||
classes += ' difficulty-easy';
|
||||
} else if (priority === 1.5) {
|
||||
classes += ' difficulty-medium';
|
||||
} else if (priority === 2) {
|
||||
classes += ' difficulty-hard';
|
||||
}
|
||||
|
||||
if (value < -20) {
|
||||
classes += ' color-worst';
|
||||
} else if (value < -10) {
|
||||
classes += ' color-worse';
|
||||
} else if (value < -1) {
|
||||
classes += ' color-bad';
|
||||
} else if (value < 1) {
|
||||
classes += ' color-neutral';
|
||||
} else if (value < 5) {
|
||||
classes += ' color-good';
|
||||
} else if (value < 10) {
|
||||
classes += ' color-better';
|
||||
} else {
|
||||
classes += ' color-best';
|
||||
}
|
||||
|
||||
return classes;
|
||||
};
|
||||
Reference in New Issue
Block a user