note list renderer improvements, still WIP

This commit is contained in:
zadam 2020-10-08 23:46:48 +02:00
parent 5933b17b47
commit badb678b69
3 changed files with 66 additions and 24 deletions

View File

@ -26,7 +26,7 @@ async function getRenderedContent(note) {
} }
else if (type === 'file' || type === 'pdf') { else if (type === 'file' || type === 'pdf') {
function getFileUrl() { function getFileUrl() {
return utils.getUrlForDownload("api/notes/" + note.noteId + "/download"); return utils.getUrlForDownload(`api/notes/${note.noteId}/download`);
} }
const $downloadButton = $('<button class="file-download btn btn-primary" type="button">Download</button>'); const $downloadButton = $('<button class="file-download btn btn-primary" type="button">Download</button>');
@ -51,7 +51,7 @@ async function getRenderedContent(note) {
if (type === 'pdf') { if (type === 'pdf') {
const $pdfPreview = $('<iframe class="pdf-preview" style="width: 100%; flex-grow: 100;"></iframe>'); const $pdfPreview = $('<iframe class="pdf-preview" style="width: 100%; flex-grow: 100;"></iframe>');
$pdfPreview.attr("src", utils.getUrlForDownload("api/notes/" + note.noteId + "/open")); $pdfPreview.attr("src", utils.getUrlForDownload(`api/notes/${note.noteId}/open`));
$rendered.append($pdfPreview); $rendered.append($pdfPreview);
} }

View File

@ -36,6 +36,8 @@ const TPL = `
<style> <style>
.note-list { .note-list {
overflow: hidden; overflow: hidden;
position: relative;
height: 100%;
} }
.note-book-card { .note-book-card {
@ -70,8 +72,38 @@ const TPL = `
.note-book-title { .note-book-title {
flex-grow: 0; flex-grow: 0;
} }
.note-list-container {
height: 100%;
overflow: auto;
}
.note-expander {
font-size: x-large;
position: relative;
top: 2px;
cursor: pointer;
}
</style> </style>
<div class="btn-group floating-button" style="right: 20px; top: 10px;">
<button type="button"
class="expand-children-button btn icon-button bx bx-move-vertical"
title="Expand all children"></button>
&nbsp;
<button type="button"
class="list-view-button btn icon-button bx bx-menu"
title="List view"></button>
&nbsp;
<button type="button"
class="grid-view-button btn icon-button bx bx-grid-alt"
title="Grid view"></button>
</div>
<div class="note-list-container"></div> <div class="note-list-container"></div>
</div>`; </div>`;
@ -130,7 +162,8 @@ async function renderList(notes, parentNote = null) {
return $noteList; return $noteList;
} }
async function renderNote(note) { // TODO: we should also render (promoted) attributes
async function renderNote(note, renderContent) {
const notePath = /*this.notePath + '/' + */ note.noteId; const notePath = /*this.notePath + '/' + */ note.noteId;
const $content = $('<div class="note-book-content">') const $content = $('<div class="note-book-content">')
@ -139,9 +172,14 @@ async function renderNote(note) {
const $card = $('<div class="note-book-card">') const $card = $('<div class="note-book-card">')
.attr('data-note-id', note.noteId) .attr('data-note-id', note.noteId)
.css("flex-basis", ZOOMS[zoomLevel].width) .css("flex-basis", ZOOMS[zoomLevel].width)
.append($('<h5 class="note-book-title">').append(await linkService.createNoteLink(notePath, {showTooltip: false}))) .append(
$('<h5 class="note-book-title">')
.append('<span class="note-expander bx bx-chevron-right"></span>')
.append(await linkService.createNoteLink(notePath, {showTooltip: false}))
)
.append($content); .append($content);
if (renderContent) {
try { try {
const {type, renderedContent} = await noteContentRenderer.getRenderedContent(note); const {type, renderedContent} = await noteContentRenderer.getRenderedContent(note);
@ -168,6 +206,7 @@ async function renderNote(note) {
.append($('<div class="note-book-children-content">')) .append($('<div class="note-book-children-content">'))
); );
} }
}
return $card; return $card;
} }

View File

@ -8,6 +8,8 @@ const TPL = `
height: 100%; height: 100%;
padding: 0 10px 10px 10px; padding: 0 10px 10px 10px;
position: relative; position: relative;
display: flex;
flex-direction: column;
} }
.note-book-auto-message { .note-book-auto-message {
@ -19,8 +21,9 @@ const TPL = `
margin-top: 5px; margin-top: 5px;
} }
.note-book-content { .note-detail-book-content {
flex-grow: 1; flex-grow: 1;
min-height: 0;
} }
</style> </style>