mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
Tasks sort delete fix (#8526)
* Fixed task sorting * Add sync when group task is deleted * Added sync when user tasks reorder * Abstracted show logic and removed task grouping from group page * Fixed scope typo * Localized the default challenge short name * Removed default shortName * Fixed test for challenge shortName
This commit is contained in:
@@ -117,9 +117,6 @@ describe('POST /challenges/:challengeId/leave', () => {
|
||||
});
|
||||
|
||||
expect(testTask).to.not.be.undefined;
|
||||
expect(testTask.challenge).to.eql({
|
||||
shortName: 'None',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -74,6 +74,7 @@ habitrpg.controller('GroupTasksCtrl', ['$scope', 'Shared', 'Tasks', 'User', '$ro
|
||||
if (group._id) Tasks.deleteTask(task._id);
|
||||
var index = group[task.type + 's'].indexOf(task);
|
||||
group[task.type + 's'].splice(index, 1);
|
||||
$rootScope.$broadcast('obj-updated', $scope.group);
|
||||
};
|
||||
|
||||
$scope.saveTask = function(task, stayOpen, isSaveAndClose) {
|
||||
|
||||
@@ -159,6 +159,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
$scope.removeTask = function(task) {
|
||||
if (!Tasks.removeTask(task)) return;
|
||||
User.deleteTask({params:{id: task._id, taskType: task.type}})
|
||||
$rootScope.$broadcast('obj-updated', User.user);
|
||||
};
|
||||
|
||||
$scope.unlink = function(task, keep) {
|
||||
|
||||
@@ -65,14 +65,22 @@
|
||||
return $scope.obj[list.type+'s'];
|
||||
};
|
||||
|
||||
$scope.showNormalList = function () {
|
||||
return !$state.includes("options.social.challenges") && !User.user.preferences.tasks.groupByChallenge;
|
||||
};
|
||||
function objIsGroup (obj) {
|
||||
return obj && obj.type && (obj.type === 'guild' || obj.type === 'party');
|
||||
}
|
||||
|
||||
$scope.showNormalList = function (obj) {
|
||||
return objIsGroup(obj) || (!$state.includes("options.social.challenges") && !User.user.preferences.tasks.groupByChallenge);
|
||||
}
|
||||
|
||||
$scope.showChallengeList = function () {
|
||||
return $state.includes("options.social.challenges");
|
||||
};
|
||||
|
||||
$scope.showGroupedList = function (obj) {
|
||||
return User.user.preferences.tasks.groupByChallenge && !$state.includes("options.social.challenges") && !objIsGroup(obj);
|
||||
}
|
||||
|
||||
$scope.showDoubleTaskCounter = function (task, obj) {
|
||||
var objectIsGroup = obj.type && (obj.type === 'guild' || obj.type === 'party');
|
||||
var objectIsChallenge = $state.includes("options.social.challenges");
|
||||
|
||||
@@ -158,7 +158,7 @@ async function _addTaskFn (challenge, tasks, memberId) {
|
||||
|
||||
tasks.forEach(chalTask => {
|
||||
let userTask = new Tasks[chalTask.type](Tasks.Task.sanitize(syncableAttrs(chalTask)));
|
||||
userTask.challenge = {taskId: chalTask._id, id: challenge._id};
|
||||
userTask.challenge = {taskId: chalTask._id, id: challenge._id, shortName: challenge.shortName};
|
||||
userTask.userId = memberId;
|
||||
userTask.notes = chalTask.notes; // We want to sync the notes when the task is first added to the challenge
|
||||
|
||||
|
||||
@@ -58,7 +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: {
|
||||
shortName: {type: String, default: 'None'},
|
||||
shortName: {type: String},
|
||||
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
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
script(id='templates/task-list.html', type="text/ng-template")
|
||||
ul(ng-init='setObj(obj)', class='{{::list.type}}s main-list',
|
||||
ng-show='obj[list.type+"s"].length > 0',
|
||||
hrpg-sort-tasks,
|
||||
ng-if='showNormalList()')
|
||||
task
|
||||
ng-if='showNormalList(obj)')
|
||||
task(hrpg-sort-tasks)
|
||||
|
||||
div(ng-init='setObj(obj);')
|
||||
div(
|
||||
ng-repeat="(key, taskList) in groupedList[list.type]",
|
||||
ng-if='user.preferences.tasks.groupByChallenge && !$state.includes("options.social.challenges")')
|
||||
ng-if='showGroupedList(obj)')
|
||||
h3 {{key}}
|
||||
ul(class='{{::list.type}}s main-list',
|
||||
ng-show='taskList.length > 0', hrpg-sort-tasks)
|
||||
task
|
||||
ng-show='taskList.length > 0')
|
||||
task(hrpg-sort-tasks)
|
||||
|
||||
//Loads the non-sortable lists for challenges
|
||||
ul(ng-init='setObj(obj)', class='{{::list.type}}s main-list',
|
||||
|
||||
Reference in New Issue
Block a user