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>!", "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", "habits": "Habits",
"newHabit": "New Habit", "newHabit": "New Habit",
"newHabitBulk": "New Habits (one per line)",
"yellowred": "Weak", "yellowred": "Weak",
"greenblue": "Strong", "greenblue": "Strong",
"edit": "Edit", "edit": "Edit",
@@ -30,11 +31,13 @@
"progress": "Progress", "progress": "Progress",
"dailies": "Dailies", "dailies": "Dailies",
"newDaily": "New Daily", "newDaily": "New Daily",
"newDailyBulk": "New Dailies (one per line)",
"streakCounter": "Streak Counter", "streakCounter": "Streak Counter",
"repeat": "Repeat", "repeat": "Repeat",
"restoreStreak": "Restore Streak", "restoreStreak": "Restore Streak",
"todos": "To-Dos", "todos": "To-Dos",
"newTodo": "New To-Do", "newTodo": "New To-Do",
"newTodoBulk": "New To-Dos (one per line)",
"dueDate": "Due Date", "dueDate": "Due Date",
"remaining": "Active", "remaining": "Active",
"complete": "Done", "complete": "Done",
@@ -48,6 +51,7 @@
"gold": "Gold", "gold": "Gold",
"silver": "Silver (100 silver = 1 gold)", "silver": "Silver (100 silver = 1 gold)",
"newReward": "New Reward", "newReward": "New Reward",
"newRewardBulk": "New Rewards (one per line)",
"price": "Price", "price": "Price",
"tags": "Tags", "tags": "Tags",
"editTags": "Edit", "editTags": "Edit",

View File

@@ -105,10 +105,12 @@ $hrpg-button-with-input
@extend $hrpg-button-master @extend $hrpg-button-master
border: none border: none
border-radius: 0.382em border-radius: 0.382em
input, a, button input, a, button, textarea
display: block display: block
float: left float: left
height: 2em height: 2em
textarea
height: auto
input input
border: 1px solid #ccc border: 1px solid #ccc
border-radius: 0.382em 0em 0em 0.382em !important 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}}) User.user.ops.score({params:{id: task.id, direction:direction}})
}; };
$scope.addTask = function(addTo, listDef) { function addTask(addTo, listDef, task) {
var newTask = { var newTask = {
text: listDef.newTask, text: task,
type: listDef.type, type: listDef.type,
tags: _.transform(User.user.filters, function(m,v,k){ tags: _.transform(User.user.filters, function(m,v,k){
if (v) m[k]=v; if (v) m[k]=v;
}) })
} };
User.user.ops.addTask({body:newTask}); 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; 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 * Add the new task to the actions log
*/ */

View File

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

View File

@@ -24,9 +24,14 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template")
// Add New // Add New
form.task-add(name='new{{list.type}}form', ng-hide='obj._locked', ng-submit='addTask(obj[list.type+"s"],list)') 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') button(type='submit', ng-disabled='new{{list.type}}form.$invalid')
span.glyphicon.glyphicon-plus 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) mixin taskColumnTabs(position)
// Habits Tabs // Habits Tabs