new functions and fixes

This commit is contained in:
Mateusz Gruszczyński
2026-08-06 09:08:02 +02:00
parent 1e80fb2bcb
commit 7989a873e7
11 changed files with 191 additions and 42 deletions
+6 -2
View File
@@ -165,9 +165,13 @@ function setNotesView(view) {
});
}
function deleteButton(note, inline = false) {
const disabled = note.protected;
const disabled = !note.can_delete;
const classes = `note-delete-button${inline ? " note-delete-button--inline" : ""}`;
const reason = disabled ? "Protected notes cannot be deleted" : `Delete ${note.title}`;
const reason = !disabled
? `Delete ${note.title}`
: note.protected
? "Protected note: only its owner can delete it"
: "Read-write access is required to delete this note";
return `<button class="${classes}" data-delete-note="${escapeHtml(note.slug)}" data-note-title="${escapeHtml(note.title)}" ${disabled ? "disabled" : ""} title="${escapeHtml(reason)}">Delete</button>`;
}
function renderNotes(notes = notesCache) {