Fixed adding and removing tags on tasks

This commit is contained in:
Keith Holliday
2016-05-14 10:00:10 -05:00
parent 6222c23810
commit 409dfbb2b0
3 changed files with 20 additions and 4 deletions

View File

@@ -33,9 +33,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
var newTask = {
text: task,
type: listDef.type,
// tags: _.transform(User.user.filters, function(m, v, k) {
// if (v) m.push(v);
// }),
tags: _.keys(User.user.filters),
};
User.addTask({body: newTask});
@@ -272,4 +270,21 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
$rootScope.playSound('Reward');
}
}
/*
------------------------
Tags
------------------------
*/
$scope.updateTaskTags = function (tagId, task) {
var tagIndex = task.tags.indexOf(tagId);
if (tagIndex === -1) {
Tasks.addTagToTask(task._id, tagId);
task.tags.push(tagId);
} else {
Tasks.removeTagFromTask(task._id, tagId);
task.tags.splice(tagIndex, 0);
}
}
}]);