diff --git a/website/public/js/controllers/challengesCtrl.js b/website/public/js/controllers/challengesCtrl.js index c3d1ef1e0c..b81b8b8340 100644 --- a/website/public/js/controllers/challengesCtrl.js +++ b/website/public/js/controllers/challengesCtrl.js @@ -93,40 +93,41 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', * Clone */ $scope.clone = function(challenge) { - //We need to clone habits, dailys, todos, and rewards. They each need a new id and entry in the database - var clonedTasks = { - habit: [], - daily: [], - todo: [], - reward: [] - }; + //We need to clone habits, dailys, todos, and rewards. They each need a new id and entry in the database + var clonedTasks = { + habit: [], + daily: [], + todo: [], + reward: [] + }; - function cloneTask(element, index, array) { - var task = Shared.taskDefaults({text: element.text, type: element.type}); - clonedTasks[element.type].push(task); - } + function cloneTask(element, index, array) { + var task = Shared.taskDefaults(element); + clonedTasks[element.type].push(task); + } - challenge.habits.forEach(cloneTask); - challenge.dailys.forEach(cloneTask); - challenge.todos.forEach(cloneTask); - challenge.rewards.forEach(cloneTask); + challenge.habits.forEach(cloneTask); + challenge.dailys.forEach(cloneTask); + challenge.todos.forEach(cloneTask); + challenge.rewards.forEach(cloneTask); - //Use values from inc challenge. The reasons we don't use the whole challenge object is because - //Values like timestamp and memebers shouldn't be copied. - $scope.obj = $scope.newChallenge = new Challenges.Challenge({ - name: challenge.name, - shortName: challenge.shortName, - description: challenge.description, - habits: clonedTasks.habit, - dailys: clonedTasks.daily, - todos: clonedTasks.todo, - rewards: clonedTasks.reward, - leader: User.user._id, - group: challenge.group._id, - timestamp: +(new Date), - members: [], - official: false - }); + //Use values from inc challenge. The reasons we don't use the whole challenge object is because + //Values like timestamp and memebers shouldn't be copied. + $scope.obj = $scope.newChallenge = new Challenges.Challenge({ + name: challenge.name, + shortName: challenge.shortName, + description: challenge.description, + habits: clonedTasks.habit, + dailys: clonedTasks.daily, + todos: clonedTasks.todo, + rewards: clonedTasks.reward, + leader: User.user._id, + group: challenge.group._id, + timestamp: +(new Date), + members: [], + official: false, + prize: challenge.prize + }); }; /**