small visual tweaks to link map, including displaying the note icon

This commit is contained in:
zadam
2020-10-14 23:14:04 +02:00
parent 4a76b7a9a5
commit 8a019d617f
4 changed files with 90 additions and 57 deletions

View File

@@ -5,6 +5,16 @@ import noteAttributeCache from "../services/note_attribute_cache.js";
const LABEL = 'label';
const RELATION = 'relation';
const NOTE_TYPE_ICONS = {
"file": "bx bx-file",
"image": "bx bx-image",
"code": "bx bx-code",
"render": "bx bx-extension",
"search": "bx bx-file-find",
"relation-map": "bx bx-map-alt",
"book": "bx bx-book"
};
/**
* FIXME: since there's no "full note" anymore we can rename this to Note
*
@@ -254,6 +264,31 @@ class NoteShort {
return this.getAttributes(LABEL, name);
}
getIcon(isFolder = false) {
const iconCassLabels = this.getLabels('iconClass');
if (iconCassLabels.length > 0) {
return iconCassLabels.map(l => l.value).join(' ');
}
else if (this.noteId === 'root') {
return "bx bx-chevrons-right";
}
else if (this.type === 'text') {
if (isFolder) {
return "bx bx-folder";
}
else {
return "bx bx-note";
}
}
else if (this.type === 'code' && this.mime.startsWith('text/x-sql')) {
return "bx bx-data";
}
else {
return NOTE_TYPE_ICONS[this.type];
}
}
/**
* @param {string} [name] - relation name to filter
* @returns {Attribute[]} all note's relations (attributes with type relation), including inherited ones