mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +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",
|
"taskRequiresApproval": "This task must be approved before you can complete it. Approval has already been requested",
|
||||||
"taskApprovalHasBeenRequested": "Approval has been requested",
|
"taskApprovalHasBeenRequested": "Approval has been requested",
|
||||||
"approvals": "Approvals",
|
"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
|
if (!matchingTask) { // If the task is new, create it
|
||||||
matchingTask = new Tasks[chalTask.type](Tasks.Task.sanitize(syncableAttrs(chalTask)));
|
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;
|
matchingTask.userId = user._id;
|
||||||
user.tasksOrder[`${chalTask.type}s`].push(matchingTask._id);
|
user.tasksOrder[`${chalTask.type}s`].push(matchingTask._id);
|
||||||
} else {
|
} 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
|
userId: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.']}, // When not set it belongs to a challenge
|
||||||
|
|
||||||
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
|
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
|
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
|
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)
|
// 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
|
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`;
|
achievements party backer contributor auth.timestamps items inbox.optOut`;
|
||||||
|
|
||||||
// The minimum amount of data needed when populating multiple users
|
// The minimum amount of data needed when populating multiple users
|
||||||
|
|||||||
@@ -465,6 +465,9 @@ let schema = new Schema({
|
|||||||
raisePet: {type: Boolean, default: false},
|
raisePet: {type: Boolean, default: false},
|
||||||
streak: {type: Boolean, default: false},
|
streak: {type: Boolean, default: false},
|
||||||
},
|
},
|
||||||
|
tasks: {
|
||||||
|
groupByChallenge: {type: Boolean, default: false},
|
||||||
|
},
|
||||||
improvementCategories: {
|
improvementCategories: {
|
||||||
type: Array,
|
type: Array,
|
||||||
validate: (categories) => {
|
validate: (categories) => {
|
||||||
|
|||||||
@@ -88,6 +88,10 @@ script(type='text/ng-template', id='partials/options.settings.settings.html')
|
|||||||
label=env.t('suppressStreakModal')
|
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})')
|
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
|
hr
|
||||||
|
|
||||||
button.btn.btn-default(ng-click='showBailey()', popover-trigger='mouseenter', popover-placement='right', popover=env.t('showBaileyPop'))= env.t('showBailey')
|
button.btn.btn-default(ng-click='showBailey()', popover-trigger='mouseenter', popover-placement='right', popover=env.t('showBaileyPop'))= env.t('showBailey')
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ include ./task_view/mixins
|
|||||||
script(id='templates/habitrpg-tasks.html', type="text/ng-template")
|
script(id='templates/habitrpg-tasks.html', type="text/ng-template")
|
||||||
.tasks-lists.container-fluid
|
.tasks-lists.container-fluid
|
||||||
.row
|
.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')
|
.task-column(class='{{::list.type}}s')
|
||||||
|
|
||||||
include ./task_view/graph
|
include ./task_view/graph
|
||||||
@@ -29,8 +32,19 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template")
|
|||||||
+taskColumnTabs('top')
|
+taskColumnTabs('top')
|
||||||
|
|
||||||
// Actual List
|
// 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
|
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
|
//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")')
|
ul(class='{{::list.type}}s main-list', ng-show='obj[list.type + "s"].length > 0', ng-if='$state.includes("options.social.challenges")')
|
||||||
include ./task
|
include ./task
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
li(id='task-{{::task._id}}',
|
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)}}',
|
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-class='{"cast-target":spell && (list.type != "reward"), "locked-task":obj._locked === true}',
|
||||||
ng-click='spell && (list.type != "reward") && castEnd(task, "task", $event)',
|
ng-click='spell && (list.type != "reward") && castEnd(task, "task", $event)',
|
||||||
|
|||||||
Reference in New Issue
Block a user