mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
option to erase notes immediately
This commit is contained in:
parent
9b9be5d155
commit
0448883782
6
libraries/force-graph.min.js
vendored
6
libraries/force-graph.min.js
vendored
File diff suppressed because one or more lines are too long
12
package-lock.json
generated
12
package-lock.json
generated
@ -2890,9 +2890,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"electron": {
|
"electron": {
|
||||||
"version": "13.3.0",
|
"version": "13.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-13.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/electron/-/electron-13.4.0.tgz",
|
||||||
"integrity": "sha512-d/BvOLDjI4i7yf9tqCuLL2fFGA2TrM/D9PyRpua+rJolG0qrwp/FohP02L0m+44kmPpofIo4l3NPwLmzyKKimA==",
|
"integrity": "sha512-KJGWS2qa0xZXIMPMDUNkRVO8/JxRd4+M0ejYYOzu2LIQ5ijecPzNuNR9nvDkml9XyyRBzu975FkhJcwD17ietQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@electron/get": "^1.0.1",
|
"@electron/get": "^1.0.1",
|
||||||
@ -6873,9 +6873,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sanitize-html": {
|
"sanitize-html": {
|
||||||
"version": "2.5.0",
|
"version": "2.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.5.1.tgz",
|
||||||
"integrity": "sha512-smU67ODza8E0rJF7oY37qQqMF5srxwEkqsgV17PFfdYAtIxnicH8LIyDEGINJIso8bPaxRZS7zGhCjg6BeDoqQ==",
|
"integrity": "sha512-hUITPitQk+eFNLtr4dEkaaiAJndG2YE87IOpcfBSL1XdklWgwcNDJdr9Ppe8QKL/C3jFt1xH/Mbj20e0GZQOfg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"deepmerge": "^4.2.2",
|
"deepmerge": "^4.2.2",
|
||||||
"escape-string-regexp": "^4.0.0",
|
"escape-string-regexp": "^4.0.0",
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"sanitize-filename": "1.6.3",
|
"sanitize-filename": "1.6.3",
|
||||||
"sanitize-html": "2.5.0",
|
"sanitize-html": "2.5.1",
|
||||||
"sax": "1.2.4",
|
"sax": "1.2.4",
|
||||||
"semver": "7.3.5",
|
"semver": "7.3.5",
|
||||||
"serve-favicon": "2.5.0",
|
"serve-favicon": "2.5.0",
|
||||||
@ -81,7 +81,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"electron": "13.3.0",
|
"electron": "13.4.0",
|
||||||
"electron-builder": "22.11.7",
|
"electron-builder": "22.11.7",
|
||||||
"electron-packager": "15.4.0",
|
"electron-packager": "15.4.0",
|
||||||
"electron-rebuild": "3.2.3",
|
"electron-rebuild": "3.2.3",
|
||||||
|
@ -14,6 +14,7 @@ const $deleteNotesListWrapper = $("#delete-notes-list-wrapper");
|
|||||||
const $brokenRelationsListWrapper = $("#broken-relations-wrapper");
|
const $brokenRelationsListWrapper = $("#broken-relations-wrapper");
|
||||||
const $brokenRelationsCount = $("#broke-relations-count");
|
const $brokenRelationsCount = $("#broke-relations-count");
|
||||||
const $deleteAllClones = $("#delete-all-clones");
|
const $deleteAllClones = $("#delete-all-clones");
|
||||||
|
const $eraseNotes = $("#erase-notes");
|
||||||
|
|
||||||
let branchIds = null;
|
let branchIds = null;
|
||||||
let resolve = null;
|
let resolve = null;
|
||||||
@ -63,6 +64,9 @@ export async function showDialog(branchIdsToDelete) {
|
|||||||
|
|
||||||
utils.openDialog($dialog);
|
utils.openDialog($dialog);
|
||||||
|
|
||||||
|
$deleteAllClones.prop("checked", false);
|
||||||
|
$eraseNotes.prop("checked", false);
|
||||||
|
|
||||||
return new Promise((res, rej) => resolve = res);
|
return new Promise((res, rej) => resolve = res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +74,10 @@ export function isDeleteAllClonesChecked() {
|
|||||||
return $deleteAllClones.is(":checked");
|
return $deleteAllClones.is(":checked");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isEraseNotesChecked() {
|
||||||
|
return $eraseNotes.is(":checked");
|
||||||
|
}
|
||||||
|
|
||||||
$dialog.on('shown.bs.modal', () => $okButton.trigger("focus"));
|
$dialog.on('shown.bs.modal', () => $okButton.trigger("focus"));
|
||||||
|
|
||||||
$cancelButton.on('click', () => {
|
$cancelButton.on('click', () => {
|
||||||
@ -83,7 +91,8 @@ $okButton.on('click', () => {
|
|||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
proceed: true,
|
proceed: true,
|
||||||
deleteAllClones: isDeleteAllClonesChecked()
|
deleteAllClones: isDeleteAllClonesChecked(),
|
||||||
|
eraseNotes: isEraseNotesChecked()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ async function deleteNotes(branchIdsToDelete) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let proceed, deleteAllClones;
|
let proceed, deleteAllClones, eraseNotes;
|
||||||
|
|
||||||
if (utils.isMobile()) {
|
if (utils.isMobile()) {
|
||||||
proceed = true;
|
proceed = true;
|
||||||
@ -82,7 +82,7 @@ async function deleteNotes(branchIdsToDelete) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const deleteNotesDialog = await import("../dialogs/delete_notes.js");
|
const deleteNotesDialog = await import("../dialogs/delete_notes.js");
|
||||||
({proceed, deleteAllClones} = await deleteNotesDialog.showDialog(branchIdsToDelete));
|
({proceed, deleteAllClones, eraseNotes} = await deleteNotesDialog.showDialog(branchIdsToDelete));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!proceed) {
|
if (!proceed) {
|
||||||
@ -97,7 +97,7 @@ async function deleteNotes(branchIdsToDelete) {
|
|||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
const last = counter === branchIdsToDelete.length;
|
const last = counter === branchIdsToDelete.length;
|
||||||
const query = `?taskId=${taskId}&last=${last ? 'true' : 'false'}`;
|
const query = `?taskId=${taskId}&eraseNotes=${eraseNotes ? 'true' : 'false'}&last=${last ? 'true' : 'false'}`;
|
||||||
|
|
||||||
const branch = froca.getBranch(branchIdToDelete);
|
const branch = froca.getBranch(branchIdToDelete);
|
||||||
|
|
||||||
|
@ -205,12 +205,17 @@ function setExpandedForSubtree(req) {
|
|||||||
|
|
||||||
function deleteBranch(req) {
|
function deleteBranch(req) {
|
||||||
const last = req.query.last === 'true';
|
const last = req.query.last === 'true';
|
||||||
|
const eraseNotes = req.query.eraseNotes === 'true';
|
||||||
const branch = becca.getBranch(req.params.branchId);
|
const branch = becca.getBranch(req.params.branchId);
|
||||||
const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');
|
const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');
|
||||||
|
|
||||||
const deleteId = utils.randomString(10);
|
const deleteId = utils.randomString(10);
|
||||||
const noteDeleted = noteService.deleteBranch(branch, deleteId, taskContext);
|
const noteDeleted = noteService.deleteBranch(branch, deleteId, taskContext);
|
||||||
|
|
||||||
|
if (eraseNotes) {
|
||||||
|
noteService.eraseNotesWithDeleteId(deleteId);
|
||||||
|
}
|
||||||
|
|
||||||
if (last) {
|
if (last) {
|
||||||
taskContext.taskSucceeded();
|
taskContext.taskSucceeded();
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,22 @@ function getSearchRoot() {
|
|||||||
return searchRoot;
|
return searchRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSpecialNoteRoot() {
|
||||||
|
let specialNoteRoot = becca.getNote('special');
|
||||||
|
|
||||||
|
if (!specialNoteRoot) {
|
||||||
|
specialNoteRoot = noteService.createNewNote({
|
||||||
|
noteId: 'special',
|
||||||
|
title: 'special',
|
||||||
|
type: 'text',
|
||||||
|
content: '',
|
||||||
|
parentNoteId: getHiddenRoot().noteId
|
||||||
|
}).note;
|
||||||
|
}
|
||||||
|
|
||||||
|
return specialNoteRoot;
|
||||||
|
}
|
||||||
|
|
||||||
function getSqlConsoleRoot() {
|
function getSqlConsoleRoot() {
|
||||||
let sqlConsoleRoot = becca.getNote('sqlconsole');
|
let sqlConsoleRoot = becca.getNote('sqlconsole');
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ function updateNote(req) {
|
|||||||
function deleteNote(req) {
|
function deleteNote(req) {
|
||||||
const noteId = req.params.noteId;
|
const noteId = req.params.noteId;
|
||||||
const taskId = req.query.taskId;
|
const taskId = req.query.taskId;
|
||||||
|
const eraseNotes = req.query.eraseNotes === 'true';
|
||||||
const last = req.query.last === 'true';
|
const last = req.query.last === 'true';
|
||||||
|
|
||||||
// note how deleteId is separate from taskId - single taskId produces separate deleteId for each "top level" deleted note
|
// note how deleteId is separate from taskId - single taskId produces separate deleteId for each "top level" deleted note
|
||||||
@ -76,6 +77,10 @@ function deleteNote(req) {
|
|||||||
noteService.deleteBranch(branch, deleteId, taskContext);
|
noteService.deleteBranch(branch, deleteId, taskContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (eraseNotes) {
|
||||||
|
noteService.eraseNotesWithDeleteId(deleteId);
|
||||||
|
}
|
||||||
|
|
||||||
if (last) {
|
if (last) {
|
||||||
taskContext.taskSucceeded();
|
taskContext.taskSucceeded();
|
||||||
}
|
}
|
||||||
|
@ -743,6 +743,20 @@ function eraseDeletedEntities(eraseEntitiesAfterTimeInSeconds = null) {
|
|||||||
eraseAttributes(attributeIdsToErase);
|
eraseAttributes(attributeIdsToErase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function eraseNotesWithDeleteId(deleteId) {
|
||||||
|
const noteIdsToErase = sql.getColumn("SELECT noteId FROM notes WHERE deleteId = ?", [deleteId]);
|
||||||
|
|
||||||
|
eraseNotes(noteIdsToErase);
|
||||||
|
|
||||||
|
const branchIdsToErase = sql.getColumn("SELECT branchId FROM branches WHERE deleteId = ?", [deleteId]);
|
||||||
|
|
||||||
|
eraseBranches(branchIdsToErase);
|
||||||
|
|
||||||
|
const attributeIdsToErase = sql.getColumn("SELECT attributeId FROM attributes WHERE deleteId = ?", [deleteId]);
|
||||||
|
|
||||||
|
eraseAttributes(attributeIdsToErase);
|
||||||
|
}
|
||||||
|
|
||||||
function eraseDeletedNotesNow() {
|
function eraseDeletedNotesNow() {
|
||||||
eraseDeletedEntities(0);
|
eraseDeletedEntities(0);
|
||||||
}
|
}
|
||||||
@ -885,5 +899,6 @@ module.exports = {
|
|||||||
duplicateSubtreeWithoutRoot,
|
duplicateSubtreeWithoutRoot,
|
||||||
getUndeletedParentBranchIds,
|
getUndeletedParentBranchIds,
|
||||||
triggerNoteTitleChanged,
|
triggerNoteTitleChanged,
|
||||||
eraseDeletedNotesNow
|
eraseDeletedNotesNow,
|
||||||
|
eraseNotesWithDeleteId
|
||||||
};
|
};
|
||||||
|
@ -17,6 +17,14 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="checkbox">
|
||||||
|
<label data-toggle="tooltip" title="Normal (soft) deletion only marks the notes as deleted and they can be undeleted (in recent changes dialog) within a period of time. Checking this option will erase the notes immediatelly and it won't be possible to undelete the notes.">
|
||||||
|
<input id="erase-notes" value="1" type="checkbox">
|
||||||
|
|
||||||
|
erase notes permanently (can't be undone)
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="delete-notes-list-wrapper">
|
<div id="delete-notes-list-wrapper">
|
||||||
<h4>Following notes will be deleted (<span id="deleted-notes-count"></span>)</h4>
|
<h4>Following notes will be deleted (<span id="deleted-notes-count"></span>)</h4>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user