mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Added support for grouping tasks by chllenge
This commit is contained in:
@@ -121,7 +121,7 @@ schema.methods.syncToUser = async function syncChallengeToUser (user) {
|
||||
|
||||
if (!matchingTask) { // If the task is new, create it
|
||||
matchingTask = new Tasks[chalTask.type](Tasks.Task.sanitize(syncableAttrs(chalTask)));
|
||||
matchingTask.challenge = {taskId: chalTask._id, id: challenge._id};
|
||||
matchingTask.challenge = {taskId: chalTask._id, id: challenge._id, name: challenge.shortName};
|
||||
matchingTask.userId = user._id;
|
||||
user.tasksOrder[`${chalTask.type}s`].push(matchingTask._id);
|
||||
} else {
|
||||
|
||||
@@ -58,6 +58,7 @@ export let TaskSchema = new Schema({
|
||||
userId: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.']}, // When not set it belongs to a challenge
|
||||
|
||||
challenge: {
|
||||
name: {type: String, default: 'No Category'},
|
||||
id: {type: String, ref: 'Challenge', validate: [validator.isUUID, 'Invalid uuid.']}, // When set (and userId not set) it's the original task
|
||||
taskId: {type: String, ref: 'Task', validate: [validator.isUUID, 'Invalid uuid.']}, // When not set but challenge.id defined it's the original task
|
||||
broken: {type: String, enum: ['CHALLENGE_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED', 'CHALLENGE_CLOSED', 'CHALLENGE_TASK_NOT_FOUND']}, // CHALLENGE_TASK_NOT_FOUND comes from v3 migration
|
||||
|
||||
@@ -7,7 +7,7 @@ require('./methods');
|
||||
|
||||
// A list of publicly accessible fields (not everything from preferences because there are also a lot of settings tha should remain private)
|
||||
export let publicFields = `preferences.size preferences.hair preferences.skin preferences.shirt
|
||||
preferences.chair preferences.costume preferences.sleep preferences.background profile stats
|
||||
preferences.chair preferences.costume preferences.sleep preferences.background preferences.tasks profile stats
|
||||
achievements party backer contributor auth.timestamps items inbox.optOut`;
|
||||
|
||||
// The minimum amount of data needed when populating multiple users
|
||||
|
||||
@@ -465,6 +465,9 @@ let schema = new Schema({
|
||||
raisePet: {type: Boolean, default: false},
|
||||
streak: {type: Boolean, default: false},
|
||||
},
|
||||
tasks: {
|
||||
groupByChallenge: {type: Boolean, default: false},
|
||||
},
|
||||
improvementCategories: {
|
||||
type: Array,
|
||||
validate: (categories) => {
|
||||
|
||||
Reference in New Issue
Block a user