Fix: Standort-Picker im Forum-Edit-Modal ergänzt
- _showEditThreadModal: location picker mit Vorausfüllung (thread_lat/lon/ort)
- ThreadUpdate-Schema: thread_lat/lon/ort Felder ergänzt
- PATCH /threads/{id}/content: Location wird jetzt gespeichert/überschrieben
This commit is contained in:
parent
062c0209e6
commit
b1053198de
3 changed files with 32 additions and 6 deletions
|
|
@ -38,8 +38,11 @@ class ThreadPatch(BaseModel):
|
||||||
is_locked: Optional[int] = None
|
is_locked: Optional[int] = None
|
||||||
|
|
||||||
class ThreadUpdate(BaseModel):
|
class ThreadUpdate(BaseModel):
|
||||||
titel: Optional[str] = None
|
titel: Optional[str] = None
|
||||||
text: Optional[str] = None
|
text: Optional[str] = None
|
||||||
|
thread_lat: Optional[float] = None
|
||||||
|
thread_lon: Optional[float] = None
|
||||||
|
thread_ort: Optional[str] = None
|
||||||
|
|
||||||
class PostUpdate(BaseModel):
|
class PostUpdate(BaseModel):
|
||||||
text: str
|
text: str
|
||||||
|
|
@ -351,7 +354,10 @@ async def update_thread_content(thread_id: int, data: ThreadUpdate, user=Depends
|
||||||
updates.append("titel=?"); vals.append(data.titel.strip())
|
updates.append("titel=?"); vals.append(data.titel.strip())
|
||||||
if data.text is not None:
|
if data.text is not None:
|
||||||
updates.append("text=?"); vals.append(data.text.strip())
|
updates.append("text=?"); vals.append(data.text.strip())
|
||||||
if not updates: return {"ok": True}
|
# Location immer überschreiben (auch mit None zum Löschen)
|
||||||
|
updates += ["thread_lat=?", "thread_lon=?", "thread_ort=?"]
|
||||||
|
vals += [data.thread_lat, data.thread_lon,
|
||||||
|
data.thread_ort.strip() if data.thread_ort else None]
|
||||||
conn.execute(f"UPDATE forum_threads SET {','.join(updates)} WHERE id=?", (*vals, thread_id))
|
conn.execute(f"UPDATE forum_threads SET {','.join(updates)} WHERE id=?", (*vals, thread_id))
|
||||||
return {"ok": True}
|
return {"ok": True}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Router, State-Management, Navigation, Initialisierung.
|
Router, State-Management, Navigation, Initialisierung.
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const APP_VER = '216'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
const APP_VER = '217'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||||
|
|
||||||
const App = (() => {
|
const App = (() => {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1067,19 +1067,39 @@ window.Page_forum = (() => {
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label">Text</label>
|
<label class="form-label">Text</label>
|
||||||
<textarea class="form-control" name="text" rows="6">${_esc(thread.text || '')}</textarea>
|
<textarea class="form-control" name="text" rows="5">${_esc(thread.text || '')}</textarea>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">Standort <span style="color:var(--c-text-secondary)">(optional)</span></label>
|
||||||
|
<div id="forum-edit-location-picker"></div>
|
||||||
</div>
|
</div>
|
||||||
</form>`,
|
</form>`,
|
||||||
footer: `
|
footer: `
|
||||||
<button class="btn btn-ghost flex-1" onclick="UI.modal.close()">Abbrechen</button>
|
<button class="btn btn-ghost flex-1" onclick="UI.modal.close()">Abbrechen</button>
|
||||||
<button type="submit" form="${id}" class="btn btn-primary flex-1">${UI.icon('floppy-disk')} Speichern</button>`,
|
<button type="submit" form="${id}" class="btn btn-primary flex-1">${UI.icon('floppy-disk')} Speichern</button>`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let _picker = null;
|
||||||
|
setTimeout(() => {
|
||||||
|
_picker = UI.locationPicker({ containerId: 'forum-edit-location-picker' });
|
||||||
|
if (thread.thread_lat && thread.thread_lon) {
|
||||||
|
_picker.setValue(thread.thread_lat, thread.thread_lon, thread.thread_ort || null);
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
|
||||||
document.getElementById(id)?.addEventListener('submit', async e => {
|
document.getElementById(id)?.addEventListener('submit', async e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const fd = new FormData(e.target);
|
const fd = new FormData(e.target);
|
||||||
|
const loc = _picker ? _picker.getValue() : { lat: null, lon: null, name: null };
|
||||||
const btn = document.querySelector(`[form="${id}"][type="submit"]`);
|
const btn = document.querySelector(`[form="${id}"][type="submit"]`);
|
||||||
await UI.asyncButton(btn, async () => {
|
await UI.asyncButton(btn, async () => {
|
||||||
await API.forum.updateThread(thread.id, { titel: fd.get('titel'), text: fd.get('text') });
|
await API.forum.updateThread(thread.id, {
|
||||||
|
titel: fd.get('titel'),
|
||||||
|
text: fd.get('text'),
|
||||||
|
thread_lat: loc.lat ?? null,
|
||||||
|
thread_lon: loc.lon ?? null,
|
||||||
|
thread_ort: loc.name ?? null,
|
||||||
|
});
|
||||||
UI.modal.close();
|
UI.modal.close();
|
||||||
_loadThreads(true);
|
_loadThreads(true);
|
||||||
UI.toast.success('Beitrag aktualisiert.');
|
UI.toast.success('Beitrag aktualisiert.');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue