From fcf28501e774f963f77e4e59fd0922cb71dc67a3 Mon Sep 17 00:00:00 2001 From: Max Pozdeev Date: Mon, 21 Feb 2022 18:37:32 +0300 Subject: [PATCH] fix incorrect tab html of newly created list (broken in 57bd711) --- src/includes/mytinytodo.js | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/includes/mytinytodo.js b/src/includes/mytinytodo.js index 598e89b..ec7bd6f 100644 --- a/src/includes/mytinytodo.js +++ b/src/includes/mytinytodo.js @@ -713,18 +713,14 @@ var mytinytodo = window.mytinytodo = _mtt = { // open all tasks tab if(_mtt.options.openList == -1) openListId = -1; - $.each(res.list, function(i,item) { - if ( item.id == -1) { + $.each(res.list, function(i, item) { + if ( item.id == -1 ) { tabLists._alltasks = item; - ti += '
  • '+ - ''+item.name+''+ - '
  • '; + ti += prepareListHtml(item); } else { tabLists.add(item); - ti += '
  • '+ - ''+item.name+''+ - '
  • '; + ti += prepareListHtml(item); } }); } @@ -954,13 +950,13 @@ function addList() var item = json.list[0]; var i = tabLists.length(); tabLists.add(item); - if(i > 0) { - $('#lists ul').append('
  • '+ - ''+item.name+''+ - '
  • '); + if (i > 0) { + $('#lists ul').append(prepareListHtml(item)); mytinytodo.doAction('listAdded', item); } - else _mtt.loadLists(); + else { + _mtt.loadLists(); + } }); }); }; @@ -1047,6 +1043,19 @@ function loadTasks(opts) }); }; +function prepareListHtml(list) +{ + var opentag = ''; + if (list.id == -1) { + opentag = '
  • '; + } + else { + opentag = '
  • '; + } + return opentag + + '' + list.name + '' + + '
  • '; +} function prepareTaskStr(item, noteExp) {