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, apiDelete, apiDownloadFetch } from '../api.js';
import { canEdit, pageHeaderHTML, showToast } from '../app.js';
import { confirmAction } from '../confirm-modal.js';
import {
SOURCE_LANG,
normalizeEntry,
@ -308,7 +309,12 @@ function renderLanguagePanel(languages) {
panel.querySelectorAll('.lang-chip-remove').forEach(btn => {
btn.addEventListener('click', async () => {
const lc = btn.dataset.lc;
if (!confirm(`Remove "${lc}" and all its translations?`)) return;
if (!(await confirmAction({
title: 'Remove language',
message: `Remove "${lc}" and all its translations?`,
confirmLabel: 'Remove',
variant: 'danger',
}))) return;
try {
await apiDelete('translations.php', { type: 'language', languageCode: lc });
showToast(`Language "${lc}" removed`, 'success');
@ -671,7 +677,11 @@ function bindTranslationBundleActions() {
}
const count = bundle.entries.length;
if (!confirm(`Import translations for ${count} entries from this file?`)) return;
if (!(await confirmAction({
title: 'Import translations',
message: `Import translations for ${count} entries from this file?`,
confirmLabel: 'Import',
}))) return;
importBtn.disabled = true;
const prev = importBtn.textContent;