mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
#129, removed recent notes dialog as its not necessary anymore
This commit is contained in:
parent
f578e001b0
commit
e4f459fa2b
@ -14,7 +14,8 @@ async function showDialog() {
|
|||||||
|
|
||||||
$dialog.dialog({
|
$dialog.dialog({
|
||||||
modal: true,
|
modal: true,
|
||||||
width: 800
|
width: 800,
|
||||||
|
position: { my: "center top+100", at: "top", of: window }
|
||||||
});
|
});
|
||||||
|
|
||||||
await $autoComplete.autocomplete({
|
await $autoComplete.autocomplete({
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
import treeService from '../services/tree.js';
|
|
||||||
import server from '../services/server.js';
|
|
||||||
|
|
||||||
const $dialog = $("#recent-notes-dialog");
|
|
||||||
const $searchInput = $('#recent-notes-search-input');
|
|
||||||
|
|
||||||
function addRecentNote(branchId, notePath) {
|
|
||||||
setTimeout(async () => {
|
|
||||||
// we include the note into recent list only if the user stayed on the note at least 5 seconds
|
|
||||||
if (notePath && notePath === treeService.getCurrentNotePath()) {
|
|
||||||
const result = await server.put('recent-notes/' + branchId + '/' + encodeURIComponent(notePath));
|
|
||||||
}
|
|
||||||
}, 1500);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function showDialog() {
|
|
||||||
glob.activeDialog = $dialog;
|
|
||||||
|
|
||||||
$dialog.dialog({
|
|
||||||
modal: true,
|
|
||||||
width: 800,
|
|
||||||
height: 100,
|
|
||||||
position: { my: "center top+100", at: "top", of: window }
|
|
||||||
});
|
|
||||||
|
|
||||||
$searchInput.val('');
|
|
||||||
|
|
||||||
const result = await server.get('recent-notes');
|
|
||||||
|
|
||||||
// remove the current note
|
|
||||||
const recNotes = result.filter(note => note.notePath !== treeService.getCurrentNotePath());
|
|
||||||
|
|
||||||
const items = recNotes.map(rn => {
|
|
||||||
return {
|
|
||||||
label: rn.title,
|
|
||||||
value: rn.notePath
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
$searchInput.autocomplete({
|
|
||||||
source: items,
|
|
||||||
minLength: 0,
|
|
||||||
autoFocus: true,
|
|
||||||
select: function (event, ui) {
|
|
||||||
treeService.activateNode(ui.item.value);
|
|
||||||
|
|
||||||
$searchInput.autocomplete('destroy');
|
|
||||||
$dialog.dialog('close');
|
|
||||||
},
|
|
||||||
focus: function (event, ui) {
|
|
||||||
event.preventDefault();
|
|
||||||
},
|
|
||||||
close: function (event, ui) {
|
|
||||||
if (event.keyCode === 27) { // escape closes dialog
|
|
||||||
$searchInput.autocomplete('destroy');
|
|
||||||
$dialog.dialog('close');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// keep autocomplete open
|
|
||||||
// we're kind of abusing autocomplete to work in a way which it's not designed for
|
|
||||||
$searchInput.autocomplete("search", "");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
create: () => $searchInput.autocomplete("search", ""),
|
|
||||||
classes: {
|
|
||||||
"ui-autocomplete": "recent-notes-autocomplete"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
showDialog,
|
|
||||||
addRecentNote
|
|
||||||
};
|
|
1
src/public/javascripts/services/bootstrap.js
vendored
1
src/public/javascripts/services/bootstrap.js
vendored
@ -4,7 +4,6 @@ import labelsDialog from '../dialogs/labels.js';
|
|||||||
import noteRevisionsDialog from '../dialogs/note_revisions.js';
|
import noteRevisionsDialog from '../dialogs/note_revisions.js';
|
||||||
import noteSourceDialog from '../dialogs/note_source.js';
|
import noteSourceDialog from '../dialogs/note_source.js';
|
||||||
import recentChangesDialog from '../dialogs/recent_changes.js';
|
import recentChangesDialog from '../dialogs/recent_changes.js';
|
||||||
import recentNotesDialog from '../dialogs/recent_notes.js';
|
|
||||||
import optionsDialog from '../dialogs/options.js';
|
import optionsDialog from '../dialogs/options.js';
|
||||||
import sqlConsoleDialog from '../dialogs/sql_console.js';
|
import sqlConsoleDialog from '../dialogs/sql_console.js';
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import zoomService from "./zoom.js";
|
|||||||
import noteRevisionsDialog from "../dialogs/note_revisions.js";
|
import noteRevisionsDialog from "../dialogs/note_revisions.js";
|
||||||
import optionsDialog from "../dialogs/options.js";
|
import optionsDialog from "../dialogs/options.js";
|
||||||
import addLinkDialog from "../dialogs/add_link.js";
|
import addLinkDialog from "../dialogs/add_link.js";
|
||||||
import recentNotesDialog from "../dialogs/recent_notes.js";
|
|
||||||
import jumpToNoteDialog from "../dialogs/jump_to_note.js";
|
import jumpToNoteDialog from "../dialogs/jump_to_note.js";
|
||||||
import noteSourceDialog from "../dialogs/note_source.js";
|
import noteSourceDialog from "../dialogs/note_source.js";
|
||||||
import recentChangesDialog from "../dialogs/recent_changes.js";
|
import recentChangesDialog from "../dialogs/recent_changes.js";
|
||||||
@ -35,9 +34,6 @@ function registerEntrypoints() {
|
|||||||
$("#protected-session-on").click(protectedSessionService.enterProtectedSession);
|
$("#protected-session-on").click(protectedSessionService.enterProtectedSession);
|
||||||
$("#protected-session-off").click(protectedSessionService.leaveProtectedSession);
|
$("#protected-session-off").click(protectedSessionService.leaveProtectedSession);
|
||||||
|
|
||||||
$("#recent-notes-button").click(recentNotesDialog.showDialog);
|
|
||||||
utils.bindShortcut('ctrl+e', recentNotesDialog.showDialog);
|
|
||||||
|
|
||||||
$("#toggle-search-button").click(searchNotesService.toggleSearch);
|
$("#toggle-search-button").click(searchNotesService.toggleSearch);
|
||||||
utils.bindShortcut('ctrl+s', searchNotesService.toggleSearch);
|
utils.bindShortcut('ctrl+s', searchNotesService.toggleSearch);
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import treeChangesService from './branches.js';
|
|||||||
import treeUtils from './tree_utils.js';
|
import treeUtils from './tree_utils.js';
|
||||||
import utils from './utils.js';
|
import utils from './utils.js';
|
||||||
import server from './server.js';
|
import server from './server.js';
|
||||||
import recentNotesDialog from '../dialogs/recent_notes.js';
|
|
||||||
import treeCache from './tree_cache.js';
|
import treeCache from './tree_cache.js';
|
||||||
import infoService from "./info.js";
|
import infoService from "./info.js";
|
||||||
import treeBuilder from "./tree_builder.js";
|
import treeBuilder from "./tree_builder.js";
|
||||||
@ -239,6 +238,15 @@ async function setExpandedToServer(branchId, isExpanded) {
|
|||||||
await server.put('branches/' + branchId + '/expanded/' + expandedNum);
|
await server.put('branches/' + branchId + '/expanded/' + expandedNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addRecentNote(branchId, notePath) {
|
||||||
|
setTimeout(async () => {
|
||||||
|
// we include the note into recent list only if the user stayed on the note at least 5 seconds
|
||||||
|
if (notePath && notePath === getCurrentNotePath()) {
|
||||||
|
await server.put('recent-notes/' + branchId + '/' + encodeURIComponent(notePath));
|
||||||
|
}
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
|
||||||
function setCurrentNotePathToHash(node) {
|
function setCurrentNotePathToHash(node) {
|
||||||
utils.assertArguments(node);
|
utils.assertArguments(node);
|
||||||
|
|
||||||
@ -247,7 +255,7 @@ function setCurrentNotePathToHash(node) {
|
|||||||
|
|
||||||
document.location.hash = currentNotePath;
|
document.location.hash = currentNotePath;
|
||||||
|
|
||||||
recentNotesDialog.addRecentNote(currentBranchId, currentNotePath);
|
addRecentNote(currentBranchId, currentNotePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelectedNodes(stopOnParents = false) {
|
function getSelectedNodes(stopOnParents = false) {
|
||||||
|
@ -1,30 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const repository = require('../../services/repository');
|
|
||||||
const optionService = require('../../services/options');
|
const optionService = require('../../services/options');
|
||||||
const RecentNote = require('../../entities/recent_note');
|
const RecentNote = require('../../entities/recent_note');
|
||||||
const noteCacheService = require('../../services/note_cache');
|
|
||||||
|
|
||||||
async function getRecentNotes() {
|
|
||||||
const recentNotes = await repository.getEntities(`
|
|
||||||
SELECT
|
|
||||||
recent_notes.*
|
|
||||||
FROM
|
|
||||||
recent_notes
|
|
||||||
JOIN branches USING(branchId)
|
|
||||||
WHERE
|
|
||||||
recent_notes.isDeleted = 0
|
|
||||||
AND branches.isDeleted = 0
|
|
||||||
ORDER BY
|
|
||||||
dateCreated DESC
|
|
||||||
LIMIT 200`);
|
|
||||||
|
|
||||||
for (const rn of recentNotes) {
|
|
||||||
rn.title = noteCacheService.getNoteTitleForPath(rn.notePath.split('/'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return recentNotes;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function addRecentNote(req) {
|
async function addRecentNote(req) {
|
||||||
const branchId = req.params.branchId;
|
const branchId = req.params.branchId;
|
||||||
@ -36,11 +13,8 @@ async function addRecentNote(req) {
|
|||||||
}).save();
|
}).save();
|
||||||
|
|
||||||
await optionService.setOption('startNotePath', notePath);
|
await optionService.setOption('startNotePath', notePath);
|
||||||
|
|
||||||
return await getRecentNotes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getRecentNotes,
|
|
||||||
addRecentNote
|
addRecentNote
|
||||||
};
|
};
|
@ -161,7 +161,6 @@ function register(app) {
|
|||||||
|
|
||||||
apiRoute(GET, '/api/event-log', eventLogRoute.getEventLog);
|
apiRoute(GET, '/api/event-log', eventLogRoute.getEventLog);
|
||||||
|
|
||||||
apiRoute(GET, '/api/recent-notes', recentNotesRoute.getRecentNotes);
|
|
||||||
apiRoute(PUT, '/api/recent-notes/:branchId/:notePath', recentNotesRoute.addRecentNote);
|
apiRoute(PUT, '/api/recent-notes/:branchId/:notePath', recentNotesRoute.addRecentNote);
|
||||||
apiRoute(GET, '/api/app-info', appInfoRoute.getAppInfo);
|
apiRoute(GET, '/api/app-info', appInfoRoute.getAppInfo);
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
<div style="flex-grow: 100; display: flex;">
|
<div style="flex-grow: 100; display: flex;">
|
||||||
<button class="btn btn-xs" id="jump-to-note-dialog-button" title="CTRL+J">Jump to note</button>
|
<button class="btn btn-xs" id="jump-to-note-dialog-button" title="CTRL+J">Jump to note</button>
|
||||||
<button class="btn btn-xs" id="recent-notes-button" title="CTRL+E">Recent notes</button>
|
|
||||||
<button class="btn btn-xs" id="recent-changes-button">Recent changes</button>
|
<button class="btn btn-xs" id="recent-changes-button">Recent changes</button>
|
||||||
<div>
|
<div>
|
||||||
<span style="font-size: smaller">Protected session:</span>
|
<span style="font-size: smaller">Protected session:</span>
|
||||||
@ -262,10 +261,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="recent-notes-dialog" title="Recent notes" style="display: none;">
|
|
||||||
<input id="recent-notes-search-input" class="form-control"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="add-link-dialog" title="Add note link" style="display: none;">
|
<div id="add-link-dialog" title="Add note link" style="display: none;">
|
||||||
<form id="add-link-form">
|
<form id="add-link-form">
|
||||||
<div id="add-link-type-div" class="radio">
|
<div id="add-link-type-div" class="radio">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user