mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
v3: fix adding multiple tasks
This commit is contained in:
@@ -29,14 +29,18 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
|||||||
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'score task','taskType':task.type,'direction':direction});
|
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'score task','taskType':task.type,'direction':direction});
|
||||||
};
|
};
|
||||||
|
|
||||||
function addTask(addTo, listDef, task) {
|
function addTask(addTo, listDef, tasks) {
|
||||||
var newTask = {
|
tasks = _.isArray(tasks) ? tasks : [tasks];
|
||||||
|
|
||||||
|
User.addTask({
|
||||||
|
body: tasks.map(function (task) {
|
||||||
|
return {
|
||||||
text: task,
|
text: task,
|
||||||
type: listDef.type,
|
type: listDef.type,
|
||||||
tags: _.keys(User.user.filters),
|
tags: _.keys(User.user.filters),
|
||||||
};
|
}
|
||||||
|
}),
|
||||||
User.addTask({body: newTask});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.addTask = function(addTo, listDef) {
|
$scope.addTask = function(addTo, listDef) {
|
||||||
@@ -44,9 +48,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
|||||||
var tasks = listDef.newTask.split(/[\n\r]+/);
|
var tasks = listDef.newTask.split(/[\n\r]+/);
|
||||||
//Reverse the order of tasks so the tasks will appear in the order the user entered them
|
//Reverse the order of tasks so the tasks will appear in the order the user entered them
|
||||||
tasks.reverse();
|
tasks.reverse();
|
||||||
_.each(tasks, function(t) {
|
addTask(addTo, listDef, tasks);
|
||||||
addTask(addTo, listDef, t);
|
|
||||||
});
|
|
||||||
listDef.bulk = false;
|
listDef.bulk = false;
|
||||||
} else {
|
} else {
|
||||||
addTask(addTo, listDef, listDef.newTask);
|
addTask(addTo, listDef, listDef.newTask);
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ function($rootScope, User, $timeout, $state, Analytics) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var goto = function(chapter, page, force) {
|
var goto = function(chapter, page, force) {
|
||||||
if (chapter == 'intro') User.set({'flags.welcomed': true});
|
if (chapter == 'intro' && User.user.flags.welcomed != true) User.set({'flags.welcomed': true});
|
||||||
if (page === -1) page = 0;
|
if (page === -1) page = 0;
|
||||||
var curr = User.user.flags.tour[chapter];
|
var curr = User.user.flags.tour[chapter];
|
||||||
if (page != curr+1 && !force) return;
|
if (page != curr+1 && !force) return;
|
||||||
|
|||||||
@@ -170,7 +170,13 @@ angular.module('habitrpg')
|
|||||||
},
|
},
|
||||||
|
|
||||||
addTask: function (data) {
|
addTask: function (data) {
|
||||||
|
if (_.isArray(data.body)) {
|
||||||
|
data.body.forEach(function (task) {
|
||||||
|
user.ops.addTask({body: task});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
user.ops.addTask(data);
|
user.ops.addTask(data);
|
||||||
|
}
|
||||||
save();
|
save();
|
||||||
Tasks.createUserTasks(data.body);
|
Tasks.createUserTasks(data.body);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user