fix: forum delete button JS error when title contains apostrophe
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions

Title with '26 broke inline onclick string. Now reads title from DOM.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-04-10 07:59:07 +02:00
parent 8481ffd70a
commit 155577b985

View File

@ -1047,7 +1047,7 @@
</svg> </svg>
{% if topic.is_locked %}Odblokuj{% else %}Zablokuj{% endif %} {% if topic.is_locked %}Odblokuj{% else %}Zablokuj{% endif %}
</button> </button>
<button type="button" class="admin-btn admin-btn-delete" onclick="deleteTopic({{ topic.id }}, '{{ topic.title|e }}')" title="Usuń wątek"> <button type="button" class="admin-btn admin-btn-delete" onclick="deleteTopic({{ topic.id }})" title="Usuń wątek">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"> <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/> <path d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
</svg> </svg>
@ -1680,10 +1680,11 @@
}); });
// Admin functions // Admin functions
function deleteTopic(topicId, topicTitle) { function deleteTopic(topicId) {
var topicTitle = document.querySelector('.topic-title')?.textContent?.trim() || '';
showConfirmModal( showConfirmModal(
'Usuń wątek', 'Usuń wątek',
`Czy na pewno chcesz usunąć wątek "${topicTitle}"?`, 'Czy na pewno chcesz usunąć wątek "' + topicTitle + '"?',
'Ta operacja usunie również wszystkie odpowiedzi i jest nieodwracalna.', 'Ta operacja usunie również wszystkie odpowiedzi i jest nieodwracalna.',
function() { function() {
fetch(`/admin/forum/topic/${topicId}/delete`, { fetch(`/admin/forum/topic/${topicId}/delete`, {