Merge pull request #6314 from TheHollidayInn/tasks-fix-delete-message

Changed language when deleteing tasks to indicate type and text of task
This commit is contained in:
Sabe Jones
2015-12-14 14:30:06 -06:00
4 changed files with 43 additions and 7 deletions

View File

@@ -5,6 +5,7 @@
"beeminderDeleteWarning": "Beeminder users: <strong>First</strong> read <a href=\"http://habitica.wikia.com/wiki/Beeminder#Deleting_Completed_To-Dos_Without_Confusing_Beeminder\">Deleting Completed To-Dos Without Confusing Beeminder</a>!", "beeminderDeleteWarning": "Beeminder users: <strong>First</strong> read <a href=\"http://habitica.wikia.com/wiki/Beeminder#Deleting_Completed_To-Dos_Without_Confusing_Beeminder\">Deleting Completed To-Dos Without Confusing Beeminder</a>!",
"addmultiple": "Add Multiple", "addmultiple": "Add Multiple",
"addsingle": "Add Single", "addsingle": "Add Single",
"habit": "Habit",
"habits": "Habits", "habits": "Habits",
"newHabit": "New Habit", "newHabit": "New Habit",
"newHabitBulk": "New Habits (one per line)", "newHabitBulk": "New Habits (one per line)",
@@ -32,6 +33,7 @@
"mental": "Mental", "mental": "Mental",
"otherExamples": "Eg, professional pursuits, hobbies, financial, etc.", "otherExamples": "Eg, professional pursuits, hobbies, financial, etc.",
"progress": "Progress", "progress": "Progress",
"daily": "Daily",
"dailies": "Dailies", "dailies": "Dailies",
"newDaily": "New Daily", "newDaily": "New Daily",
"newDailyBulk": "New Dailies (one per line)", "newDailyBulk": "New Dailies (one per line)",
@@ -46,6 +48,7 @@
"day": "Day", "day": "Day",
"days": "Days", "days": "Days",
"restoreStreak": "Restore Streak", "restoreStreak": "Restore Streak",
"todo": "To-Do",
"todos": "To-Dos", "todos": "To-Dos",
"newTodo": "New To-Do", "newTodo": "New To-Do",
"newTodoBulk": "New To-Dos (one per line)", "newTodoBulk": "New To-Dos (one per line)",
@@ -57,6 +60,7 @@
"notDue": "Not Due", "notDue": "Not Due",
"grey": "Grey", "grey": "Grey",
"score": "Score", "score": "Score",
"reward": "Reward",
"rewards": "Rewards", "rewards": "Rewards",
"ingamerewards": "Equipment & Skills", "ingamerewards": "Equipment & Skills",
"gold": "Gold", "gold": "Gold",
@@ -86,7 +90,7 @@
"fortifyPop": "Return all tasks to neutral value (yellow color), and restore all lost Health.", "fortifyPop": "Return all tasks to neutral value (yellow color), and restore all lost Health.",
"fortify": "Fortify", "fortify": "Fortify",
"fortifyText": "Fortify will return all your tasks to a neutral (yellow) state, as if you'd just added them, and top your Health off to full. This is great if all your red tasks are making the game too hard, or all your blue tasks are making the game too easy. If starting fresh sounds much more motivating, spend the Gems and catch a reprieve!", "fortifyText": "Fortify will return all your tasks to a neutral (yellow) state, as if you'd just added them, and top your Health off to full. This is great if all your red tasks are making the game too hard, or all your blue tasks are making the game too easy. If starting fresh sounds much more motivating, spend the Gems and catch a reprieve!",
"sureDelete": "Are you sure you want to delete this task?", "sureDelete": "Are you sure you want to delete the <%= taskType %> with the text \"<%= taskText %>\"?",
"streakCoins": "Streak Bonus!", "streakCoins": "Streak Bonus!",
"pushTaskToTop": "Push task to top. Hold ctrl or cmd to push to bottom.", "pushTaskToTop": "Push task to top. Hold ctrl or cmd to push to bottom.",
"emptyTask": "Enter the task's title first.", "emptyTask": "Enter the task's title first.",

View File

@@ -1,12 +1,18 @@
'use strict'; 'use strict';
describe('Tasks Controller', function() { describe('Tasks Controller', function() {
var $rootScope, shared, scope, user, ctrl; var $rootScope, shared, scope, user, User, ctrl;
beforeEach(function() { beforeEach(function() {
user = specHelper.newUser(); user = specHelper.newUser();
User = {
user: user
};
User.user.ops = {
deleteTask: sandbox.stub(),
};
module(function($provide) { module(function($provide) {
$provide.value('User', {user: user}); $provide.value('User', User);
$provide.value('Guide', {}); $provide.value('Guide', {});
}); });
@@ -14,9 +20,9 @@ describe('Tasks Controller', function() {
scope = $rootScope.$new(); scope = $rootScope.$new();
shared = Shared; shared = Shared;
$controller('RootCtrl', {$scope: scope, User: {user: user}}); $controller('RootCtrl', {$scope: scope, User: User});
ctrl = $controller('TasksCtrl', {$scope: scope, User: {user: user}}); ctrl = $controller('TasksCtrl', {$scope: scope, User: User});
}); });
}); });
@@ -29,6 +35,32 @@ describe('Tasks Controller', function() {
}); });
}); });
describe('removeTask', function() {
var task;
beforeEach(function() {
sandbox.stub(window, 'confirm');
task = specHelper.newTodo();
});
it('asks user to confirm deletion', function() {
scope.removeTask(task);
expect(window.confirm).to.be.calledOnce;
});
it('does not remove task if not confirmed', function() {
window.confirm.returns(false);
scope.removeTask(task);
expect(user.ops.deleteTask).to.not.be.called;
});
it('removes task', function() {
window.confirm.returns(true);
scope.removeTask(task);
expect(user.ops.deleteTask).to.be.calledOnce;
});
});
describe('watch to updateStore', function() { describe('watch to updateStore', function() {
it('updates itemStore when user gear changes', function() { it('updates itemStore when user gear changes', function() {
sinon.stub(shared, 'updateStore').returns({item: true}); sinon.stub(shared, 'updateStore').returns({item: true});

View File

@@ -212,7 +212,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
}; };
$scope.removeTask = function(task, list) { $scope.removeTask = function(task, list) {
if (!confirm(window.env.t('sureDelete'))) return; if (!confirm(window.env.t('sureDelete', {taskType: window.env.t(task.type), taskText: task.text}))) return;
//TODO persist //TODO persist
// User.log({op: "delTask", data: task}); // User.log({op: "delTask", data: task});
_.remove(list, task); _.remove(list, task);

View File

@@ -92,7 +92,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
}; };
$scope.removeTask = function(task) { $scope.removeTask = function(task) {
if (!confirm(window.env.t('sureDelete'))) return; if (!confirm(window.env.t('sureDelete', {taskType: window.env.t(task.type), taskText: task.text}))) return;
User.user.ops.deleteTask({params:{id:task.id}}) User.user.ops.deleteTask({params:{id:task.id}})
}; };