mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
Added support for grouping tasks by chllenge
This commit is contained in:
@@ -139,5 +139,6 @@
|
||||
"taskRequiresApproval": "This task must be approved before you can complete it. Approval has already been requested",
|
||||
"taskApprovalHasBeenRequested": "Approval has been requested",
|
||||
"approvals": "Approvals",
|
||||
"approvalRequired": "Approval Required"
|
||||
"approvalRequired": "Approval Required",
|
||||
"groupTasksByChallenge": "Group Tasks by Challenge Title"
|
||||
}
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -87,6 +87,10 @@ script(type='text/ng-template', id='partials/options.settings.settings.html')
|
||||
.checkbox
|
||||
label=env.t('suppressStreakModal')
|
||||
input(type='checkbox', ng-model='user.preferences.suppressModals.streak', ng-change='set({"preferences.suppressModals.streak": user.preferences.suppressModals.streak?true: false})')
|
||||
|
||||
.checkbox
|
||||
label=env.t('groupTasksByChallenge')
|
||||
input(type='checkbox', ng-model='user.preferences.tasks.groupByChallenge', ng-change='set({"preferences.tasks.groupByChallenge": user.preferences.tasks.groupByChallenge ? true: false})')
|
||||
|
||||
hr
|
||||
|
||||
|
||||
@@ -6,7 +6,10 @@ include ./task_view/mixins
|
||||
script(id='templates/habitrpg-tasks.html', type="text/ng-template")
|
||||
.tasks-lists.container-fluid
|
||||
.row
|
||||
.col-sm-6.col-md-3(ng-repeat='list in lists', ng-class='::{ "rewards-module": list.type==="reward", "new-row-sm": list.type==="todo" }')
|
||||
.col-sm-6.col-md-3(
|
||||
ng-repeat='list in lists',
|
||||
ng-init="groupedList = _.groupBy(obj[list.type + 's'], 'challenge.name')",
|
||||
ng-class='::{ "rewards-module": list.type==="reward", "new-row-sm": list.type==="todo" }')
|
||||
.task-column(class='{{::list.type}}s')
|
||||
|
||||
include ./task_view/graph
|
||||
@@ -29,8 +32,19 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template")
|
||||
+taskColumnTabs('top')
|
||||
|
||||
// Actual List
|
||||
ul(class='{{::list.type}}s main-list', ng-show='obj[list.type + "s"].length > 0', hrpg-sort-tasks, ng-if='!$state.includes("options.social.challenges")')
|
||||
ul(class='{{::list.type}}s main-list',
|
||||
ng-init='taskList = obj[list.type+"s"]',
|
||||
ng-show='obj[list.type + "s"].length > 0',
|
||||
hrpg-sort-tasks, ng-if='!$state.includes("options.social.challenges") && !user.preferences.tasks.groupByChallenge')
|
||||
include ./task
|
||||
|
||||
div(ng-repeat="(key, taskList) in groupedList", ng-if='user.preferences.tasks.groupByChallenge')
|
||||
h3 {{key}}
|
||||
ul(class='{{::list.type}}s main-list',
|
||||
ng-show='taskList.length > 0', hrpg-sort-tasks,
|
||||
ng-if='!$state.includes("options.social.challenges")')
|
||||
include ./task
|
||||
|
||||
//Loads the non-sortable lists for challenges
|
||||
ul(class='{{::list.type}}s main-list', ng-show='obj[list.type + "s"].length > 0', ng-if='$state.includes("options.social.challenges")')
|
||||
include ./task
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
li(id='task-{{::task._id}}',
|
||||
ng-repeat='task in obj[list.type+"s"] | filterByTaskInfo: obj.filterQuery | conditionalOrderBy: list.view=="dated":"date"',
|
||||
ng-repeat='task in taskList | filterByTaskInfo: obj.filterQuery | conditionalOrderBy: list.view=="dated":"date"',
|
||||
class='task {{Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main)}}',
|
||||
ng-class='{"cast-target":spell && (list.type != "reward"), "locked-task":obj._locked === true}',
|
||||
ng-click='spell && (list.type != "reward") && castEnd(task, "task", $event)',
|
||||
|
||||
Reference in New Issue
Block a user