diff --git a/src/public/javascripts/services/tooltip.js b/src/public/javascripts/services/tooltip.js index 61d462316..df4a9431a 100644 --- a/src/public/javascripts/services/tooltip.js +++ b/src/public/javascripts/services/tooltip.js @@ -1,6 +1,7 @@ import noteDetailService from "./note_detail.js"; import treeUtils from "./tree_utils.js"; import linkService from "./link.js"; +import server from "./server.js"; function setupTooltip() { $(document).tooltip({ @@ -21,19 +22,11 @@ function setupTooltip() { if (notePath) { const noteId = treeUtils.getNoteIdFromNotePath(notePath); - noteDetailService.loadNote(noteId).then(note => { - if (!note.content.trim()) { - return; - } + const notePromise = noteDetailService.loadNote(noteId); + const attributePromise = server.get('notes/' + noteId + '/attributes'); - if (note.type === 'text') { - callback(note.content); - } - else if (note.type === 'code') { - callback($("
").text(note.content).prop('outerHTML')); - } - // other types of notes don't have tooltip preview - }); + Promise.all([notePromise, attributePromise]) + .then(([note, attributes]) => renderTooltip(callback, note, attributes)); } }, close: function (event, ui) { @@ -49,6 +42,57 @@ function setupTooltip() { }); } +async function renderTooltip(callback, note, attributes) { + let content = ''; + const promoted = attributes.filter(attr => (attr.type === 'label-definition' || attr.type === 'relation-definition') && attr.value.isPromoted); + + if (promoted.length > 0) { + const $table = $("
").text(valueAttr.value); + } + else if (valueType === 'relation' && valueAttr.value) { + $value = $(" | ").append(await linkService.createNoteLink(valueAttr.value)); + } + + const $row = $(" |
").text(definitionAttr.name))
+ .append($value);
+
+ $table.append($row);
+ }
+ }
+
+ content += $table.prop('outerHTML');
+ }
+
+ if (note.type === 'text') {
+ content += note.content;
+ }
+ else if (note.type === 'code') {
+ content += $("").text(note.content).prop('outerHTML'); + } + // other types of notes don't have tooltip preview + + console.log(content); + + if (!content.trim()) { + return; + } + + callback(content); +} + export default { setupTooltip } \ No newline at end of file diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index f04efc61d..174004872 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -445,4 +445,12 @@ html.theme-dark body { .show-recent-notes-button { background: url('/images/icons/clock-16.png') no-repeat center; cursor: pointer; +} + +table.promoted-attributes-in-tooltip { + margin: auto; +} + +table.promoted-attributes-in-tooltip td, table.promoted-attributes-in-tooltip th { + padding: 10px; } \ No newline at end of file |
---|