mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Moved clone tasks function to task service
This commit is contained in:
@@ -6,10 +6,11 @@ angular
|
||||
|
||||
tasksFactory.$inject = [
|
||||
'$rootScope',
|
||||
'User'
|
||||
'User',
|
||||
'Shared'
|
||||
];
|
||||
|
||||
function tasksFactory($rootScope, User) {
|
||||
function tasksFactory($rootScope, User, Shared) {
|
||||
|
||||
function editTask(task) {
|
||||
task._editing = !task._editing;
|
||||
@@ -18,7 +19,23 @@ function tasksFactory($rootScope, User) {
|
||||
if($rootScope.charts[task.id]) $rootScope.charts[task.id] = false;
|
||||
}
|
||||
|
||||
function cloneTasks(tasksToClone, arrayWithClonedTasks) {
|
||||
var len = tasksToClone.length;
|
||||
for (var i = 0; i < len; i+=1) {
|
||||
var tmpTask = {};
|
||||
var task = tasksToClone[i];
|
||||
for( var property in task ) {
|
||||
if ( property !== "_id" && property !== "id" && property !== "dateCreated" ) {
|
||||
tmpTask[property] = task[property];
|
||||
}
|
||||
}
|
||||
var newTask = Shared.taskDefaults(tmpTask);
|
||||
arrayWithClonedTasks[newTask.type].push(newTask);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
editTask: editTask
|
||||
editTask: editTask,
|
||||
cloneTasks: cloneTasks,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user