Merge branch 'bulk-add-tasks' of https://github.com/chimericdream/habitrpg into bulk-add

This commit is contained in:
Blade Barringer 2015-02-17 08:05:36 -06:00
commit 48e688d815
10 changed files with 114 additions and 5 deletions

View file

@ -31,6 +31,13 @@
"qrCode": "QR Code",
"dataExport": "Data Export",
"saveData": "Here are a few options for saving your Habit data.",
"taskLists": "Task Lists",
"taskData": "You can export lists of your current tasks (useful for sharing many items with another person)",
"exportHabits": "Export Habits",
"exportDailies": "Export Dailies",
"exportToDos": "Export To-Dos",
"exportRewards": "Export Rewards",
"exportAllTasks": "Export All",
"habitHistory": "Habit History",
"exportHistory": "Export History:",
"csv": "(CSV)",

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

@ -156,6 +156,10 @@ for $stage in $stages
width: 20%
span
font-size: 0.8em
.help-block a
border: 0
float: right
font-size: 0.85em
// an individual task entry
// ------------------------

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

@ -22,6 +22,48 @@ var request = require('request');
------------------------------------------------------------------------
*/
function buildTaskList(list) {
var output = [];
_.each(list, function(task) {
output.push(task);
});
return output;
}
dataexport.habits = function(req, res) {
return res.jsonstring({
'habits': buildTaskList(res.locals.user.habits)
});
}
dataexport.dailies = function(req, res) {
return res.jsonstring({
'dailies': buildTaskList(res.locals.user.dailys)
});
}
dataexport.todos = function(req, res) {
return res.jsonstring({
'todos': buildTaskList(res.locals.user.todos)
});
}
dataexport.rewards = function(req, res) {
return res.jsonstring({
'rewards': buildTaskList(res.locals.user.rewards)
});
}
dataexport.tasks = function(req, res) {
var user = res.locals.user;
return res.jsonstring({
'habits': buildTaskList(user.habits),
'dailies': buildTaskList(user.dailys),
'todos': buildTaskList(user.todos),
'rewards': buildTaskList(user.rewards)
});
}
dataexport.history = function(req, res) {
var user = res.locals.user;
var output = [

View file

@ -7,6 +7,11 @@ var i18n = require('../i18n');
var middleware = require('../middleware.js');
/* Data export */
router.get('/habits.json',auth.authWithSession,i18n.getUserLanguage,dataexport.habits); //[todo] encode data output options in the data controller and use these to build routes
router.get('/dailies.json',auth.authWithSession,i18n.getUserLanguage,dataexport.dailies); //[todo] encode data output options in the data controller and use these to build routes
router.get('/todos.json',auth.authWithSession,i18n.getUserLanguage,dataexport.todos); //[todo] encode data output options in the data controller and use these to build routes
router.get('/tasks.json',auth.authWithSession,i18n.getUserLanguage,dataexport.tasks); //[todo] encode data output options in the data controller and use these to build routes
router.get('/rewards.json',auth.authWithSession,i18n.getUserLanguage,dataexport.rewards); //[todo] encode data output options in the data controller and use these to build routes
router.get('/history.csv',auth.authWithSession,i18n.getUserLanguage,dataexport.history); //[todo] encode data output options in the data controller and use these to build routes
router.get('/userdata.xml',auth.authWithSession,i18n.getUserLanguage,dataexport.leanuser,dataexport.userdata.xml);
router.get('/userdata.json',auth.authWithSession,i18n.getUserLanguage,dataexport.leanuser,dataexport.userdata.json);

View file

@ -228,6 +228,23 @@ script(id='partials/options.settings.export.html', type="text/ng-template")
.col-md-6
h2=env.t('dataExport')
small=env.t('saveData')
h4=env.t('taskLists')
small=env.t('taskData')
p
=env.t('exportHabits')
a(href="/export/habits.json")= ' ' + env.t('json')
p
=env.t('exportDailies')
a(href="/export/dailies.json")= ' ' + env.t('json')
p
=env.t('exportToDos')
a(href="/export/todos.json")= ' ' + env.t('json')
p
=env.t('exportRewards')
a(href="/export/rewards.json")= ' ' + env.t('json')
p
=env.t('exportAllTasks')
a(href="/export/tasks.json")= ' ' + env.t('json')
h4=env.t('habitHistory')
=env.t('exportHistory')
a(href="/export/history.csv")= ' ' + env.t('csv')

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