first draft of bulk add

This commit is contained in:
Bill Parrott
2015-02-17 00:25:56 -06:00
parent b1b478bc74
commit 2de3a5dd55
5 changed files with 39 additions and 5 deletions

View File

@@ -23,18 +23,37 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
User.user.ops.score({params:{id: task.id, direction:direction}})
};
$scope.addTask = function(addTo, listDef) {
function addTask(addTo, listDef, task) {
var newTask = {
text: listDef.newTask,
text: task,
type: listDef.type,
tags: _.transform(User.user.filters, function(m,v,k){
if (v) m[k]=v;
})
}
};
User.user.ops.addTask({body:newTask});
}
$scope.addTask = function(addTo, listDef) {
if (listDef.bulk) {
var tasks = listDef.newTask.split(/[\n\r]+/);
_.each(tasks, function(t) {
addTask(addTo, listDef, t);
});
listDef.bulk = false;
} else {
addTask(addTo, listDef, listDef.newTask);
}
delete listDef.newTask;
};
$scope.toggleBulk = function(list) {
if (typeof list.bulk === 'undefined') {
list.bulk = false;
}
list.bulk = !list.bulk;
};
/**
* Add the new task to the actions log
*/