diff --git a/src/content/mytinytodo.js b/src/content/mytinytodo.js index 7821080..ee0385f 100644 --- a/src/content/mytinytodo.js +++ b/src/content/mytinytodo.js @@ -1228,7 +1228,7 @@ function prepareTaskBlocks(item) '
' + preparePrio(item.prio,id) + '' + prepareTaskTitleInlineHtml(item.title) + ' ' + - (curList.id == -1 ? ''+ tabLists.get(item.listId).name +'' : '') + + (curList.id == -1 ? prepareListNameInline(item) : '') + '' + prepareTagsStr(item) + '' + '
' + prepareInlineDate(item) + '
' + '
' + @@ -1251,14 +1251,22 @@ _mtt.prepareTaskBlocks = prepareTaskBlocks; function prepareTaskTitleInlineHtml(s) { - // Task title is already escaped on php back-end + // Task title is already escaped on back-end return s; } _mtt.prepareTaskTitleInlineHtml = prepareTaskTitleInlineHtml; +function prepareListNameInline(item) +{ + // Used in AllTasks list + // List name is already escaped on back-end + return ''+ item.listName +''; +} +_mtt.prepareListNameInline = prepareListNameInline; + function prepareTaskNoteInlineHtml(s, rawText) { - // Task note is already escaped on php back-end + // Task note is already escaped on back-end return s; }; _mtt.prepareTaskNoteInlineHtml = prepareTaskNoteInlineHtml; diff --git a/src/includes/api/TasksController.php b/src/includes/api/TasksController.php index 5cd9aaa..2f0d6cb 100644 --- a/src/includes/api/TasksController.php +++ b/src/includes/api/TasksController.php @@ -24,16 +24,15 @@ class TasksController extends ApiController { $db = DBConnection::instance(); $dbcore = DBCore::default(); - $sqlWhere = $sqlWhereListId = $sqlInnerWhereListId = ''; + $sqlWhere = $sqlWhereListId = ''; + $userLists = []; if ($listId == -1) { $userLists = $this->getUserListsSimple(); $userListsIds = implode(',', array_keys($userLists)); $sqlWhereListId = "todo.list_id IN ($userListsIds) "; - $sqlInnerWhereListId = "list_id IN ($userListsIds) "; } else { $sqlWhereListId = "todo.list_id=". $listId; - $sqlInnerWhereListId = "list_id=$listId "; } if (_get('compl') == 0) { $sqlWhere .= ' AND compl=0'; @@ -125,6 +124,9 @@ class TasksController extends ApiController { while ($r = $q->fetchAssoc()) { $t['total']++; + if ($listId == -1 && $r['list_id']) { + $r['list_name'] = $userLists[ (string)$r['list_id'] ] ?? '((undefined))'; + } $t['list'][] = $this->prepareTaskRow($r); } if (_get('setCompl') && haveWriteAccess($listId)) { @@ -619,6 +621,7 @@ class TasksController extends ApiController { 'title' => titleMarkup( $r['title'] ), 'titleText' => (string)$r['title'], 'listId' => $r['list_id'], + 'listName' => htmlarray($r['list_name'] ?? ''), 'date' => htmlarray($dCreated), 'dateInt' => (int)$r['d_created'], 'dateFull' => htmlarray($dCreatedFull),