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:
@@ -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]:
|
||||
|
||||
@@ -1356,6 +1356,35 @@ def api_get_task(request: Request, task_id: int) -> JSONResponse:
|
||||
return JSONResponse({"task": task})
|
||||
|
||||
|
||||
@router.post("/api/tasks/{task_id}/move-parent")
|
||||
def api_move_subtask(
|
||||
request: Request,
|
||||
task_id: int,
|
||||
payload: dict[str, Any] = Body(...),
|
||||
) -> JSONResponse:
|
||||
"""하위 업무를 다른 상위 업무로 옮긴다 — 보드에서 하위 업무 줄을 다른 카드로 드래그.
|
||||
|
||||
body: {"parent_task_id": 받는 업무 id}. 받는 업무는 같은 프로젝트의 최상위 업무만.
|
||||
"""
|
||||
user = _require_user(request)
|
||||
st = _db_or_503(request)
|
||||
existing = st.get_task(task_id=task_id)
|
||||
if existing is None:
|
||||
raise HTTPException(status_code=404, detail="업무를 찾을 수 없습니다.")
|
||||
_require_manage(request, st, user, existing["project_id"])
|
||||
try:
|
||||
parent_id = int(payload.get("parent_task_id"))
|
||||
except (TypeError, ValueError):
|
||||
raise HTTPException(status_code=400, detail="parent_task_id 가 필요합니다.")
|
||||
try:
|
||||
task = st.move_subtask(task_id=task_id, parent_task_id=parent_id, actor=user["email"])
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc))
|
||||
except KeyError as exc:
|
||||
raise HTTPException(status_code=404, detail=str(exc))
|
||||
return JSONResponse({"task": task})
|
||||
|
||||
|
||||
# ────────────────────────────────────────────────────────────
|
||||
# JSON API — 팔로워 (아사나의 협업자)
|
||||
# ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -37,6 +37,7 @@ ACTION_ASSIGNED = "assigned"
|
||||
ACTION_COMPLETED = "completed"
|
||||
ACTION_STAGE_CHANGED = "stage_changed"
|
||||
ACTION_REOPENED = "reopened"
|
||||
ACTION_SUBTASK_MOVED = "subtask_moved" # 하위 업무를 다른 상위 업무로 옮김(보드 드래그)
|
||||
|
||||
# 프로젝트 색상 팔레트(아사나 느낌) — UI 선택지
|
||||
COLOR_PALETTE: tuple[str, ...] = (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260925c" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260925d" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -99,5 +99,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20260925c" defer></script>
|
||||
<script src="/static/project.js?v=20260925d" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260925c" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260925d" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -98,5 +98,5 @@
|
||||
"today": {{ today | tojson }}
|
||||
}
|
||||
</script>
|
||||
<script src="/static/project.js?v=20260925c" defer></script>
|
||||
<script src="/static/project.js?v=20260925d" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260925c" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260925d" />
|
||||
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — self-host -->
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
<!-- 타임라인 vis-timeline — self-host -->
|
||||
@@ -460,5 +460,5 @@
|
||||
</script>
|
||||
|
||||
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
|
||||
<script src="/static/project.js?v=20260925c" defer></script>
|
||||
<script src="/static/project.js?v=20260925d" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260925c" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260925d" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -68,5 +68,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20260925c" defer></script>
|
||||
<script src="/static/project.js?v=20260925d" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user