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

@@ -5,6 +5,7 @@
"beeminderDeleteWarning": "Beeminder users: <strong>First</strong> read <a href=\"http://habitrpg.wikia.com/wiki/Beeminder#Deleting_Completed_To-Dos_Without_Confusing_Beeminder\">Deleting Completed To-Dos Without Confusing Beeminder</a>!",
"habits": "Habits",
"newHabit": "New Habit",
"newHabitBulk": "New Habits (one per line)",
"yellowred": "Weak",
"greenblue": "Strong",
"edit": "Edit",
@@ -30,11 +31,13 @@
"progress": "Progress",
"dailies": "Dailies",
"newDaily": "New Daily",
"newDailyBulk": "New Dailies (one per line)",
"streakCounter": "Streak Counter",
"repeat": "Repeat",
"restoreStreak": "Restore Streak",
"todos": "To-Dos",
"newTodo": "New To-Do",
"newTodoBulk": "New To-Dos (one per line)",
"dueDate": "Due Date",
"remaining": "Active",
"complete": "Done",
@@ -48,6 +51,7 @@
"gold": "Gold",
"silver": "Silver (100 silver = 1 gold)",
"newReward": "New Reward",
"newRewardBulk": "New Rewards (one per line)",
"price": "Price",
"tags": "Tags",
"editTags": "Edit",

View File

@@ -105,10 +105,12 @@ $hrpg-button-with-input
@extend $hrpg-button-master
border: none
border-radius: 0.382em
input, a, button
input, a, button, textarea
display: block
float: left
height: 2em
textarea
height: auto
input
border: 1px solid #ccc
border-radius: 0.382em 0em 0em 0.382em !important

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
*/

View File

@@ -73,21 +73,25 @@ habitrpg
header: window.env.t('habits'),
type: 'habit',
placeHolder: window.env.t('newHabit'),
placeHolderBulk: window.env.t('newHabitBulk'),
view: "all"
}, {
header: window.env.t('dailies'),
type: 'daily',
placeHolder: window.env.t('newDaily'),
placeHolderBulk: window.env.t('newDailyBulk'),
view: dailiesView
}, {
header: window.env.t('todos'),
type: 'todo',
placeHolder: window.env.t('newTodo'),
placeHolderBulk: window.env.t('newTodoBulk'),
view: "remaining"
}, {
header: window.env.t('rewards'),
type: 'reward',
placeHolder: window.env.t('newReward'),
placeHolderBulk: window.env.t('newRewardBulk'),
view: "all"
}
];

View File

@@ -24,9 +24,14 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template")
// Add New
form.task-add(name='new{{list.type}}form', ng-hide='obj._locked', ng-submit='addTask(obj[list.type+"s"],list)')
input(type='text', ng-model='list.newTask', placeholder='{{list.placeHolder}}', required)
textarea(rows='6', ng-model='list.newTask', placeholder='{{list.placeHolderBulk}}', ng-if='list.bulk', required)
input(type='text', ng-model='list.newTask', placeholder='{{list.placeHolder}}', ng-if='!list.bulk', required)
button(type='submit', ng-disabled='new{{list.type}}form.$invalid')
span.glyphicon.glyphicon-plus
span.help-block
a(ng-click='toggleBulk(list)')
span.add-multiple(ng-if='!list.bulk') Add Multiple
span.add-single(ng-if='list.bulk') Add Single
mixin taskColumnTabs(position)
// Habits Tabs