mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
- fix: counter of new tasks was not reset when tasks were completed
This commit is contained in:
parent
5b9e142f89
commit
e446880836
2 changed files with 25 additions and 7 deletions
|
|
@ -1177,7 +1177,7 @@ function loadTasks(opts)
|
|||
changeTaskCnt(item, 1);
|
||||
});
|
||||
curList.lastTime = json.time;
|
||||
$('#list_'+curList.id).find('.counter').text('').addClass('hidden');
|
||||
setNewTaskCounterForList(curList.id, 0);
|
||||
if(opts.beforeShow && opts.beforeShow.call) {
|
||||
opts.beforeShow();
|
||||
}
|
||||
|
|
@ -2728,27 +2728,44 @@ function newTaskCounter()
|
|||
})
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
if (json && json.total) {
|
||||
if (json && json.ok) {
|
||||
let counters = {};
|
||||
let curCounter = 0;
|
||||
if (Array.isArray(json.tasks)) {
|
||||
let curCounter = 0;
|
||||
json.tasks.forEach((id) => {
|
||||
if (!taskList[id]) {
|
||||
curCounter++;
|
||||
}
|
||||
});
|
||||
if (curCounter > 0) {
|
||||
$('#list_'+curList.id).find('.counter').text(curCounter).removeClass('hidden');
|
||||
}
|
||||
}
|
||||
counters[curList.id] = curCounter;
|
||||
|
||||
if (Array.isArray(json.lists)) {
|
||||
json.lists.forEach((item) => {
|
||||
$('#list_'+item.listId).find('.counter').text(item.counter).removeClass('hidden');
|
||||
counters[0 + item.listId] = 0 + item.counter;
|
||||
});
|
||||
}
|
||||
|
||||
tabLists.getAll().forEach( (list) => {
|
||||
if (!list.hidden || list.id !== -1) {
|
||||
setNewTaskCounterForList(list.id, counters[list.id]);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setNewTaskCounterForList(listId, counter)
|
||||
{
|
||||
listId = 0 + listId;
|
||||
counter = 0 + counter;
|
||||
if (counter > 0) {
|
||||
$('#list_' + listId).find('.counter').text(counter).removeClass('hidden');
|
||||
} else {
|
||||
$('#list_' + listId).find('.counter').text('').addClass('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Errors and Info messages
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -304,6 +304,7 @@ class TasksController extends ApiController {
|
|||
}
|
||||
|
||||
$this->response->data = [
|
||||
'ok' => true,
|
||||
'total' => count($b) + count($a),
|
||||
'tasks' => $b,
|
||||
'lists' => $a
|
||||
|
|
|
|||
Loading…
Reference in a new issue