skeleton for global link map

This commit is contained in:
zadam 2021-09-16 23:09:48 +02:00
parent 5866004e23
commit ed26e32ccb
8 changed files with 42 additions and 10 deletions

View File

@ -42,6 +42,7 @@ import RightPaneContainer from "../widgets/containers/right_pane_container.js";
import EditButton from "../widgets/buttons/edit_button.js"; import EditButton from "../widgets/buttons/edit_button.js";
import CalendarMenuWidget from "../widgets/buttons/calendar_menu.js"; import CalendarMenuWidget from "../widgets/buttons/calendar_menu.js";
import EditedNotesWidget from "../widgets/ribbon_widgets/edited_notes.js"; import EditedNotesWidget from "../widgets/ribbon_widgets/edited_notes.js";
import OpenNoteButtonWidget from "../widgets/buttons/open_note_button_widget.js";
export default class DesktopLayout { export default class DesktopLayout {
constructor(customWidgets) { constructor(customWidgets) {
@ -69,6 +70,10 @@ export default class DesktopLayout {
.icon("bx-send") .icon("bx-send")
.title("Jump to note") .title("Jump to note")
.command("jumpToNote")) .command("jumpToNote"))
.child(new OpenNoteButtonWidget()
.icon("bx-map-alt")
.title("Global link map")
.targetNote('globallinkmap'))
.child(new ButtonWidget() .child(new ButtonWidget()
.icon("bx-history") .icon("bx-history")
.title("Show recent changes") .title("Show recent changes")

View File

@ -227,7 +227,7 @@ export default class TabManager extends Component {
/** /**
* If the requested notePath is within current note hoisting scope then keep the note hoisting also for the new tab. * If the requested notePath is within current note hoisting scope then keep the note hoisting also for the new tab.
*/ */
async openTabWithNoteWithHoisting(notePath) { async openTabWithNoteWithHoisting(notePath, activate = false) {
const noteContext = this.getActiveContext(); const noteContext = this.getActiveContext();
let hoistedNoteId = 'root'; let hoistedNoteId = 'root';
@ -239,7 +239,7 @@ export default class TabManager extends Component {
} }
} }
return this.openContextWithNote(notePath, false, null, hoistedNoteId); return this.openContextWithNote(notePath, activate, null, hoistedNoteId);
} }
async openContextWithNote(notePath, activate, ntxId, hoistedNoteId = 'root', mainNtxId = null) { async openContextWithNote(notePath, activate, ntxId, hoistedNoteId = 'root', mainNtxId = null) {

View File

@ -0,0 +1,10 @@
import ButtonWidget from "./button_widget.js";
import appContext from "../../services/app_context.js";
export default class OpenNoteButtonWidget extends ButtonWidget {
targetNote(noteId) {
this.onClick(() => appContext.tabManager.openTabWithNoteWithHoisting(noteId, true));
return this;
}
}

View File

@ -20,6 +20,7 @@ import ReadOnlyTextTypeWidget from "./type_widgets/read_only_text.js";
import ReadOnlyCodeTypeWidget from "./type_widgets/read_only_code.js"; import ReadOnlyCodeTypeWidget from "./type_widgets/read_only_code.js";
import NoneTypeWidget from "./type_widgets/none.js"; import NoneTypeWidget from "./type_widgets/none.js";
import attributeService from "../services/attributes.js"; import attributeService from "../services/attributes.js";
import GlobalLinkMapTypeWidget from "./type_widgets/global_link_map.js";
const TPL = ` const TPL = `
<div class="note-detail"> <div class="note-detail">
@ -45,7 +46,8 @@ const typeWidgetClasses = {
'render': RenderTypeWidget, 'render': RenderTypeWidget,
'relation-map': RelationMapTypeWidget, 'relation-map': RelationMapTypeWidget,
'protected-session': ProtectedSessionTypeWidget, 'protected-session': ProtectedSessionTypeWidget,
'book': BookTypeWidget 'book': BookTypeWidget,
'globallinkmap': GlobalLinkMapTypeWidget
}; };
export default class NoteDetailWidget extends NoteContextAwareWidget { export default class NoteDetailWidget extends NoteContextAwareWidget {
@ -166,6 +168,10 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
type = 'editable-code'; type = 'editable-code';
} }
if (type === 'special') {
type = note.noteId;
}
if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) { if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
type = 'protected-session'; type = 'protected-session';
} }

View File

@ -1,7 +1,5 @@
import openService from "../../services/open.js"; import openService from "../../services/open.js";
import TypeWidget from "./type_widget.js"; import TypeWidget from "./type_widget.js";
import fileWatcher from "../../services/file_watcher.js";
import server from "../../services/server.js";
const TPL = ` const TPL = `
<div class="note-detail-file note-detail-printable"> <div class="note-detail-file note-detail-printable">

View File

@ -0,0 +1,13 @@
import TypeWidget from "./type_widget.js";
const TPL = `<div class="note-detail-global-link-map note-detail-printable">WHATSUP</div>`;
export default class GlobalLinkMapTypeWidget extends TypeWidget {
static getType() { return "globallinkmap"; }
doRender() {
this.$widget = $(TPL);
super.doRender();
}
}

View File

@ -268,7 +268,7 @@ class ConsistencyChecks {
SELECT noteId, type SELECT noteId, type
FROM notes FROM notes
WHERE isDeleted = 0 WHERE isDeleted = 0
AND type NOT IN ('text', 'code', 'render', 'file', 'image', 'search', 'relation-map', 'book')`, AND type NOT IN ('text', 'code', 'render', 'file', 'image', 'search', 'relation-map', 'book', 'special')`,
({noteId, type}) => { ({noteId, type}) => {
if (this.autoFix) { if (this.autoFix) {
const note = becca.getNote(noteId); const note = becca.getNote(noteId);

View File

@ -82,13 +82,13 @@ function getSinglesNoteRoot() {
} }
function getGlobalLinkMapNote() { function getGlobalLinkMapNote() {
let globalLinkMapNote = becca.getNote('global-link-map'); let globalLinkMapNote = becca.getNote('globallinkmap');
if (!globalLinkMapNote) { if (!globalLinkMapNote) {
globalLinkMapNote = noteService.createNewNote({ globalLinkMapNote = noteService.createNewNote({
noteId: 'global-link-map', noteId: 'globallinkmap',
title: 'global-link-map', title: 'Global Link Map',
type: 'global-link-map', type: 'special',
content: '', content: '',
parentNoteId: getSinglesNoteRoot().noteId parentNoteId: getSinglesNoteRoot().noteId
}).note; }).note;