mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
* Added initial group tasks ui * Changed group compnent directory * Added group task checklist support * Added checklist support to ui * Fixed delete tags route * Added checklist routes to support new group tasks * Added assign user tag input * Added new group members autocomplete directive * Linked assign ui to api * Added styles * Limited tag use * Fixed line endings * Updated to new file structure * Fixed failing task tests * Updatd with new checklist logic and fixed columns * Added purchased info to group and prevented non purchased group from seeing new group tasks * Updated add task function * Added userid check back to tag routes * Marked tag tests as pending * Added comments to pending tests * Added back routes accidently deleted * Added locale strings * Other clarity fixes * Moved common task function to task service * Removed files from manifest * Fixed naming collision and remove logic * Removed group get tasks until live * Fixed test to check update task. Removed extra removeTask call. Synced updated checklists. Added purchased to noset * Fixed delete group task
80 lines
2.5 KiB
JavaScript
80 lines
2.5 KiB
JavaScript
habitrpg.controller('GroupTasksCtrl', ['$scope', 'Shared', 'Tasks', 'User', function ($scope, Shared, Tasks, User) {
|
|
$scope.editTask = Tasks.editTask;
|
|
$scope.toggleBulk = Tasks.toggleBulk;
|
|
$scope.cancelTaskEdit = Tasks.cancelTaskEdit;
|
|
|
|
function addTask (listDef, task) {
|
|
var task = Shared.taskDefaults({text: task, type: listDef.type});
|
|
//If the group has not been created, we bulk add tasks on save
|
|
var group = $scope.obj;
|
|
if (group._id) Tasks.createGroupTasks(group._id, task);
|
|
if (!group[task.type + 's']) group[task.type + 's'] = [];
|
|
group[task.type + 's'].unshift(task);
|
|
delete listDef.newTask;
|
|
};
|
|
|
|
$scope.addTask = function(listDef) {
|
|
Tasks.addTasks(listDef, addTask);
|
|
};
|
|
|
|
$scope.removeTask = function(task, group) {
|
|
if (!Tasks.removeTask(task)) return;
|
|
//We only pass to the api if the group exists, otherwise, the tasks only exist on the client
|
|
if (group._id) Tasks.deleteTask(task._id);
|
|
var index = group[task.type + 's'].indexOf(task);
|
|
group[task.type + 's'].splice(index, 1);
|
|
};
|
|
|
|
$scope.saveTask = function(task, stayOpen, isSaveAndClose) {
|
|
Tasks.saveTask (task, stayOpen, isSaveAndClose);
|
|
Tasks.updateTask(task._id, task);
|
|
};
|
|
|
|
$scope.shouldShow = function(task, list, prefs){
|
|
return true;
|
|
};
|
|
|
|
$scope.canEdit = function(task) {
|
|
return true;
|
|
};
|
|
|
|
/*
|
|
------------------------
|
|
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, 1);
|
|
}
|
|
};
|
|
|
|
/*
|
|
------------------------
|
|
Checklists
|
|
------------------------
|
|
*/
|
|
$scope.addChecklist = Tasks.addChecklist;
|
|
|
|
$scope.addChecklistItem = Tasks.addChecklistItemToUI;
|
|
|
|
$scope.removeChecklistItem = Tasks.removeChecklistItemFromUI;
|
|
|
|
$scope.swapChecklistItems = Tasks.swapChecklistItems;
|
|
|
|
$scope.navigateChecklist = Tasks.navigateChecklist;
|
|
|
|
$scope.checklistCompletion = Tasks.checklistCompletion;
|
|
|
|
$scope.collapseChecklist = function (task) {
|
|
Tasks.collapseChecklist(task);
|
|
//@TODO: Currently the api save of the task is separate, so whenever we need to save the task we need to call the respective api
|
|
Tasks.updateTask(task._id, task);
|
|
};
|
|
}]);
|