refactored confirmation dialogs to use a unified confirmAction modal
Some checks failed
PHPUnit / test (push) Has been cancelled

This commit is contained in:
2026-06-14 18:02:03 +02:00
parent 6ae29f1648
commit b06c4bf3ee
10 changed files with 295 additions and 39 deletions

View File

@ -1,5 +1,6 @@
import { apiGet, apiPost, apiPut, apiPatch, apiDelete } from '../api.js';
import { canEdit, homeNavButton, showToast } from '../app.js';
import { confirmAction } from '../confirm-modal.js';
import { navigate } from '../router.js';
import {
SOURCE_LANG,
@ -1668,7 +1669,12 @@ async function deleteQuestion(q) {
return;
}
const msg = 'Remove this question? If client data exists it will be retired (not deleted) so upload history stays intact.';
if (!confirm(msg)) return;
if (!(await confirmAction({
title: 'Remove question',
message: msg,
confirmLabel: 'Remove',
variant: 'danger',
}))) return;
try {
const data = await apiDelete('questions.php', { questionID: q.questionID });
questions = questions.filter(x => x.questionID !== q.questionID);
@ -1702,7 +1708,12 @@ async function updateOption(q, answerOptionID, fields) {
}
async function deleteOption(q, answerOptionID) {
if (!confirm('Remove this answer option?')) return;
if (!(await confirmAction({
title: 'Remove answer option',
message: 'Remove this answer option?',
confirmLabel: 'Remove',
variant: 'danger',
}))) return;
try {
const data = await apiDelete('answer_options.php', { answerOptionID });
if (!data.retired) {
@ -1976,7 +1987,12 @@ function bindLanguageManager(languages) {
document.querySelectorAll('.lang-chip-remove').forEach(btn => {
btn.addEventListener('click', async () => {
const lc = btn.dataset.lc;
if (!confirm(`Remove language "${lc}" and ALL its translations?`)) return;
if (!(await confirmAction({
title: 'Remove language',
message: `Remove language "${lc}" and ALL its translations?`,
confirmLabel: 'Remove',
variant: 'danger',
}))) return;
try {
await apiDelete('translations.php', { type: 'language', languageCode: lc });
showToast(`Language "${lc}" removed`, 'success');