mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
sync fix to prefix and some usability improvements
This commit is contained in:
parent
37a105db4d
commit
8b5988e13c
@ -6,10 +6,10 @@ const editTreePrefix = (function() {
|
|||||||
const treePrefixInputEl = $("#tree-prefix-input");
|
const treePrefixInputEl = $("#tree-prefix-input");
|
||||||
const noteTitleEl = $('#tree-prefix-note-title');
|
const noteTitleEl = $('#tree-prefix-note-title');
|
||||||
|
|
||||||
function showDialog() {
|
async function showDialog() {
|
||||||
glob.activeDialog = dialogEl;
|
glob.activeDialog = dialogEl;
|
||||||
|
|
||||||
dialogEl.dialog({
|
await dialogEl.dialog({
|
||||||
modal: true,
|
modal: true,
|
||||||
width: 800
|
width: 800
|
||||||
});
|
});
|
||||||
@ -36,6 +36,8 @@ const editTreePrefix = (function() {
|
|||||||
prefix: prefix
|
prefix: prefix
|
||||||
}),
|
}),
|
||||||
success: () => {
|
success: () => {
|
||||||
|
currentNode.data.prefix = prefix;
|
||||||
|
|
||||||
const noteTitle = noteTree.getNoteTitle(currentNode.data.note_id);
|
const noteTitle = noteTree.getNoteTitle(currentNode.data.note_id);
|
||||||
|
|
||||||
const title = (prefix ? (prefix + " - ") : "") + noteTitle;
|
const title = (prefix ? (prefix + " - ") : "") + noteTitle;
|
||||||
|
@ -346,6 +346,9 @@ const noteTree = (function() {
|
|||||||
if (toNode !== null) {
|
if (toNode !== null) {
|
||||||
treeChanges.moveToNode(node, toNode);
|
treeChanges.moveToNode(node, toNode);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"f2": node => {
|
||||||
|
editTreePrefix.showDialog();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ const auth = require('../../services/auth');
|
|||||||
const sql = require('../../services/sql');
|
const sql = require('../../services/sql');
|
||||||
const utils = require('../../services/utils');
|
const utils = require('../../services/utils');
|
||||||
const notes = require('../../services/notes');
|
const notes = require('../../services/notes');
|
||||||
|
const log = require('../../services/log');
|
||||||
const protected_session = require('../../services/protected_session');
|
const protected_session = require('../../services/protected_session');
|
||||||
const data_encryption = require('../../services/data_encryption');
|
const data_encryption = require('../../services/data_encryption');
|
||||||
const RequestContext = require('../../services/request_context');
|
const RequestContext = require('../../services/request_context');
|
||||||
@ -15,6 +16,12 @@ router.get('/:noteId', auth.checkApiAuth, async (req, res, next) => {
|
|||||||
|
|
||||||
const detail = await sql.getSingleResult("SELECT * FROM notes WHERE note_id = ?", [noteId]);
|
const detail = await sql.getSingleResult("SELECT * FROM notes WHERE note_id = ?", [noteId]);
|
||||||
|
|
||||||
|
if (!detail) {
|
||||||
|
log.info("Note " + noteId + " has not been found.");
|
||||||
|
|
||||||
|
return res.status(404).send({});
|
||||||
|
}
|
||||||
|
|
||||||
if (detail.is_protected) {
|
if (detail.is_protected) {
|
||||||
const dataKey = protected_session.getDataKey(req);
|
const dataKey = protected_session.getDataKey(req);
|
||||||
|
|
||||||
|
@ -50,10 +50,10 @@ router.put('/:noteId/protectSubTree/:isProtected', auth.checkApiAuth, async (req
|
|||||||
|
|
||||||
router.put('/:noteTreeId/setPrefix', auth.checkApiAuth, async (req, res, next) => {
|
router.put('/:noteTreeId/setPrefix', auth.checkApiAuth, async (req, res, next) => {
|
||||||
const noteTreeId = req.params.noteTreeId;
|
const noteTreeId = req.params.noteTreeId;
|
||||||
const prefix = req.body.prefix;
|
const prefix = utils.isEmptyOrWhitespace(req.body.prefix) ? null : req.body.prefix;
|
||||||
|
|
||||||
await sql.doInTransaction(async () => {
|
await sql.doInTransaction(async () => {
|
||||||
await sql.execute("UPDATE notes_tree SET prefix = ? WHERE note_tree_id = ?", [prefix, noteTreeId]);
|
await sql.execute("UPDATE notes_tree SET prefix = ?, date_modified = ? WHERE note_tree_id = ?", [prefix, utils.nowTimestamp(), noteTreeId]);
|
||||||
|
|
||||||
await sync_table.addNoteTreeSync(noteTreeId);
|
await sync_table.addNoteTreeSync(noteTreeId);
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,7 @@ async function getContentHash() {
|
|||||||
"is_deleted FROM notes ORDER BY note_id"));
|
"is_deleted FROM notes ORDER BY note_id"));
|
||||||
|
|
||||||
hash = updateHash(hash, await sql.getResults("SELECT note_tree_id, note_id, note_pid, note_pos, date_modified, " +
|
hash = updateHash(hash, await sql.getResults("SELECT note_tree_id, note_id, note_pid, note_pos, date_modified, " +
|
||||||
"is_deleted FROM notes_tree ORDER BY note_tree_id"));
|
"is_deleted, prefix FROM notes_tree ORDER BY note_tree_id"));
|
||||||
|
|
||||||
hash = updateHash(hash, await sql.getResults("SELECT note_history_id, note_id, note_title, note_text, " +
|
hash = updateHash(hash, await sql.getResults("SELECT note_history_id, note_id, note_title, note_text, " +
|
||||||
"date_modified_from, date_modified_to FROM notes_history ORDER BY note_history_id"));
|
"date_modified_from, date_modified_to FROM notes_history ORDER BY note_history_id"));
|
||||||
|
@ -11,6 +11,7 @@ async function createNewNote(parentNoteId, note) {
|
|||||||
|
|
||||||
let newNotePos = 0;
|
let newNotePos = 0;
|
||||||
|
|
||||||
|
await sql.doInTransaction(async () => {
|
||||||
if (note.target === 'into') {
|
if (note.target === 'into') {
|
||||||
const maxNotePos = await sql.getSingleValue('SELECT MAX(note_pos) FROM notes_tree WHERE note_pid = ? AND is_deleted = 0', [parentNoteId]);
|
const maxNotePos = await sql.getSingleValue('SELECT MAX(note_pos) FROM notes_tree WHERE note_pid = ? AND is_deleted = 0', [parentNoteId]);
|
||||||
|
|
||||||
@ -28,7 +29,6 @@ async function createNewNote(parentNoteId, note) {
|
|||||||
throw new Error('Unknown target: ' + note.target);
|
throw new Error('Unknown target: ' + note.target);
|
||||||
}
|
}
|
||||||
|
|
||||||
await sql.doInTransaction(async () => {
|
|
||||||
await sync_table.addNoteTreeSync(noteTreeId);
|
await sync_table.addNoteTreeSync(noteTreeId);
|
||||||
await sync_table.addNoteSync(noteId);
|
await sync_table.addNoteSync(noteId);
|
||||||
|
|
||||||
|
@ -66,6 +66,10 @@ function hash(text) {
|
|||||||
return crypto.createHash('sha1').update(text).digest('base64');
|
return crypto.createHash('sha1').update(text).digest('base64');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isEmptyOrWhitespace(str) {
|
||||||
|
return str === null || str.match(/^ *$/) !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
randomSecureToken,
|
randomSecureToken,
|
||||||
@ -79,5 +83,6 @@ module.exports = {
|
|||||||
hmac,
|
hmac,
|
||||||
isElectron,
|
isElectron,
|
||||||
formatTwoTimestamps,
|
formatTwoTimestamps,
|
||||||
hash
|
hash,
|
||||||
|
isEmptyOrWhitespace
|
||||||
};
|
};
|
@ -326,7 +326,6 @@
|
|||||||
<script src="javascripts/dialogs/edit_tree_prefix.js"></script>
|
<script src="javascripts/dialogs/edit_tree_prefix.js"></script>
|
||||||
|
|
||||||
<script src="javascripts/link.js"></script>
|
<script src="javascripts/link.js"></script>
|
||||||
<script src="javascripts/status.js"></script>
|
|
||||||
<script src="javascripts/sync.js"></script>
|
<script src="javascripts/sync.js"></script>
|
||||||
<script src="javascripts/utils.js"></script>
|
<script src="javascripts/utils.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user