mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
first draft of bulk add
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
];
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user