buttons on the left

This commit is contained in:
zadam 2021-05-18 22:14:35 +02:00
parent d18b95d87c
commit 845f5d15c4
7 changed files with 130 additions and 10 deletions

View file

@ -38,6 +38,8 @@ import RootContainer from "../widgets/containers/root_container.js";
import NoteUpdateStatusWidget from "../widgets/note_update_status.js";
import SpacerWidget from "../widgets/spacer.js";
import QuickSearchWidget from "../widgets/quick_search.js";
import ButtonWidget from "../widgets/button_widget.js";
import ProtectedSessionStatusWidget from "../widgets/protected_session_status.js";
const RIGHT_PANE_CSS = `
<style>
@ -141,6 +143,29 @@ export default class DesktopLayout {
return new RootContainer()
.setParent(appContext)
.child(new FlexContainer("column")
.child(new GlobalMenuWidget())
.child(new ButtonWidget()
.icon("bx-file-blank")
.title("New note")
.command("createNoteIntoInbox"))
.child(new ButtonWidget()
.icon("bx-search")
.title("Search")
.command("searchNotes"))
.child(new ButtonWidget()
.icon("bx-send")
.title("Jump to note")
.command("jumpToNote"))
.child(new ButtonWidget()
.icon("bx-history")
.title("Show recent changes")
.command("showRecentChanges"))
.child(new SpacerWidget())
.child(new ProtectedSessionStatusWidget())
.child(new SyncStatusWidget())
.css("width", "50px")
)
.child(new SidePaneContainer('left')
.hideInZenMode()
.css("width", "300px")
@ -152,16 +177,10 @@ export default class DesktopLayout {
.id('center-pane')
.css("flex-grow", "1")
.child(new FlexContainer('row').overflowing()
.filling()
.child(new GlobalMenuWidget())
.child(new SyncStatusWidget())
.child(new SpacerWidget())
.child(new TabRowWidget())
.child(new TitleBarButtonsWidget())
.css('height', '36px')
)
.child(new FlexContainer('row').overflowing()
.child(new TabRowWidget())
)
.child(new FlexContainer('row').class('title-row')
.css('align-items: center;')
.cssBlock('.title-row > * { margin: 5px; }')

View file

@ -3,6 +3,7 @@ import appContext from "./app_context.js";
import dateNoteService from "../services/date_notes.js";
import treeService from "../services/tree.js";
import openService from "./open.js";
import protectedSessionService from "./protected_session.js";
export default class RootCommandExecutor extends Component {
jumpToNoteCommand() {
@ -93,4 +94,12 @@ export default class RootCommandExecutor extends Component {
openService.openNoteExternally(noteId);
}
}
enterProtectedSessionCommand() {
protectedSessionService.enterProtectedSession();
}
leaveProtectedSessionCommand() {
protectedSessionService.leaveProtectedSession();
}
}

View file

@ -0,0 +1,49 @@
import BasicWidget from "./basic_widget.js";
const TPL = `
<span class="button-widget"
title="">
<span class="bx"></span>
</span>
`;
export default class ButtonWidget extends BasicWidget {
constructor() {
super();
this.options = {};
}
doRender() {
this.$widget = $(TPL);
this.refreshIcon();
this.overflowing();
this.$widget.on("click", () => this.triggerCommand(this.options.command));
super.doRender();
}
refreshIcon() {
this.$widget.attr("title", this.options.title);
this.$widget.find("span.bx")
.removeClass()
.addClass("bx")
.addClass(this.options.icon);
}
icon(icon) {
this.options.icon = icon;
return this;
}
title(title) {
this.options.title = title;
return this;
}
command(command) {
this.options.command = command;
return this;
}
}

View file

@ -0,0 +1,33 @@
import ButtonWidget from "./button_widget.js";
import protectedSessionHolder from "../services/protected_session_holder.js";
export default class ProtectedSessionStatusWidget extends ButtonWidget {
constructor() {
super();
}
doRender() {
this.updateOptions();
super.doRender();
}
updateOptions() {
this.options.icon = protectedSessionHolder.isProtectedSessionAvailable()
? "bx-shield-quarter"
: "bx-log-in";
this.options.title = protectedSessionHolder.isProtectedSessionAvailable()
? "Protected session is active. Click to leave protected session."
: "Click to enter protected session";
this.options.command = protectedSessionHolder.isProtectedSessionAvailable()
? "leaveProtectedSession"
: "enterProtectedSession";
}
protectedSessionStartedEvent() {
this.updateOptions();
this.refreshIcon();
}
}

View file

@ -928,3 +928,15 @@ ul.fancytree-container li {
padding: 10px;
margin: 10px;
}
.button-widget .bx {
font-size: 180%;
display: inline-block;
position: relative;
padding: 10px;
cursor: pointer;
}
.button-widget:hover .bx {
background-color: var(--hover-item-background-color);
}

View file

@ -16,7 +16,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {
collectedNoteIds.add(note.noteId);
for (const branch of note.parentBranches) {
for (const branch of note.getParentBranches()) {
collectedBranchIds.add(branch.branchId);
collectEntityIds(branch.parentNote);

View file

@ -153,8 +153,6 @@ function findResultsWithQuery(query, searchContext) {
const expression = parseQueryToExpression(query, searchContext);
console.log("expression", expression);
if (!expression) {
return [];
}