fix(diarization-ui): bind document action handlers on window to avoid renameDoc undefined

This commit is contained in:
2026-03-21 14:37:26 +01:00
parent 3100aa22b3
commit 90dd0c0e4b

26
app.py
View File

@@ -369,27 +369,27 @@ def view_document(doc_id: int):
<div class='card mdview'>{rendered}</div>
<script>
async function postForm(url, data) {{
window.postForm = async function(url, data) {
const body = new URLSearchParams(data);
const r = await fetch(url, {{method:'POST', headers:{{'Content-Type':'application/x-www-form-urlencoded'}}, body}});
if (!r.ok) {{ alert('Fehler: '+r.status); return; }}
const r = await fetch(url, {method:'POST', headers:{'Content-Type':'application/x-www-form-urlencoded'}, body});
if (!r.ok) { alert('Fehler: '+r.status); return; }
location.href = '/library';
}}
function renameDoc() {{
};
window.renameDoc = function() {
const v = prompt('Neuer Dokumentname:', {json.dumps(d['title'])});
if (v===null) return;
postForm('/document/{doc_id}/rename', {{title:v}});
}}
function moveDoc() {{
window.postForm('/document/{doc_id}/rename', {title:v});
};
window.moveDoc = function() {
const info = {json.dumps(project_list)};
const v = prompt('Ziel-Projekt-ID eingeben:\n'+info, '');
if (v===null) return;
postForm('/document/{doc_id}/move', {{project_id:v}});
}}
function deleteDoc() {{
window.postForm('/document/{doc_id}/move', {project_id:v});
};
window.deleteDoc = function() {
if (!confirm('Dokument wirklich löschen?')) return;
postForm('/document/{doc_id}/delete', {{}});
}}
window.postForm('/document/{doc_id}/delete', {});
};
</script>
"""
return layout("Dokument", body)