1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

All: Added support for hierarchical/nested tags (#2572)

The implementation uses / symbol as a nesting separator. I.e. tag/subtag is a nested tag, where tag is the parent tag and subtag is its child. Creating a tag named tag/subtag/subsubtag creates three tags, one for each level. The tags are associated using parent_id field.

In the app, viewing notes with a tag will also show all notes that are associated with any of the tag's descendant tags (same for the note count). Deleting a tag will also delete all its descendant tags.

In the desktop app the tags are shown nested just like the notebooks.
This commit is contained in:
Vaidotas Šimkus
2020-07-12 18:09:07 +01:00
committed by GitHub
parent 073bd80f89
commit e11e57f1d8
31 changed files with 991 additions and 191 deletions

View File

@ -4,6 +4,7 @@ const Note = require('lib/models/Note.js');
const { Database } = require('lib/database.js');
const { _ } = require('lib/locale.js');
const BaseItem = require('lib/models/BaseItem.js');
const { nestedPath } = require('lib/nested-utils.js');
const { substrWithEllipsis } = require('lib/string-utils.js');
class Folder extends BaseItem {
@ -263,22 +264,7 @@ class Folder extends BaseItem {
}
static folderPath(folders, folderId) {
const idToFolders = {};
for (let i = 0; i < folders.length; i++) {
idToFolders[folders[i].id] = folders[i];
}
const path = [];
while (folderId) {
const folder = idToFolders[folderId];
if (!folder) break; // Shouldn't happen
path.push(folder);
folderId = folder.parent_id;
}
path.reverse();
return path;
return nestedPath(folders, folderId);
}
static folderPathString(folders, folderId, maxTotalLength = 80) {