mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
Group tasks ui picked (#7996)
* 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
This commit is contained in:
committed by
Matteo Pagliazzi
parent
6a82206f81
commit
285041cdee
@@ -101,24 +101,8 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
};
|
||||
|
||||
$scope.saveTask = function(task, stayOpen, isSaveAndClose) {
|
||||
if (task._edit) {
|
||||
angular.copy(task._edit, task);
|
||||
}
|
||||
task._edit = undefined;
|
||||
|
||||
if (task.checklist) {
|
||||
task.checklist = _.filter(task.checklist, function (i) {
|
||||
return !!i.text
|
||||
});
|
||||
}
|
||||
|
||||
Tasks.saveTask (task, stayOpen, isSaveAndClose);
|
||||
User.updateTask(task, {body: task});
|
||||
if (!stayOpen) task._editing = false;
|
||||
|
||||
if (isSaveAndClose) {
|
||||
$("#task-" + task._id).parent().children('.popover').removeClass('in');
|
||||
}
|
||||
|
||||
if (task.type == 'habit') Guide.goto('intro', 3);
|
||||
};
|
||||
|
||||
@@ -132,8 +116,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
$scope.cancelTaskEdit = Tasks.cancelTaskEdit;
|
||||
|
||||
$scope.removeTask = function(task) {
|
||||
if (!confirm(window.env.t('sureDelete', {taskType: window.env.t(task.type), taskText: task.text}))) return;
|
||||
task._edit = undefined;
|
||||
if (!Tasks.removeTask(task)) return;
|
||||
User.deleteTask({params:{id: task._id, taskType: task.type}})
|
||||
};
|
||||
|
||||
@@ -190,60 +173,28 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
Checklists
|
||||
------------------------
|
||||
*/
|
||||
function focusChecklist(task,index) {
|
||||
window.setTimeout(function(){
|
||||
$('#task-'+task._id+' .checklist-form input[type="text"]')[index].focus();
|
||||
});
|
||||
}
|
||||
/*
|
||||
------------------------
|
||||
Checklists
|
||||
------------------------
|
||||
*/
|
||||
$scope.addChecklist = Tasks.addChecklist;
|
||||
|
||||
$scope.addChecklist = function(task) {
|
||||
task._edit.checklist = [{completed:false, text:""}];
|
||||
focusChecklist(task._edit,0);
|
||||
}
|
||||
$scope.addChecklistItem = Tasks.addChecklistItemToUI;
|
||||
|
||||
$scope.addChecklistItem = function(task, $event, $index) {
|
||||
if (task._edit.checklist[$index].text) {
|
||||
if ($index === task._edit.checklist.length - 1) {
|
||||
task._edit.checklist.push({ completed: false, text: '' });
|
||||
}
|
||||
focusChecklist(task._edit, $index + 1);
|
||||
} else {
|
||||
// TODO Provide UI feedback that this item is still blank
|
||||
}
|
||||
}
|
||||
$scope.removeChecklistItem = Tasks.removeChecklistItemFromUI;
|
||||
|
||||
$scope.removeChecklistItem = function(task, $event, $index, force) {
|
||||
// Remove item if clicked on trash icon
|
||||
if (force) {
|
||||
task._edit.checklist.splice($index, 1);
|
||||
} else if (!task._edit.checklist[$index].text) {
|
||||
// User deleted all the text and is now wishing to delete the item
|
||||
// saveTask will prune the empty item
|
||||
// Move focus if the list is still non-empty
|
||||
if ($index > 0)
|
||||
focusChecklist(task._edit, $index-1);
|
||||
// Don't allow the backspace key to navigate back now that the field is gone
|
||||
$event.preventDefault();
|
||||
}
|
||||
}
|
||||
$scope.swapChecklistItems = Tasks.swapChecklistItems;
|
||||
|
||||
$scope.swapChecklistItems = function(task, oldIndex, newIndex) {
|
||||
var toSwap = task._edit.checklist.splice(oldIndex, 1)[0];
|
||||
task._edit.checklist.splice(newIndex, 0, toSwap);
|
||||
}
|
||||
$scope.navigateChecklist = Tasks.navigateChecklist;
|
||||
|
||||
$scope.navigateChecklist = function(task,$index,$event){
|
||||
focusChecklist(task, $event.keyCode == '40' ? $index+1 : $index-1);
|
||||
}
|
||||
$scope.checklistCompletion = Tasks.checklistCompletion;
|
||||
|
||||
$scope.checklistCompletion = function(checklist){
|
||||
return _.reduce(checklist,function(m,i){return m+(i.completed ? 1 : 0);},0)
|
||||
}
|
||||
|
||||
$scope.collapseChecklist = function(task) {
|
||||
task.collapseChecklist = !task.collapseChecklist;
|
||||
$scope.saveTask(task,true);
|
||||
}
|
||||
$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);
|
||||
};
|
||||
|
||||
/*
|
||||
------------------------
|
||||
|
||||
Reference in New Issue
Block a user