fix: task form — <form hx-post> вместо hx-include (не отправлял summary). fix: checkbox — <a> вместо <span> (не кликался Alpine).

This commit is contained in:
2026-10-24 14:30:25 +00:00
parent e970ec1602
commit 7f08b39487
2 changed files with 8 additions and 6 deletions
+7 -5
View File
@@ -379,7 +379,7 @@ def tasks_reload(request: Request, _: AuthDep):
sid = "'" + t["summary"].replace("'", "\\'") + "'" sid = "'" + t["summary"].replace("'", "\\'") + "'"
xdata = '{{edit:{},editing:false}}'.format(sid) xdata = '{{edit:{},editing:false}}'.format(sid)
items.append(f'''<div class="tk {'done' if t['completed'] else ''}" x-data="{xdata}"> items.append(f'''<div class="tk {'done' if t['completed'] else ''}" x-data="{xdata}">
<span class="chk" hx-post="/api/task/{t['uid']}/toggle" hx-target="closest .card" hx-swap="innerHTML"></span> <a class="chk" href="#" hx-post="/api/task/{t['uid']}/toggle" hx-target="closest .card" hx-swap="innerHTML" onclick="event.preventDefault()"></a>
<div class="txt"> <div class="txt">
<div class="t" x-on:click="edit={sid};editing=true">{t['summary']}</div> <div class="t" x-on:click="edit={sid};editing=true">{t['summary']}</div>
<template x-if="editing"> <template x-if="editing">
@@ -405,10 +405,12 @@ def tasks_reload(request: Request, _: AuthDep):
def task_new_form(_: AuthDep): def task_new_form(_: AuthDep):
"""Форма создания задачи (HTMX-фрагмент).""" """Форма создания задачи (HTMX-фрагмент)."""
return HTMLResponse('''<div class="task-form" style="display:flex;gap:4px;padding:6px 10px"> return HTMLResponse('''<div class="task-form" style="display:flex;gap:4px;padding:6px 10px">
<input name="summary" placeholder="Название задачи" style="flex:1;padding:3px 6px;border:1px solid var(--border);border-radius:4px;background:var(--bg2);color:var(--fg)" autofocus> <form hx-post="/api/tasks/create" hx-target="closest .card" hx-swap="innerHTML" style="display:contents">
<input name="due" type="date" style="width:130px;padding:3px 6px;border:1px solid var(--border);border-radius:4px;background:var(--bg2);color:var(--fg)"> <input name="summary" placeholder="Название задачи" style="flex:1;padding:3px 6px;border:1px solid var(--border);border-radius:4px;background:var(--bg2);color:var(--fg)" autofocus required>
<button class="pb-btn" hx-post="/api/tasks/create" hx-include="closest .task-form input" hx-target="closest .card" hx-swap="innerHTML">✓</button> <input name="due" type="date" style="width:130px;padding:3px 6px;border:1px solid var(--border);border-radius:4px;background:var(--bg2);color:var(--fg)">
<button class="pb-btn" hx-get="/api/tasks/reload" hx-target="closest .card" hx-swap="innerHTML">✗</button> <button class="pb-btn" type="submit">✓</button>
<button class="pb-btn" type="button" hx-get="/api/tasks/reload" hx-target="closest .card" hx-swap="innerHTML">✗</button>
</form>
</div>''') </div>''')
+1 -1
View File
@@ -189,7 +189,7 @@ body.f3 .c3{flex:1}
cursor:pointer;align-items:flex-start} cursor:pointer;align-items:flex-start}
.tk:hover{background:var(--hover)} .tk:hover{background:var(--hover)}
.tk .chk{width:15px;height:15px;border:1.5px solid var(--fg3);border-radius:4px; .tk .chk{width:15px;height:15px;border:1.5px solid var(--fg3);border-radius:4px;
flex-shrink:0;margin-top:2px;cursor:pointer} flex-shrink:0;margin-top:2px;cursor:pointer;display:inline-flex;text-decoration:none;color:inherit;align-items:center;justify-content:center}
.tk .txt{flex:1;min-width:0} .tk .txt{flex:1;min-width:0}
.tk .txt .t{font-size:12.5px} .tk .txt .t{font-size:12.5px}
.tk .txt .d{font-size:11px;color:var(--fg3);margin-top:1px} .tk .txt .d{font-size:11px;color:var(--fg3);margin-top:1px}