Skip to content

Commit 398589b

Browse files
committed
Add a safety check to deletion
1 parent beb8057 commit 398589b

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Next version
1212
``JS`` to a script without attributes, and moved the configuration into an
1313
inline JSON blob.
1414
- Rewrote ``content_editor/save_shortcut.js`` without jQuery.
15+
- Added a safety check to ``save_shortcut.js`` which shows a confirmation
16+
dialog when attempting to delete the whole object instead of deleting only
17+
inlines.
1518

1619

1720
7.2 (2025-01-27)

content_editor/static/content_editor/save_shortcut.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,17 @@ window.addEventListener("keydown", (e) => {
99
el.click()
1010
}
1111
})
12+
13+
window.addEventListener("click", (e) => {
14+
let el
15+
if (
16+
(el = e.target.closest(".deletelink")) &&
17+
document.querySelectorAll("input[type=checkbox][name$=-DELETE]:checked")
18+
.length &&
19+
!confirm(
20+
"You have marked inline objects for deletion but have clicked the link to delete the whole object. Are you sure that's what you want? Use a save button to delete inline objects.",
21+
)
22+
) {
23+
e.preventDefault()
24+
}
25+
})

0 commit comments

Comments
 (0)