mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
fix(client): Allow bulk task adding in challenges
closes #6781 fixes #6723
This commit is contained in:
@@ -5,6 +5,29 @@ var TASK_KEYS_TO_REMOVE = ['_id', 'completed', 'date', 'dateCompleted', 'history
|
||||
angular.module('habitrpg')
|
||||
.factory('Tasks', ['$rootScope', 'Shared', '$http',
|
||||
function tasksFactory($rootScope, Shared, $http) {
|
||||
function addTasks(listDef, addTaskFn) {
|
||||
var tasks = listDef.newTask;
|
||||
|
||||
if (listDef.bulk) {
|
||||
tasks = tasks.split(/[\n\r]+/);
|
||||
// Reverse the order of tasks so the tasks
|
||||
// will appear in the order the user entered them
|
||||
tasks.reverse();
|
||||
listDef.bulk = false;
|
||||
} else {
|
||||
tasks = [tasks];
|
||||
}
|
||||
|
||||
addTaskFn(listDef, tasks);
|
||||
|
||||
delete listDef.newTask;
|
||||
delete listDef.focus;
|
||||
}
|
||||
|
||||
function toggleBulk (list) {
|
||||
list.bulk = !list.bulk;
|
||||
list.focus = true;
|
||||
};
|
||||
|
||||
function getUserTasks (getCompletedTodos) {
|
||||
var url = '/api/v3/tasks/user';
|
||||
@@ -33,11 +56,11 @@ angular.module('habitrpg')
|
||||
});
|
||||
};
|
||||
|
||||
function createChallengeTasks (challengeId, taskDetails) {
|
||||
function createChallengeTasks (challengeId, tasks) {
|
||||
return $http({
|
||||
method: 'POST',
|
||||
url: '/api/v3/tasks/challenge/' + challengeId,
|
||||
data: taskDetails,
|
||||
data: tasks,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -181,6 +204,8 @@ angular.module('habitrpg')
|
||||
}
|
||||
|
||||
return {
|
||||
addTasks: addTasks,
|
||||
toggleBulk: toggleBulk,
|
||||
getUserTasks: getUserTasks,
|
||||
loadedCompletedTodos: false,
|
||||
createUserTasks: createUserTasks,
|
||||
|
||||
Reference in New Issue
Block a user