Skip to content

Build your personal knowledge base with Trilium Notes

fixed confirmDeleteNoteBoxWithNote

zadamc5bc23d511ba
diff --git a/src/public/app/widgets/dialog.js b/src/public/app/widgets/dialog.js
index ef259e7483..7c7b935a92 100644
--- a/src/public/app/widgets/dialog.js
+++ b/src/public/app/widgets/dialog.js
@@ -7,7 +7,15 @@ async function info(message) {
async function confirm(message) {
return new Promise(res =>
- appContext.triggerCommand("showConfirmDialog", {message, callback: res}));
+ appContext.triggerCommand("showConfirmDialog", {
+ message,
+ callback: x => res(x.confirmed)
+ }));
+}
+
+async function confirmDeleteNoteBoxWithNote(title) {
+ return new Promise(res =>
+ appContext.triggerCommand("showConfirmDeleteNoteBoxWithNoteDialog", {title, callback: res}));
}
async function prompt(props) {
@@ -18,5 +26,6 @@ async function prompt(props) {
export default {
info,
confirm,
+ confirmDeleteNoteBoxWithNote,
prompt
};
diff --git a/src/public/app/widgets/dialogs/confirm.js b/src/public/app/widgets/dialogs/confirm.js
index 7f8dc64805..354d95b076 100644
--- a/src/public/app/widgets/dialogs/confirm.js
+++ b/src/public/app/widgets/dialogs/confirm.js
@@ -79,22 +79,27 @@ export default class ConfirmDialog extends BasicWidget {
this.resolve = callback;
}
- confirmDeleteNoteBoxWithNoteEvent({title, callback}) {
+ showConfirmDeleteNoteBoxWithNoteDialogEvent({title, callback}) {
glob.activeDialog = this.$widget;
this.$confirmContent.text(`Are you sure you want to remove the note "${title}" from relation map?`);
this.$custom.empty()
.append("<br/>")
- .append($("<div>").addClass("form-check")
- .append($("<label>")
- .addClass("form-check-label")
- .attr("style", "text-decoration: underline dotted black")
- .attr("title", "If you don't check this, note will be only removed from relation map, but will stay as a note.")
- .append($("<input>")
- .attr("type", "checkbox")
- .addClass("form-check-input " + DELETE_NOTE_BUTTON_CLASS))
- .text("Also delete note")));
+ .append($("<div>")
+ .addClass("form-check")
+ .append(
+ $("<label>")
+ .addClass("form-check-label")
+ .attr("style", "text-decoration: underline dotted var(--main-text-color)")
+ .attr("title", "If you don't check this, the note will be only removed from the relation map.")
+ .append(
+ $("<input>")
+ .attr("type", "checkbox")
+ .addClass("form-check-input " + DELETE_NOTE_BUTTON_CLASS)
+ )
+ .append("Also delete the note")
+ ));
this.$custom.show();
@@ -103,12 +108,12 @@ export default class ConfirmDialog extends BasicWidget {
this.resolve = callback;
}
- isDeleteNoteChecked() {
- return this.$widget.find("." + DELETE_NOTE_BUTTON_CLASS + ":checked").length > 0;
- }
-
doResolve(ret) {
- this.resolve(ret);
+ this.resolve({
+ confirmed: ret,
+ isDeleteNoteChecked: this.$widget.find("." + DELETE_NOTE_BUTTON_CLASS + ":checked").length > 0
+ });
+
this.resolve = null;
this.$widget.modal("hide");
diff --git a/src/public/app/widgets/type_widgets/relation_map.js b/src/public/app/widgets/type_widgets/relation_map.js
index 2c27503ac2..663ba033c0 100644
--- a/src/public/app/widgets/type_widgets/relation_map.js
+++ b/src/public/app/widgets/type_widgets/relation_map.js
@@ -196,13 +196,15 @@ export default class RelationMapTypeWidget extends TypeWidget {
appContext.tabManager.openTabWithNoteWithHoisting(noteId);
}
else if (command === "remove") {
- if (!await dialogService.confirmDeleteNoteBoxWithNote($title.text())) {
+ const result = await dialogService.confirmDeleteNoteBoxWithNote($title.text());
+
+ if (!result.confirmed) {
return;
}
this.jsPlumbInstance.remove(this.noteIdToId(noteId));
- if (confirmDialog.isDeleteNoteChecked()) {
+ if (result.isDeleteNoteChecked) {
const taskId = utils.randomString(10);
await server.remove(`notes/${noteId}?taskId=${taskId}&last=true`);