API: better task defaults (for 3rd-party up/down scoring)

This commit is contained in:
Tyler Renelle 2013-12-25 10:56:21 -07:00
parent c7b5b5e601
commit 84ef3fb861
2 changed files with 9 additions and 7 deletions

View file

@ -10869,11 +10869,13 @@ var process=require("__browserify_process");(function() {
api.taskDefaults = function(task) {
var defaults, _ref, _ref1;
var defaults, _ref, _ref1, _ref2;
if (!(task.type && ((_ref = task.type) === 'habit' || _ref === 'daily' || _ref === 'todo' || _ref === 'reward'))) {
task.type = 'habit';
}
defaults = {
id: api.uuid(),
type: 'habit',
text: '',
text: task.id != null ? task.id : '',
notes: '',
priority: 1,
challenge: {},
@ -10886,12 +10888,12 @@ var process=require("__browserify_process");(function() {
down: true
});
}
if ((_ref = task.type) === 'habit' || _ref === 'daily') {
if ((_ref1 = task.type) === 'habit' || _ref1 === 'daily') {
_.defaults(task, {
history: []
});
}
if ((_ref1 = task.type) === 'daily' || _ref1 === 'todo') {
if ((_ref2 = task.type) === 'daily' || _ref2 === 'todo') {
_.defaults(task, {
completed: false
});

View file

@ -164,10 +164,10 @@ Even though Mongoose handles task defaults, we want to make sure defaults are se
sending up to the server for performance
###
api.taskDefaults = (task) ->
task.type = 'habit' unless task.type and task.type in ['habit','daily','todo','reward']
defaults =
id: api.uuid()
type: 'habit'
text: ''
text: if task.id? then task.id else ''
notes: ''
priority: 1
challenge: {}