quick unhoist link/button

This commit is contained in:
azivner 2018-12-15 20:29:08 +01:00
parent a680bb4612
commit 841420360e
6 changed files with 27 additions and 4 deletions

View file

@ -32,6 +32,7 @@ import tooltip from './tooltip.js';
import bundle from "./bundle.js";
import treeCache from "./tree_cache.js";
import libraryLoader from "./library_loader.js";
import hoistedNoteService from './hoisted_note.js';
// required for CKEditor image upload plugin
window.glob.getCurrentNode = treeService.getCurrentNode;
@ -84,6 +85,8 @@ $(document).on("click", "button[data-help-page]", e => {
$("#logout-button").toggle(!utils.isElectron());
$("#tree").on("click", ".unhoist-button", hoistedNoteService.unhoist);
if (utils.isElectron()) {
require('electron').ipcRenderer.on('create-day-sub-note', async function(event, parentNoteId) {
// this might occur when day note had to be created

View file

@ -22,7 +22,12 @@ async function setHoistedNoteId(noteId) {
await tree.reload();
}
async function unhoist() {
await setHoistedNoteId('root');
}
export default {
getHoistedNoteId,
setHoistedNoteId
setHoistedNoteId,
unhoist
}

View file

@ -122,7 +122,7 @@ async function activateNote(notePath, newNote) {
}
// unhoist so we can activate the note
await hoistedNoteService.setHoistedNoteId('root');
await hoistedNoteService.unhoist();
}
if (glob.activeDialog) {
@ -417,6 +417,15 @@ function initFancyTree(tree) {
},
clones: {
highlightActiveClones: true
},
renderNode: async function (event, data) {
const node = data.node;
if (node.data.noteId !== 'root' && node.data.noteId === await hoistedNoteService.getHoistedNoteId()) {
const unhoistButton = $('<span>&nbsp; (<a class="unhoist-button">unhoist</a>)</span>');
$(node.span).append(unhoistButton);
}
}
});

View file

@ -215,7 +215,7 @@ function selectContextMenuItem(event, cmd) {
hoistedNoteService.setHoistedNoteId(node.data.noteId);
}
else if (cmd === "unhoist") {
hoistedNoteService.setHoistedNoteId('root');
hoistedNoteService.unhoist();
}
else {
messagingService.logError("Unknown command: " + cmd);

View file

@ -117,7 +117,7 @@ const keyBindings = {
"ctrl+h": node => {
hoistedNoteService.getHoistedNoteId().then(hoistedNoteId => {
if (node.data.noteId === hoistedNoteId) {
hoistedNoteService.setHoistedNoteId('root');
hoistedNoteService.unhoist();
}
else {
hoistedNoteService.setHoistedNoteId(node.data.noteId);

View file

@ -698,4 +698,10 @@ div[data-notify="container"] {
#export-form .form-check-label {
padding: 2px;
}
.unhoist-button {
text-decoration: underline !important;
color: blue !important;
cursor: pointer !important;
}