📢 Publish-Button im Header + ✏️ Spieltitel inline editierbar + partielles DB-Update
This commit is contained in:
@@ -1202,6 +1202,9 @@ def submission_detail(sub_id: int):
|
|||||||
<a href="/admin" class="btn btn-back" style="min-height:36px;padding:0.35rem 0.8rem;font-size:0.78rem;">← Zurück</a>
|
<a href="/admin" class="btn btn-back" style="min-height:36px;padding:0.35rem 0.8rem;font-size:0.78rem;">← Zurück</a>
|
||||||
<div><h1>{type_emoji} #{row['id']}</h1><div class="subtitle">{row['channel']} · {row['created_at']}</div></div>
|
<div><h1>{type_emoji} #{row['id']}</h1><div class="subtitle">{row['channel']} · {row['created_at']}</div></div>
|
||||||
{f'<div style="margin-left:auto;" class="halle-badge">📍 {row["halle"]}</div>' if row['halle'] else ''}
|
{f'<div style="margin-left:auto;" class="halle-badge">📍 {row["halle"]}</div>' if row['halle'] else ''}
|
||||||
|
<form method="post" action="/submission/{row['id']}/update-summary" style="margin-left:0.5rem;">
|
||||||
|
<button type="submit" class="btn btn-publish-big" name="action" value="publish" {'disabled' if row['status'] in ('published','gdpr_deleted') else ''} style="padding:0.4rem 1.2rem;font-size:0.8rem;white-space:nowrap;">📢 Veröffentlichen</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main class="detail-main">
|
<main class="detail-main">
|
||||||
@@ -1213,7 +1216,11 @@ def submission_detail(sub_id: int):
|
|||||||
<div class="field"><div class="field-label">Status</div><div class="field-value"><span class="badge badge-{row['status']}">{row['status']}</span></div></div>
|
<div class="field"><div class="field-label">Status</div><div class="field-value"><span class="badge badge-{row['status']}">{row['status']}</span></div></div>
|
||||||
<div class="field"><div class="field-label">Kategorie</div><div class="field-value">{row['category'] or '-'}</div></div>
|
<div class="field"><div class="field-label">Kategorie</div><div class="field-value">{row['category'] or '-'}</div></div>
|
||||||
<div class="field"><div class="field-label">📍 Halle / Stand</div><div class="field-value"><span style="color:var(--accent2);font-weight:600;">{row['halle'] or '– nicht erkannt –'}</span></div></div>
|
<div class="field"><div class="field-label">📍 Halle / Stand</div><div class="field-value"><span style="color:var(--accent2);font-weight:600;">{row['halle'] or '– nicht erkannt –'}</span></div></div>
|
||||||
<div class="field"><div class="field-label">🎯 Spieltitel</div><div class="field-value"><span style="color:#ff453a;font-weight:600;">{row['spiel_titel'] or '–'}</span></div></div>
|
<div class="field"><div class="field-label">🎯 Spieltitel</div><div class="field-value" style="display:flex;gap:0.4rem;align-items:center;">
|
||||||
|
<input type="text" id="spielTitelInline" value="{row['spiel_titel'] or ''}" placeholder="Spieltitel eingeben..." style="flex:1;max-width:300px;">
|
||||||
|
<button id="saveSpielTitelBtn" class="btn btn-publish" style="padding:0.35rem 0.8rem;font-size:0.72rem;white-space:nowrap;">💾 Speichern</button>
|
||||||
|
<span id="spielTitelStatus" style="font-size:0.7rem;color:#30d158;display:none;">✓</span>
|
||||||
|
</div></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@@ -1307,6 +1314,30 @@ if (_llmBtn) {{
|
|||||||
this.textContent = '🤖 LLM-Zusammenfassung';
|
this.textContent = '🤖 LLM-Zusammenfassung';
|
||||||
}});
|
}});
|
||||||
}}
|
}}
|
||||||
|
var _spielBtn = document.getElementById('saveSpielTitelBtn');
|
||||||
|
var _spielInput = document.getElementById('spielTitelInline');
|
||||||
|
var _spielStatus = document.getElementById('spielTitelStatus');
|
||||||
|
if (_spielBtn && _spielInput) {{
|
||||||
|
_spielBtn.addEventListener('click', async function() {{
|
||||||
|
this.disabled = true;
|
||||||
|
_spielStatus.style.display = 'none';
|
||||||
|
try {{
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('action', 'save');
|
||||||
|
formData.append('spiel_titel', _spielInput.value.trim());
|
||||||
|
const r = await fetch('/submission/{row["id"]}/update-summary', {{method:'POST', body:formData}});
|
||||||
|
if (r.ok) {{
|
||||||
|
_spielStatus.textContent = '✓ Gespeichert';
|
||||||
|
_spielStatus.style.display = 'inline';
|
||||||
|
setTimeout(() => {{ _spielStatus.style.display = 'none'; }}, 2000);
|
||||||
|
}}
|
||||||
|
}} catch(err) {{ _spielStatus.textContent = 'Fehler'; _spielStatus.style.display = 'inline'; }}
|
||||||
|
this.disabled = false;
|
||||||
|
}});
|
||||||
|
_spielInput.addEventListener('keydown', function(e) {{
|
||||||
|
if (e.key === 'Enter') {{ e.preventDefault(); _spielBtn.click(); }}
|
||||||
|
}});
|
||||||
|
}}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>"""
|
</html>"""
|
||||||
@@ -1330,10 +1361,33 @@ def submission_update_summary(sub_id: int):
|
|||||||
elif action == "done":
|
elif action == "done":
|
||||||
db.execute("UPDATE submissions SET status='done' WHERE id=?", (sub_id,))
|
db.execute("UPDATE submissions SET status='done' WHERE id=?", (sub_id,))
|
||||||
elif action == "save":
|
elif action == "save":
|
||||||
db.execute(
|
# Partial update — only update fields that are provided
|
||||||
"UPDATE submissions SET summary=?, publish_name=?, halle=?, spiel_titel=? WHERE id=?",
|
fields = []
|
||||||
(summary or None, publish_name or None, halle or None, spiel_titel or None, sub_id),
|
params = []
|
||||||
)
|
if summary:
|
||||||
|
fields.append("summary=?")
|
||||||
|
params.append(summary)
|
||||||
|
if publish_name:
|
||||||
|
fields.append("publish_name=?")
|
||||||
|
params.append(publish_name)
|
||||||
|
if halle:
|
||||||
|
fields.append("halle=?")
|
||||||
|
params.append(halle)
|
||||||
|
if spiel_titel:
|
||||||
|
fields.append("spiel_titel=?")
|
||||||
|
params.append(spiel_titel)
|
||||||
|
# Clear fields explicitly set to empty
|
||||||
|
if request.form.get("summary") is not None and not summary:
|
||||||
|
fields.append("summary=NULL")
|
||||||
|
if request.form.get("publish_name") is not None and not publish_name:
|
||||||
|
fields.append("publish_name=NULL")
|
||||||
|
if request.form.get("halle") is not None and not halle:
|
||||||
|
fields.append("halle=NULL")
|
||||||
|
if request.form.get("spiel_titel") is not None and not spiel_titel:
|
||||||
|
fields.append("spiel_titel=NULL")
|
||||||
|
if fields:
|
||||||
|
params.append(sub_id)
|
||||||
|
db.execute(f"UPDATE submissions SET {', '.join(fields)} WHERE id=?", params)
|
||||||
elif action == "save_media":
|
elif action == "save_media":
|
||||||
# Collect media publish flags from form
|
# Collect media publish flags from form
|
||||||
import re
|
import re
|
||||||
|
|||||||
Reference in New Issue
Block a user