mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Cleanup add checklist item function
Cleaned up `addChecklistItem` function, shortening it
This commit is contained in:
@@ -189,16 +189,13 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.addChecklistItem = function(task, $event, $index) {
|
$scope.addChecklistItem = function(task, $event, $index) {
|
||||||
if (!task.checklist[$index].text) {
|
if (task.checklist[$index].text) {
|
||||||
// Don't allow creation of an empty checklist item
|
|
||||||
// TODO Provide UI feedback that this item is still blank
|
|
||||||
} else if ($index == task.checklist.length - 1) {
|
|
||||||
$scope.saveTask(task, true);
|
|
||||||
task.checklist.push({completed:false, text:''});
|
|
||||||
focusChecklist(task, task.checklist.length - 1);
|
|
||||||
} else {
|
|
||||||
$scope.saveTask(task, true);
|
$scope.saveTask(task, true);
|
||||||
|
if ($index == task.checklist.length - 1)
|
||||||
|
task.checklist.push({ completed: false, text: '' });
|
||||||
focusChecklist(task, $index + 1);
|
focusChecklist(task, $index + 1);
|
||||||
|
} else {
|
||||||
|
// TODO Provide UI feedback that this item is still blank
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user