From 681d06a31d54a42c18e2cf965dd62baee02daed0 Mon Sep 17 00:00:00 2001 From: maxpozdeev Date: Tue, 18 Oct 2022 18:22:25 +0300 Subject: [PATCH] * can show tags from all lists in tag cloud --- src/content/mytinytodo.js | 22 ++++++++++++++++++++-- src/content/theme/style.css | 28 ++++++++++++++++++++++++---- src/includes/api/TagsController.php | 8 ++++++-- src/includes/lang/en.json | 1 + src/includes/lang/ru.json | 1 + src/includes/theme.php | 11 ++++++++--- 6 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/content/mytinytodo.js b/src/content/mytinytodo.js index ac12372..14c846f 100644 --- a/src/content/mytinytodo.js +++ b/src/content/mytinytodo.js @@ -14,7 +14,16 @@ var sortOrder; //save task order before dragging var searchTimer; var objPrio = {}; var lastClickedNodeId = 0; -var flag = { needAuth:false, isLogged:false, tagsChanged:true, readOnly:false, editFormChanged:false, firstLoad:true, dontChangeHistoryOnce:false }; +var flag = { + needAuth: false, + isLogged: false, + tagsChanged: true, + readOnly: false, + editFormChanged: false, + firstLoad: true, + dontChangeHistoryOnce: false, + showTagsFromAllLists: false +}; var taskCnt = { total:0, past: 0, today:0, soon:0 }; var tabLists = { _lists: {}, @@ -263,6 +272,7 @@ var mytinytodo = window.mytinytodo = _mtt = { }); $('#tagcloudbtn').click(function(){ + $('#tagcloudAllLists').prop('checked', flag.showTagsFromAllLists); if(!_mtt.menus.tagcloud) _mtt.menus.tagcloud = new mttMenu('tagcloud', { beforeShow: function(){ if(flag.tagsChanged) { @@ -286,6 +296,13 @@ var mytinytodo = window.mytinytodo = _mtt = { return false; }); + $('#tagcloudAllLists').click(function(){ + flag.showTagsFromAllLists = this.checked; + $('#tagcloudcontent').html(''); + $('#tagcloudload').show(); + loadTags(curList.id, function(){$('#tagcloudload').hide();}); + }); + $('#mtt-notes-show').click(function(){ toggleAllNotes(1); this.blur(); @@ -1816,13 +1833,14 @@ function addEditTag(tag) function loadTags(listId, callback) { + if (flag.showTagsFromAllLists) listId = -1; _mtt.db.request('tagCloud', {list:listId}, function(json){ if (!parseInt(json.total)) tagsList = []; else tagsList = json.items; var cloud = ''; tagsList.forEach( item => { // item.tag is escaped with htmlspecialchars() - cloud += ' ' + item.tag + ''; + cloud += ' ' + item.tag + ''; }); $('#tagcloudcontent').html(cloud) flag.tagsChanged = false; diff --git a/src/content/theme/style.css b/src/content/theme/style.css index 4c25ba4..3d8f2b3 100644 --- a/src/content/theme/style.css +++ b/src/content/theme/style.css @@ -732,37 +732,57 @@ h3.page-title a.mtt-back-button { #tagcloudbtn { font-size:1rem; font-weight:normal; margin-left:auto; } #mtt.show-all-tasks #tagcloudbtn { display:none; } -#tagcloudload { display:none; height:24px; background:url(images/loading48.gif) center no-repeat; background-size:24px 24px; } #tagcloud { overflow: hidden; z-index:100; background-color:var(--color-menu); border:1px solid var(--color-border-default); - padding:5px; width: 100%; max-width: 600px; text-align: center; box-shadow: var(--color-popup-shadow); + border-radius: 5px; } #tagcloud.mtt-left-adjusted { margin-left:5px; } #tagcloud.mtt-right-adjusted { margin-right:5px; } #tagcloud.mtt-left-adjusted.mtt-right-adjusted { margin-bottom:5px; } +#tagcloud > div { + padding:5px; +} #tagcloud .tag { margin: 2px; padding: 2px; line-height:160%; color: var(--color-text-default); + cursor: pointer; + text-decoration: underline; white-space: nowrap; } #tagcloud .tag:hover { background-color:var(--color-taglist-text-hover-bg); color: var(--color-taglist-text-hover); } - -#tagcloudcancel { float:right; } +#tagcloudload { + display:none; + height:24px; + background:url(images/loading48.gif) center no-repeat; + background-size:24px 24px; +} +#tagcloud .actions { + display: flex; + align-items: center; + border-bottom: 1px solid var(--color-menu-border); +} +#tagcloud .actions > *:first-child { + flex-grow: 1; +} #tagcloudcancel span { mask: url(images/closetag.svg) no-repeat; -webkit-mask: url(images/closetag.svg) no-repeat; background-color: var(--color-btn-reduced); } +#tagcloudcontent { + overflow: hidden; + text-overflow: ellipsis; +} .ui-datepicker { diff --git a/src/includes/api/TagsController.php b/src/includes/api/TagsController.php index 1f6567d..f9ef09a 100644 --- a/src/includes/api/TagsController.php +++ b/src/includes/api/TagsController.php @@ -19,8 +19,12 @@ class TagsController extends ApiController { checkReadAccess($listId); $db = DBConnection::instance(); - $q = $db->dq("SELECT name,tag_id,COUNT(tag_id) AS tags_count FROM {$db->prefix}tag2task INNER JOIN {$db->prefix}tags ON tag_id=id ". - "WHERE list_id=$listId GROUP BY (tag_id) ORDER BY tags_count DESC"); + $sqlWhere = ($listId == -1) ? "" : "WHERE list_id=$listId"; + $q = $db->dq("SELECT name,tag_id,COUNT(tag_id) AS tags_count + FROM {$db->prefix}tag2task INNER JOIN {$db->prefix}tags ON tag_id=id + $sqlWhere + GROUP BY (tag_id) + ORDER BY tags_count DESC"); $at = array(); $ac = array(); while ($r = $q->fetchAssoc()) { diff --git a/src/includes/lang/en.json b/src/includes/lang/en.json index 1f31200..b341c45 100644 --- a/src/includes/lang/en.json +++ b/src/includes/lang/en.json @@ -38,6 +38,7 @@ "public_tasks": "Public Tasks", "tagcloud": "Tags", "tagfilter_cancel": "cancel filter", + "showTagsFromAllLists": "Show tags from all lists", "sortByHand": "Sort by hand", "sortByPriority": "Sort by priority", "sortByDueDate": "Sort by due date", diff --git a/src/includes/lang/ru.json b/src/includes/lang/ru.json index 2442c53..9951db7 100644 --- a/src/includes/lang/ru.json +++ b/src/includes/lang/ru.json @@ -38,6 +38,7 @@ "public_tasks": "Опубликованные задачи", "tagcloud": "Теги", "tagfilter_cancel": "отменить фильтр по тегу", + "showTagsFromAllLists": "Показать теги из всех списков", "sortByHand": "Сортировка вручную", "sortByPriority": "Сортировка по приоритету", "sortByDueDate": "Сортировка по сроку", diff --git a/src/includes/theme.php b/src/includes/theme.php index a595cf9..50d859b 100644 --- a/src/includes/theme.php +++ b/src/includes/theme.php @@ -212,9 +212,14 @@ $().ready(function(){