mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-01-19 11:39:46 -06:00
global actions context menu, logout
This commit is contained in:
@@ -6,8 +6,6 @@ function initContextMenu(event, itemContainer, selectContextMenuItem) {
|
||||
$contextMenuContainer.empty();
|
||||
|
||||
for (const item of itemContainer.getItems()) {
|
||||
console.log("Adding " + item.title);
|
||||
|
||||
if (item.title === '----') {
|
||||
$contextMenuContainer.append($("<div>").addClass("dropdown-divider"));
|
||||
} else {
|
||||
|
||||
@@ -90,21 +90,36 @@ $("#note-menu-button").click(async e => {
|
||||
|
||||
itemsContainer.enableItem("delete", isNotRoot && parentNote.type !== 'search');
|
||||
|
||||
contextMenuWidget.initContextMenu(e, itemsContainer, noteContextMenuHandler);
|
||||
contextMenuWidget.initContextMenu(e, itemsContainer, (event, cmd) => {
|
||||
if (cmd === "delete") {
|
||||
treeChangesService.deleteNodes([node]);
|
||||
|
||||
// move to the tree
|
||||
togglePanes();
|
||||
}
|
||||
else {
|
||||
throw new Error("Unrecognized command " + cmd);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
async function noteContextMenuHandler(event, cmd) {
|
||||
const node = treeService.getCurrentNode();
|
||||
$("#global-actions-button").click(async e => {
|
||||
const itemsContainer = new ContextMenuItemsContainer([
|
||||
{title: "Switch to desktop version", cmd: "switch-to-desktop", uiIcon: "computer"},
|
||||
{title: "Logout", cmd: "log-out", uiIcon: "log-out"}
|
||||
]);
|
||||
|
||||
if (cmd === "delete") {
|
||||
treeChangesService.deleteNodes([node]);
|
||||
|
||||
// move to the tree
|
||||
togglePanes();
|
||||
}
|
||||
else {
|
||||
throw new Error("Unrecognized command " + cmd);
|
||||
}
|
||||
}
|
||||
contextMenuWidget.initContextMenu(e, itemsContainer, (event, cmd) => {
|
||||
if (cmd === "switch-to-desktop") {
|
||||
alert("switch to desktop");
|
||||
}
|
||||
else if (cmd === 'log-out') {
|
||||
$("#logout-form").submit();
|
||||
}
|
||||
else {
|
||||
throw new Error("Unrecognized command " + cmd);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
showTree();
|
||||
Reference in New Issue
Block a user