mirror of
https://github.com/zadam/trilium.git
synced 2025-02-25 07:25:32 +08:00
fixed confirmDeleteNoteBoxWithNote
This commit is contained in:
parent
7ac8dc6785
commit
c5bc23d511
3 changed files with 34 additions and 18 deletions
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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`);
|
||||
|
|
Loading…
Reference in a new issue