mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-01 11:40:25 +00:00
fix for *.completed on dailies
This commit is contained in:
parent
1eae25ae54
commit
52a96eb5e3
2 changed files with 30 additions and 25 deletions
|
|
@ -197,20 +197,24 @@ ready(function(model) {
|
|||
}
|
||||
tour.start();
|
||||
model.on('set', '_user.tasks.*.completed', function(i, completed, previous, isLocal) {
|
||||
var direction, from, ids, index, shouldTransfer, task, to, _ref3, _ref4, _ref5;
|
||||
_ref3 = [null, null, false, null], from = _ref3[0], to = _ref3[1], shouldTransfer = _ref3[2], direction = _ref3[3];
|
||||
if (completed === true && previous === false && isLocal) {
|
||||
_ref4 = ['_todoList', '_completedList', true, 'up'], from = _ref4[0], to = _ref4[1], shouldTransfer = _ref4[2], direction = _ref4[3];
|
||||
} else if (completed === false && previous === true && isLocal) {
|
||||
_ref5 = ['_completedList', '_todoList', true, 'down'], from = _ref5[0], to = _ref5[1], shouldTransfer = _ref5[2], direction = _ref5[3];
|
||||
}
|
||||
if (shouldTransfer) {
|
||||
task = model.at("_user.tasks." + i);
|
||||
score({
|
||||
user: model.at('_user'),
|
||||
task: task,
|
||||
direction: direction
|
||||
});
|
||||
var direction, from, ids, index, task, to, _ref3;
|
||||
direction = function() {
|
||||
if (completed === true && previous === false) {
|
||||
return 'up';
|
||||
}
|
||||
if (completed === false && previous === true) {
|
||||
return 'down';
|
||||
}
|
||||
return console.error('Error: direction neither "up" nor "down" on checkbox set.');
|
||||
};
|
||||
task = model.at("_user.tasks." + i);
|
||||
score({
|
||||
user: model.at('_user'),
|
||||
task: task,
|
||||
direction: direction()
|
||||
});
|
||||
if (task.get('type') === 'todo') {
|
||||
_ref3 = direction() === 'up' ? ['_todoList', '_completedList'] : ['_completedList', '_todoList'], from = _ref3[0], to = _ref3[1];
|
||||
ids = _.map(model.get(from), function(obj) {
|
||||
return obj.id;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -164,17 +164,18 @@ ready (model) ->
|
|||
# return false
|
||||
|
||||
model.on 'set', '_user.tasks.*.completed', (i, completed, previous, isLocal) ->
|
||||
|
||||
[from, to, shouldTransfer, direction] = [null, null, false, null]
|
||||
if completed==true and previous==false and isLocal
|
||||
[from, to, shouldTransfer, direction] = ['_todoList', '_completedList', true, 'up']
|
||||
else if completed==false and previous==true and isLocal
|
||||
[from, to, shouldTransfer, direction] = ['_completedList', '_todoList', true, 'down']
|
||||
if shouldTransfer
|
||||
task = model.at("_user.tasks.#{i}")
|
||||
# Score the user based on todo task
|
||||
score({user:model.at('_user'), task:task, direction:direction})
|
||||
# Then move the task to/from _todoList/_completedList
|
||||
direction = () ->
|
||||
return 'up' if completed==true and previous == false
|
||||
return 'down' if completed==false and previous == true
|
||||
console.error 'Error: direction neither "up" nor "down" on checkbox set.'
|
||||
|
||||
# Score the user based on todo task
|
||||
task = model.at("_user.tasks.#{i}")
|
||||
score({user:model.at('_user'), task:task, direction:direction()})
|
||||
|
||||
# Then move the todos to/from _todoList/_completedList
|
||||
if task.get('type') == 'todo'
|
||||
[from, to] = if (direction()=='up') then ['_todoList', '_completedList'] else ['_completedList', '_todoList']
|
||||
ids = _.map model.get(from), (obj) ->
|
||||
obj.id
|
||||
index = ids.indexOf(i)
|
||||
|
|
|
|||
Loading…
Reference in a new issue