mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-03 04:29:40 +00:00
Added sync with user adds checklist item. Prevented task checklist remove request from being called on blank checklist
This commit is contained in:
parent
51254c26dc
commit
d4287e1fd8
1 changed files with 9 additions and 6 deletions
|
|
@ -193,24 +193,27 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||||
// Don't allow creation of an empty checklist item
|
// Don't allow creation of an empty checklist item
|
||||||
// TODO Provide UI feedback that this item is still blank
|
// TODO Provide UI feedback that this item is still blank
|
||||||
} else if ($index == task.checklist.length - 1) {
|
} else if ($index == task.checklist.length - 1) {
|
||||||
Tasks.addChecklistItem(task._id, task.checklist[$index]);
|
Tasks.addChecklistItem(task._id, task.checklist[$index])
|
||||||
task.checklist.push({completed:false,text:''});
|
.then(function (response) {
|
||||||
focusChecklist(task,task.checklist.length-1);
|
task.checklist[$index] = response.data.data.checklist[$index];
|
||||||
|
});
|
||||||
|
task.checklist.push({completed:false, text:''});
|
||||||
|
focusChecklist(task, task.checklist.length - 1);
|
||||||
} else {
|
} else {
|
||||||
$scope.saveTask(task, true);
|
$scope.saveTask(task, true);
|
||||||
focusChecklist(task, $index + 1);
|
focusChecklist(task, $index + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.removeChecklistItem = function(task, $event, $index, force){
|
$scope.removeChecklistItem = function(task, $event, $index, force) {
|
||||||
// Remove item if clicked on trash icon
|
// Remove item if clicked on trash icon
|
||||||
if (force) {
|
if (force) {
|
||||||
Tasks.removeChecklistItem(task._id, task.checklist[$index].id);
|
if (task.checklist[$index].id) Tasks.removeChecklistItem(task._id, task.checklist[$index].id);
|
||||||
task.checklist.splice($index, 1);
|
task.checklist.splice($index, 1);
|
||||||
} else if (!task.checklist[$index].text) {
|
} else if (!task.checklist[$index].text) {
|
||||||
// User deleted all the text and is now wishing to delete the item
|
// User deleted all the text and is now wishing to delete the item
|
||||||
// saveTask will prune the empty item
|
// saveTask will prune the empty item
|
||||||
Tasks.removeChecklistItem(task._id, task.checklist[$index].id);
|
if (task.checklist[$index].id) Tasks.removeChecklistItem(task._id, task.checklist[$index].id);
|
||||||
// Move focus if the list is still non-empty
|
// Move focus if the list is still non-empty
|
||||||
if ($index > 0)
|
if ($index > 0)
|
||||||
focusChecklist(task, $index-1);
|
focusChecklist(task, $index-1);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue