From b20f5545b9acd429025f53bb0b6bb47b9e0770e4 Mon Sep 17 00:00:00 2001 From: "Lucas Torroba (@zesme)" Date: Thu, 26 May 2016 18:51:43 -0300 Subject: [PATCH] Cleanup add checklist item function Cleaned up `addChecklistItem` function, shortening it --- website/client/js/controllers/tasksCtrl.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/website/client/js/controllers/tasksCtrl.js b/website/client/js/controllers/tasksCtrl.js index d3eafa4eb2..a4c9db9971 100644 --- a/website/client/js/controllers/tasksCtrl.js +++ b/website/client/js/controllers/tasksCtrl.js @@ -189,16 +189,13 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N } $scope.addChecklistItem = function(task, $event, $index) { - 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 { + if (task.checklist[$index].text) { $scope.saveTask(task, true); + if ($index == task.checklist.length - 1) + task.checklist.push({ completed: false, text: '' }); focusChecklist(task, $index + 1); + } else { + // TODO Provide UI feedback that this item is still blank } }