feat(project): 보드에서 하위 업무 한 줄을 다른 업무 카드로 드래그해 옮기기

카드에 펼친 하위 업무 줄을 끌어 다른 카드에 놓으면 그 업무의 하위 업무로
옮긴다. 카드 자체 드래그(세션 이동)와 섞이지 않게 별도 드래그 타입을 쓰고,
놓을 수 있는 카드는 보라 테두리로 표시한다.

- API: POST /project/api/tasks/{id}/move-parent {parent_task_id}
- db.move_subtask: 받는 쪽은 같은 프로젝트의 최상위 업무만(순환 방지),
  활동 로그 subtask_moved, 목록 끝으로 정렬
- 정적 파일 버전 20260925d

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 18:28:56 +09:00
parent db1ffdd636
commit d5e02b04a4
10 changed files with 169 additions and 8 deletions
+46
View File
@@ -656,6 +656,52 @@ class ProjectStore:
detail=f"{ttl} → {assignee}")
return self.get_task(task_id=row["id"])
def move_subtask(
self, *, task_id: int, parent_task_id: int, actor: str = ""
) -> dict[str, Any]:
"""하위 업무를 다른 상위 업무 밑으로 옮긴다(보드 카드로 드래그).
받는 쪽은 보드 카드 = 최상위 업무만 허용한다 — 그래서 자기 자신이나
자기 하위로 옮기는 순환이 생기지 않는다. 같은 프로젝트 안에서만
(하위 업무는 부모와 같은 프로젝트에 속한다 — create_task 와 같은 규칙).
하위 업무의 하위 업무는 그대로 따라간다. 목록 끝(sort_order 최대+1)으로.
"""
with self._pool.connection() as conn:
with conn.transaction():
sub = conn.execute(
"SELECT id, project_id, parent_task_id, title FROM tasks "
"WHERE id = %s FOR UPDATE",
(task_id,),
).fetchone()
if not sub:
raise KeyError(f"업무를 찾을 수 없습니다: {task_id}")
if sub["parent_task_id"] is None:
raise ValueError("하위 업무만 다른 업무로 옮길 수 있습니다.")
parent = conn.execute(
"SELECT id, project_id, parent_task_id, title FROM tasks WHERE id = %s",
(parent_task_id,),
).fetchone()
if not parent:
raise KeyError(f"상위 업무를 찾을 수 없습니다: {parent_task_id}")
if parent["parent_task_id"] is not None:
raise ValueError("하위 업무 안으로는 옮길 수 없습니다.")
if int(parent["project_id"]) != int(sub["project_id"]):
raise ValueError("다른 프로젝트의 업무로는 옮길 수 없습니다.")
if int(parent["id"]) != int(sub["parent_task_id"]):
nxt = conn.execute(
"SELECT COALESCE(MAX(sort_order), -1) + 1 AS n FROM tasks "
"WHERE project_id = %s",
(sub["project_id"],),
).fetchone()
conn.execute(
"UPDATE tasks SET parent_task_id = %s, sort_order = %s WHERE id = %s",
(parent["id"], int(nxt["n"]), task_id),
)
self._log(conn, project_id=sub["project_id"], task_id=task_id,
actor=actor, action=store.ACTION_SUBTASK_MOVED,
detail=f"{sub['title']} → {parent['title']}")
return self.get_task(task_id=task_id)
def update_task(
self, *, task_id: int, fields: dict[str, Any], actor: str = ""
) -> dict[str, Any]: