appearance options as a special note

This commit is contained in:
zadam 2022-12-05 23:57:29 +01:00
parent 74fdaad032
commit aec2c2d5cd
7 changed files with 95 additions and 25 deletions

View File

@ -83,4 +83,8 @@ export default class RootCommandExecutor extends Component {
async showHiddenSubtreeCommand() { async showHiddenSubtreeCommand() {
await appContext.tabManager.openContextWithNote('hidden', true, null, 'hidden'); await appContext.tabManager.openContextWithNote('hidden', true, null, 'hidden');
} }
async showOptionsInHiddenCommand() {
await appContext.tabManager.openContextWithNote('opt_root', true, null, 'opt_root');
}
} }

View File

@ -83,10 +83,15 @@ const TPL = `
</button> </button>
<ul class="dropdown-menu dropdown-menu-right"> <ul class="dropdown-menu dropdown-menu-right">
<li class="dropdown-item options-button" data-trigger-command="showOptions"> <li class="dropdown-item" data-trigger-command="showOptions">
<span class="bx bx-slider"></span> <span class="bx bx-slider"></span>
Options Options
</li> </li>
<li class="dropdown-item" data-trigger-command="showOptionsInHidden">
<span class="bx bx-slider"></span>
Options in hidden
</li>
<li class="dropdown-item" data-trigger-command="openNewWindow"> <li class="dropdown-item" data-trigger-command="openNewWindow">
<span class="bx bx-window-open"></span> <span class="bx bx-window-open"></span>

View File

@ -26,6 +26,7 @@ import NoneTypeWidget from "./type_widgets/none.js";
import NoteMapTypeWidget from "./type_widgets/note_map.js"; import NoteMapTypeWidget from "./type_widgets/note_map.js";
import WebViewTypeWidget from "./type_widgets/web_view.js"; import WebViewTypeWidget from "./type_widgets/web_view.js";
import DocTypeWidget from "./type_widgets/doc.js"; import DocTypeWidget from "./type_widgets/doc.js";
import WidgetTypeWidget from "./type_widgets/widget.js";
const TPL = ` const TPL = `
<div class="note-detail"> <div class="note-detail">
@ -59,7 +60,8 @@ const typeWidgetClasses = {
'book': BookTypeWidget, 'book': BookTypeWidget,
'note-map': NoteMapTypeWidget, 'note-map': NoteMapTypeWidget,
'web-view': WebViewTypeWidget, 'web-view': WebViewTypeWidget,
'doc': DocTypeWidget 'doc': DocTypeWidget,
'widget': WidgetTypeWidget
}; };
export default class NoteDetailWidget extends NoteContextAwareWidget { export default class NoteDetailWidget extends NoteContextAwareWidget {

View File

@ -10,6 +10,7 @@ const NOTE_TYPES = [
{ type: "note-map", mime: '', title: "Note Map", selectable: false }, { type: "note-map", mime: '', title: "Note Map", selectable: false },
{ type: "launcher", mime: '', title: "Launcher", selectable: false }, { type: "launcher", mime: '', title: "Launcher", selectable: false },
{ type: "doc", mime: '', title: "Doc", selectable: false }, { type: "doc", mime: '', title: "Doc", selectable: false },
{ type: "widget", mime: '', title: "Widget", selectable: false },
{ type: "text", mime: "text/html", title: "Text", selectable: true }, { type: "text", mime: "text/html", title: "Text", selectable: true },
{ type: "relation-map", mime: "application/json", title: "Relation Map", selectable: true }, { type: "relation-map", mime: "application/json", title: "Relation Map", selectable: true },

View File

@ -0,0 +1,23 @@
import TypeWidget from "./type_widget.js";
const TPL = `<div class="note-detail-widget note-detail-printable"></div>`;
export default class WidgetTypeWidget extends TypeWidget {
static getType() { return "widget"; }
doRender() {
this.$widget = $(TPL);
super.doRender();
}
async doRefresh(note) {
const widgetName = note.getLabelValue('widget');
if (widgetName === 'optionsAppearance') {
this.$widget.empty().append("HI!");
} else {
this.$widget.empty().append(`Unknown widget of type "${widgetName}"`);
}
}
}

View File

@ -12,5 +12,6 @@ module.exports = [
'canvas', 'canvas',
'web-view', 'web-view',
'launcher', 'launcher',
'doc' 'doc',
'widget'
]; ];

View File

@ -58,10 +58,6 @@ function getHiddenRoot() {
hidden.addLabel('iconClass', "bx bx-chip", false); hidden.addLabel('iconClass', "bx bx-chip", false);
} }
if (!hidden.hasOwnedLabel("docName")) {
hidden.addLabel("docName", "hidden");
}
const MAX_POS = 999_999_999; const MAX_POS = 999_999_999;
const branch = hidden.getBranches()[0]; const branch = hidden.getBranches()[0];
@ -349,16 +345,7 @@ const launchers = [
{ id: 'lb_forwardinhistory', builtinWidget: 'forwardInHistoryButton', title: 'Forward in history', icon: 'bx bxs-right-arrow-square', isVisible: false }, { id: 'lb_forwardinhistory', builtinWidget: 'forwardInHistoryButton', title: 'Forward in history', icon: 'bx bxs-right-arrow-square', isVisible: false },
]; ];
function createMissingSpecialNotes() { function createLaunchers() {
getSqlConsoleRoot();
getGlobalNoteMap();
getBulkActionNote();
createLauncherTemplates();
getLaunchBarRoot();
getLaunchBarAvailableLaunchersRoot();
getLaunchBarVisibleLaunchersRoot();
getShareRoot();
for (const launcher of launchers) { for (const launcher of launchers) {
let note = becca.getNote(launcher.id); let note = becca.getNote(launcher.id);
@ -402,14 +389,6 @@ function createMissingSpecialNotes() {
throw new Error(`No action defined for launcher ${JSON.stringify(launcher)}`); throw new Error(`No action defined for launcher ${JSON.stringify(launcher)}`);
} }
} }
// share root is not automatically created since it's visible in the tree and many won't need it/use it
const hidden = getHiddenRoot();
if (!hidden.hasOwnedLabel('excludeFromNoteMap')) {
hidden.addLabel('excludeFromNoteMap', "", true);
}
} }
function createLauncher(parentNoteId, launcherType) { function createLauncher(parentNoteId, launcherType) {
@ -461,6 +440,18 @@ function createLauncher(parentNoteId, launcherType) {
}; };
} }
function initHiddenRoot() {
const hidden = getHiddenRoot();
if (!hidden.hasOwnedLabel("docName")) {
hidden.addLabel("docName", "hidden");
}
if (!hidden.hasOwnedLabel('excludeFromNoteMap')) {
hidden.addLabel('excludeFromNoteMap', "", true);
}
}
function createLauncherTemplates() { function createLauncherTemplates() {
if (!(LBTPL_ROOT in becca.notes)) { if (!(LBTPL_ROOT in becca.notes)) {
noteService.createNewNote({ noteService.createNewNote({
@ -582,6 +573,49 @@ function createLauncherTemplates() {
} }
} }
const OPTIONS_ROOT = "opt_root";
const OPTIONS_APPEARANCE = "opt_appearance";
function createOptionNotes() {
if (!(OPTIONS_ROOT in becca.notes)) {
noteService.createNewNote({
branchId: OPTIONS_ROOT,
noteId: OPTIONS_ROOT,
title: 'Options',
type: 'doc',
content: '',
parentNoteId: getHiddenRoot().noteId
});
}
if (!(OPTIONS_APPEARANCE in becca.notes)) {
const note = noteService.createNewNote({
branchId: OPTIONS_APPEARANCE,
noteId: OPTIONS_APPEARANCE,
title: 'Appearance',
type: 'widget',
content: '',
parentNoteId: OPTIONS_ROOT
}).note;
note.addLabel('widget', 'optionsAppearance');
}
}
function createMissingSpecialNotes() {
initHiddenRoot();
getSqlConsoleRoot();
getGlobalNoteMap();
getBulkActionNote();
createLauncherTemplates();
getLaunchBarRoot();
getLaunchBarAvailableLaunchersRoot();
getLaunchBarVisibleLaunchersRoot();
createLaunchers();
createOptionNotes();
getShareRoot();
}
function resetLauncher(noteId) { function resetLauncher(noteId) {
if (noteId.startsWith('lb_')) { if (noteId.startsWith('lb_')) {
const note = becca.getNote(noteId); const note = becca.getNote(noteId);