basic implementation of children overview, closes #80

This commit is contained in:
azivner 2018-04-08 22:38:52 -04:00
parent 1f96a6beab
commit f4079604c9
4 changed files with 116 additions and 68 deletions

View File

@ -14,6 +14,10 @@ class Branch {
return await this.treeCache.getNote(this.noteId); return await this.treeCache.getNote(this.noteId);
} }
isTopLevel() {
return this.parentNoteId === 'root';
}
get toString() { get toString() {
return `Branch(branchId=${this.branchId})`; return `Branch(branchId=${this.branchId})`;
} }

View File

@ -1,4 +1,5 @@
import treeService from './tree.js'; import treeService from './tree.js';
import treeUtils from './tree_utils.js';
import noteTypeService from './note_type.js'; import noteTypeService from './note_type.js';
import protectedSessionService from './protected_session.js'; import protectedSessionService from './protected_session.js';
import protectedSessionHolder from './protected_session_holder.js'; import protectedSessionHolder from './protected_session_holder.js';
@ -24,6 +25,7 @@ const $noteDetailWrapper = $("#note-detail-wrapper");
const $noteIdDisplay = $("#note-id-display"); const $noteIdDisplay = $("#note-id-display");
const $labelList = $("#label-list"); const $labelList = $("#label-list");
const $labelListInner = $("#label-list-inner"); const $labelListInner = $("#label-list-inner");
const $childrenOverview = $("#children-overview");
let currentNote = null; let currentNote = null;
@ -73,14 +75,14 @@ function noteChanged() {
async function reload() { async function reload() {
// no saving here // no saving here
await loadNoteToEditor(getCurrentNoteId()); await loadNoteDetail(getCurrentNoteId());
} }
async function switchToNote(noteId) { async function switchToNote(noteId) {
if (getCurrentNoteId() !== noteId) { if (getCurrentNoteId() !== noteId) {
await saveNoteIfChanged(); await saveNoteIfChanged();
await loadNoteToEditor(noteId); await loadNoteDetail(noteId);
} }
} }
@ -137,7 +139,7 @@ async function handleProtectedSession() {
protectedSessionService.ensureDialogIsClosed(); protectedSessionService.ensureDialogIsClosed();
} }
async function loadNoteToEditor(noteId) { async function loadNoteDetail(noteId) {
currentNote = await loadNote(noteId); currentNote = await loadNote(noteId);
if (isNewNoteCreated) { if (isNewNoteCreated) {
@ -175,6 +177,26 @@ async function loadNoteToEditor(noteId) {
$noteDetailWrapper.scrollTop(0); $noteDetailWrapper.scrollTop(0);
await loadLabelList(); await loadLabelList();
await showChildrenOverview();
}
async function showChildrenOverview() {
const note = getCurrentNote();
$childrenOverview.empty();
const notePath = treeService.getCurrentNotePath();
for (const childBranch of await note.getChildBranches()) {
const link = $('<a>', {
href: 'javascript:',
text: await treeUtils.getNoteTitle(childBranch.noteId, childBranch.parentNoteId)
}).attr('action', 'note').attr('note-path', notePath + '/' + childBranch.noteId);
const childEl = $('<div class="child-overview">').html(link);
$childrenOverview.append(childEl);
}
} }
async function loadLabelList() { async function loadLabelList() {

View File

@ -5,9 +5,9 @@
display: grid; display: grid;
grid-template-areas: "header header" grid-template-areas: "header header"
"tree-actions title" "tree-actions title"
"search note-content" "search note-detail"
"tree note-content" "tree note-detail"
"parent-list note-content" "parent-list note-detail"
"parent-list label-list"; "parent-list label-list";
grid-template-columns: 2fr 5fr; grid-template-columns: 2fr 5fr;
grid-template-rows: auto grid-template-rows: auto
@ -289,3 +289,20 @@ div.ui-tooltip {
padding: 10px; padding: 10px;
font-size: large; font-size: large;
} }
#children-overview {
padding-top: 20px;
}
.child-overview {
font-weight: bold;
font-size: large;
padding: 10px;
border: 1px solid black;
width: 150px;
height: 95px;
margin-right: 20px;
margin-bottom: 20px;
border-radius: 15px;
overflow: hidden;
}

View File

@ -132,8 +132,9 @@
</div> </div>
</div> </div>
<div style="position: relative; overflow: auto; grid-area: note-content; padding-left: 10px; padding-top: 10px;" id="note-detail-wrapper"> <div style="position: relative; overflow: hidden; grid-area: note-detail; padding-left: 10px; padding-top: 10px; display: flex; flex-direction: column;" id="note-detail-wrapper">
<div id="note-detail-text" class="note-detail-component"></div> <div style="flex-grow: 1; position: relative; overflow: auto; flex-basis: content;">
<div id="note-detail-text" style="height: 100%;" class="note-detail-component"></div>
<div id="note-detail-search" class="note-detail-component"> <div id="note-detail-search" class="note-detail-component">
<div style="display: flex; align-items: center;"> <div style="display: flex; align-items: center;">
@ -204,6 +205,10 @@
<input type="file" id="file-upload" style="display: none" /> <input type="file" id="file-upload" style="display: none" />
</div> </div>
<div id="children-overview" style="flex-grow: 1000; flex-shrink: 1000; flex-basis: 1px; height: 100px; overflow: hidden; display: flex; flex-wrap: wrap">
</div>
</div>
<div id="label-list"> <div id="label-list">
<button class="btn btn-sm show-labels-button">Labels:</button> <button class="btn btn-sm show-labels-button">Labels:</button>