mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-03 04:29:40 +00:00
Cleanup add checklist item function
Cleaned up `addChecklistItem` function, shortening it
This commit is contained in:
parent
46be1553f0
commit
b20f5545b9
1 changed files with 5 additions and 8 deletions
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue