feat: unlink and delete buttons for links on project detail page
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -417,3 +417,27 @@ async def remove_contact(
|
||||
"DELETE FROM contact_projects WHERE contact_id = :cid AND project_id = :pid"
|
||||
), {"cid": contact_id, "pid": project_id})
|
||||
return RedirectResponse(url=f"/projects/{project_id}?tab=contacts", status_code=303)
|
||||
|
||||
|
||||
# ---- Link unlinking ----
|
||||
|
||||
@router.post("/{project_id}/links/{link_id}/unlink")
|
||||
async def unlink_link(
|
||||
project_id: str, link_id: str,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
await db.execute(text(
|
||||
"UPDATE links SET project_id = NULL, updated_at = now() WHERE id = :lid AND project_id = :pid"
|
||||
), {"lid": link_id, "pid": project_id})
|
||||
await db.commit()
|
||||
return RedirectResponse(url=f"/projects/{project_id}?tab=links", status_code=303)
|
||||
|
||||
|
||||
@router.post("/{project_id}/links/{link_id}/delete")
|
||||
async def delete_project_link(
|
||||
project_id: str, link_id: str,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
repo = BaseRepository("links", db)
|
||||
await repo.soft_delete(link_id)
|
||||
return RedirectResponse(url=f"/projects/{project_id}?tab=links", status_code=303)
|
||||
|
||||
@@ -93,6 +93,12 @@
|
||||
<span class="row-meta">{{ l.url[:50] }}{% if l.url|length > 50 %}...{% endif %}</span>
|
||||
<div class="row-actions">
|
||||
<a href="/links/{{ l.id }}/edit" class="btn btn-ghost btn-xs">Edit</a>
|
||||
<form action="/projects/{{ item.id }}/links/{{ l.id }}/unlink" method="post" style="display:inline">
|
||||
<button class="btn btn-ghost btn-xs" title="Unlink from project">Unlink</button>
|
||||
</form>
|
||||
<form action="/projects/{{ item.id }}/links/{{ l.id }}/delete" method="post" data-confirm="Delete this link?" style="display:inline">
|
||||
<button class="btn btn-ghost btn-xs" style="color:var(--red)" title="Delete link">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
|
||||
Reference in New Issue
Block a user