From 9bb2f462640f31e3a17c63682104e668c6328384 Mon Sep 17 00:00:00 2001 From: Kevin Gisi Date: Tue, 7 Apr 2015 22:37:32 -0400 Subject: [PATCH] Modify removeTask to accept a task object. Update task view to reflect new method signature. --- website/public/js/controllers/tasksCtrl.js | 8 ++++---- website/views/shared/tasks/task.jade | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/website/public/js/controllers/tasksCtrl.js b/website/public/js/controllers/tasksCtrl.js index 95b6f0bee7..875f723161 100644 --- a/website/public/js/controllers/tasksCtrl.js +++ b/website/public/js/controllers/tasksCtrl.js @@ -82,9 +82,9 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N } }; - $scope.removeTask = function(list, $index) { + $scope.removeTask = function(task) { if (!confirm(window.env.t('sureDelete'))) return; - User.user.ops.deleteTask({params:{id:list[$index].id}}) + User.user.ops.deleteTask({params:{id:task.id}}) }; $scope.saveTask = function(task, stayOpen, isSaveAndClose) { @@ -166,7 +166,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N focusChecklist(task,$index-1); // Don't allow the backspace key to navigate back now that the field is gone $event.preventDefault(); - } + } } $scope.swapChecklistItems = function(task, oldIndex, newIndex) { var toSwap = task.checklist.splice(oldIndex, 1)[0]; @@ -186,7 +186,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N /* ------------------------ - Items + Items ------------------------ */ diff --git a/website/views/shared/tasks/task.jade b/website/views/shared/tasks/task.jade index 13e810e092..dc053042a2 100644 --- a/website/views/shared/tasks/task.jade +++ b/website/views/shared/tasks/task.jade @@ -44,7 +44,7 @@ li(bindonce='list', id='task-{{::task.id}}', ng-repeat='task in obj[list.type+"s span.glyphicon.glyphicon-bullhorn(tooltip=env.t('challenge')) |   // delete - a(ng-if='!task.challenge.id', ng-click='removeTask(obj[list.type+"s"], $index)', tooltip=env.t('delete')) + a(ng-if='!task.challenge.id', ng-click='removeTask(task)', tooltip=env.t('delete')) span.glyphicon.glyphicon-trash |   @@ -101,7 +101,7 @@ li(bindonce='list', id='task-{{::task.id}}', ng-repeat='task in obj[list.type+"s p a(ng-click='unlink(task, "keep")')=env.t('keepIt') |    - a(ng-click="removeTask(obj[list.type+'s'], $index)")=env.t('removeIt') + a(ng-click="removeTask(task)")=env.t('removeIt') div(ng-if='task.challenge.broken=="CHALLENGE_DELETED"') p |