Merge branch 'feat/project-move-task-drag'
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
{% block head_extra %}
|
||||
{# 프로젝트 화면 부품(설명 편집기·날짜 팝업·멤버 고르기)을 그대로 쓴다 — project.js 는 PJ_LIB_ONLY 로 부품만 #}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013c" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
<script>window.PJ_LIB_ONLY = true; window.PJ_HOLIDAYS = {{ (pj_kr_holidays or {}) | tojson }};</script>
|
||||
{% endblock %}
|
||||
@@ -64,7 +64,7 @@
|
||||
</section>
|
||||
</div>
|
||||
<script>window.NTC_PEOPLE = {{ people | tojson }};</script>
|
||||
<script src="/static/project.js?v=20261013b" defer></script>
|
||||
<script src="/static/project.js?v=20261013c" defer></script>
|
||||
<script src="/static/erp-notice-admin.js?v=20261012b" defer></script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -933,6 +933,86 @@ class ProjectStore:
|
||||
out["_newly_completed"] = newly_completed if changed else False
|
||||
return out
|
||||
|
||||
def move_task_to_project(
|
||||
self, *, task_id: int, project_id: int, stage_id: Any = None, actor: str = "",
|
||||
assignee_allowed: Any = None,
|
||||
) -> dict[str, Any]:
|
||||
"""메인 업무를 다른 프로젝트(의 섹션)로 옮긴다 — 세부 업무(모든 단계)도 함께. 한 트랜잭션.
|
||||
|
||||
· 메인 업무만(세부 업무는 상위 업무와 함께 움직인다). 같은 프로젝트면 ValueError.
|
||||
· 섹션은 대상 프로젝트 것만(None = 섹션 없음). 목록 끝(sort_order 최대+1)으로.
|
||||
· 섹션을 옮길 때와 같은 규칙 — 담당자가 비었으면 그 섹션 기본 담당자, 완료 섹션이면 완료 처리.
|
||||
· 대상 프로젝트로 걸려 있던 연결(멀티호밍)은 이제 원 소속이라 지운다(다른 연결은 그대로).
|
||||
· 활동 이력·알림·회의록 업무 등록 줄의 프로젝트도 따라 바꾼다(이력이 새 프로젝트 화면에 보이게).
|
||||
반환: 옮긴 업무(get_task) + `_moved_ids`·`_newly_assigned`·`_newly_completed`.
|
||||
"""
|
||||
newly_assigned: str | None = None
|
||||
newly_completed = False
|
||||
with self._pool.connection() as conn:
|
||||
with conn.transaction():
|
||||
row = conn.execute("SELECT * FROM tasks WHERE id = %s FOR UPDATE", (task_id,)).fetchone()
|
||||
if row is None:
|
||||
raise KeyError(f"업무를 찾을 수 없습니다: {task_id}")
|
||||
prev = self._serialize(row)
|
||||
if prev.get("parent_task_id") is not None:
|
||||
raise ValueError("세부 업무는 상위 업무와 함께 옮겨집니다. 상위 업무를 옮기세요.")
|
||||
target = int(project_id)
|
||||
if int(prev["project_id"]) == target:
|
||||
raise ValueError("이미 이 프로젝트의 업무입니다.")
|
||||
if not conn.execute("SELECT 1 FROM projects WHERE id = %s", (target,)).fetchone():
|
||||
raise KeyError(f"프로젝트를 찾을 수 없습니다: {target}")
|
||||
new_stage = self._check_stage_in_project(conn, stage_id, target)
|
||||
ids = [int(r["id"]) for r in conn.execute(
|
||||
"WITH RECURSIVE tree AS (SELECT id FROM tasks WHERE id = %s "
|
||||
"UNION ALL SELECT t.id FROM tasks t JOIN tree ON t.parent_task_id = tree.id) "
|
||||
"SELECT id FROM tree",
|
||||
(task_id,),
|
||||
).fetchall()]
|
||||
nxt = conn.execute(
|
||||
"SELECT COALESCE(MAX(sort_order), -1) + 1 AS n FROM tasks WHERE project_id = %s",
|
||||
(target,),
|
||||
).fetchone()
|
||||
conn.execute("UPDATE tasks SET project_id = %s WHERE id = ANY(%s)", (target, ids))
|
||||
sets = ["stage_id = %s", "sort_order = %s"]
|
||||
params: list[Any] = [new_stage, int(nxt["n"])]
|
||||
if new_stage is not None and not (prev.get("assignee_email") or ""):
|
||||
dae, dan = self._stage_default_assignee(conn, new_stage, target, allowed=assignee_allowed)
|
||||
if dae:
|
||||
sets += ["assignee_email = %s", "assignee_name = %s"]
|
||||
params += [dae, dan]
|
||||
newly_assigned = dae
|
||||
if self._stage_is_done_conn(conn, new_stage) and not prev.get("completed_at"):
|
||||
sets.append("completed_at = %s")
|
||||
params.append(now_kst())
|
||||
newly_completed = True
|
||||
conn.execute(f"UPDATE tasks SET {', '.join(sets)} WHERE id = %s", (*params, task_id))
|
||||
conn.execute(
|
||||
"DELETE FROM task_project_links WHERE task_id = ANY(%s) AND project_id = %s", (ids, target))
|
||||
conn.execute("UPDATE project_activity SET project_id = %s WHERE task_id = ANY(%s)", (target, ids))
|
||||
conn.execute("UPDATE project_notifications SET project_id = %s WHERE task_id = ANY(%s)", (target, ids))
|
||||
if self._table_exists(conn, "goal_meeting_tasks"):
|
||||
conn.execute(
|
||||
"UPDATE goal_meeting_tasks SET project_id = %s, stage_id = %s WHERE task_id = %s",
|
||||
(target, new_stage, task_id))
|
||||
old_name = conn.execute("SELECT name FROM projects WHERE id = %s", (prev["project_id"],)).fetchone()
|
||||
new_name = conn.execute("SELECT name FROM projects WHERE id = %s", (target,)).fetchone()
|
||||
self._log(conn, project_id=target, task_id=task_id, actor=actor,
|
||||
action=store.ACTION_PROJECT_MOVED,
|
||||
detail=f"{prev['title']}: {(old_name or {}).get('name', '')} → {(new_name or {}).get('name', '')}")
|
||||
if newly_assigned:
|
||||
self._log(conn, project_id=target, task_id=task_id, actor=actor,
|
||||
action=store.ACTION_ASSIGNED, detail=f"{prev['title']} → {newly_assigned}")
|
||||
if newly_completed:
|
||||
self._log(conn, project_id=target, task_id=task_id, actor=actor,
|
||||
action=store.ACTION_COMPLETED, detail=prev["title"])
|
||||
out = self.get_task(task_id=task_id)
|
||||
if out is None:
|
||||
raise KeyError(task_id)
|
||||
out["_moved_ids"] = ids
|
||||
out["_newly_assigned"] = newly_assigned
|
||||
out["_newly_completed"] = newly_completed
|
||||
return out
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 휴지통 (마이그레이션 010) — 지우기 직전 스냅샷, 관리자 복구, 3개월 보관
|
||||
# ════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -1740,6 +1740,60 @@ def api_move_subtask(
|
||||
return JSONResponse({"task": task})
|
||||
|
||||
|
||||
@router.post("/api/tasks/{task_id}/move-project")
|
||||
def api_move_task_project(
|
||||
request: Request,
|
||||
task_id: int,
|
||||
bg: BackgroundTasks,
|
||||
payload: dict[str, Any] = Body(...),
|
||||
) -> JSONResponse:
|
||||
"""메인 업무를 다른 프로젝트로 옮긴다 — 보드 카드·목록 줄을 왼쪽 프로젝트 목록으로 드래그 → 섹션 선택 창.
|
||||
|
||||
body: {"project_id": 대상, "stage_id": 대상 섹션 또는 null}. 원 소속 권한(FULL) + 대상 프로젝트 멤버여야 한다.
|
||||
세부 업무는 함께 옮겨진다. 응답의 `unseen` = 대상 프로젝트를 볼 수 없는 담당자·협업자(화면이 안내).
|
||||
"""
|
||||
user = _require_user(request)
|
||||
st = _db_or_503(request)
|
||||
existing = _task_or_404(st, task_id)
|
||||
_require_task(st, user, existing, write=True)
|
||||
try:
|
||||
target = int(payload.get("project_id"))
|
||||
except (TypeError, ValueError):
|
||||
raise HTTPException(status_code=400, detail="옮길 프로젝트(project_id)가 필요합니다.")
|
||||
_require_manage(request, st, user, target)
|
||||
project = st.get_project(project_id=target)
|
||||
if project is None:
|
||||
raise HTTPException(status_code=404, detail="프로젝트를 찾을 수 없습니다.")
|
||||
try:
|
||||
task = st.move_task_to_project(
|
||||
task_id=task_id, project_id=target, stage_id=payload.get("stage_id"),
|
||||
actor=user["email"], assignee_allowed=_registered_project_user,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc))
|
||||
except KeyError as exc:
|
||||
raise HTTPException(status_code=404, detail=str(exc))
|
||||
task.pop("_moved_ids", None)
|
||||
newly_assigned = task.pop("_newly_assigned", None)
|
||||
if newly_assigned: # 대상 섹션 기본 담당자가 자동 배정됨 — 일반 배정과 같은 알림
|
||||
_follow(st, task["id"], [newly_assigned])
|
||||
_inbox(
|
||||
st, recipients=[newly_assigned], actor=user["email"], project_id=target, task_id=task["id"],
|
||||
ntype="assigned", title=f"업무 배정: {task['title']}",
|
||||
body=f"{project['name']} · 마감 {task.get('due_date') or '-'}",
|
||||
)
|
||||
if task.pop("_newly_completed", False):
|
||||
_notify_completed(bg, request, st, project=project, task=task, actor=user["email"])
|
||||
people = [task.get("assignee_email") or ""]
|
||||
try:
|
||||
people += st.list_followers(task_id=task_id)
|
||||
except Exception: # noqa: BLE001 - 008 미적용
|
||||
pass
|
||||
unseen = sorted({store.norm_str(e, lower=True) for e in people if e} -
|
||||
set(access.filter_recipients(st, task, [e for e in people if e])))
|
||||
return JSONResponse({"task": task, "unseen": unseen})
|
||||
|
||||
|
||||
# ────────────────────────────────────────────────────────────
|
||||
# JSON API — 팔로워 (아사나의 협업자)
|
||||
# ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -41,6 +41,7 @@ ACTION_COMPLETED = "completed"
|
||||
ACTION_STAGE_CHANGED = "stage_changed"
|
||||
ACTION_REOPENED = "reopened"
|
||||
ACTION_SUBTASK_MOVED = "subtask_moved" # 세부 업무를 다른 상위 업무로 옮김(보드 드래그)
|
||||
ACTION_PROJECT_MOVED = "project_moved" # 업무를 다른 프로젝트로 옮김(왼쪽 프로젝트 목록으로 드래그)
|
||||
|
||||
# 프로젝트 색상 팔레트 — 32색(8칸 × 4줄). 앞 16색은 아사나 프로젝트 색(아사나 색상표
|
||||
# 순서 그대로), 뒤 16색은 같은 칸(열)에 대응하는 진한 색 — 3줄째 = 1줄째의 진한 색,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "project/_meeting_content_base.html" if meeting_embedded else "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013c" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -298,5 +298,5 @@
|
||||
|
||||
<script src="/static/project-goal-text.js?v=20261003d" defer></script>
|
||||
<script src="/static/project-meeting-cells.js?v=20261012a" defer></script>
|
||||
<script src="/static/project.js?v=20261013b" defer></script>
|
||||
<script src="/static/project.js?v=20261013c" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013c" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -207,5 +207,5 @@
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project-goal-text.js?v=20261003d" defer></script>
|
||||
<script src="/static/project.js?v=20261013b" defer></script>
|
||||
<script src="/static/project.js?v=20261013c" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013c" />
|
||||
<link rel="stylesheet" href="/static/project-help.css?v=20261003a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013c" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -102,5 +102,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20261013b" defer></script>
|
||||
<script src="/static/project.js?v=20261013c" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013c" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -100,5 +100,5 @@
|
||||
"today": {{ today | tojson }}
|
||||
}
|
||||
</script>
|
||||
<script src="/static/project.js?v=20261013b" defer></script>
|
||||
<script src="/static/project.js?v=20261013c" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013c" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -108,5 +108,5 @@
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<script src="/static/project.js?v=20261013b" defer></script>
|
||||
<script src="/static/project.js?v=20261013c" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013c" />
|
||||
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — self-host -->
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
<!-- 타임라인 vis-timeline — self-host -->
|
||||
@@ -469,5 +469,5 @@
|
||||
</script>
|
||||
|
||||
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
|
||||
<script src="/static/project.js?v=20261013b" defer></script>
|
||||
<script src="/static/project.js?v=20261013c" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261013c" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -70,5 +70,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20261013b" defer></script>
|
||||
<script src="/static/project.js?v=20261013c" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1616,6 +1616,24 @@ img.pj-person-ic { width: 22px; height: 22px; }
|
||||
box-shadow: var(--pj-card-shadow); padding: 18px 20px 20px; min-width: 0;
|
||||
}
|
||||
.pj-dash-card-wide { grid-column: 1 / -1; }
|
||||
/* 업무 카드를 왼쪽 프로젝트에 끌어 놓을 때 — 놓일 프로젝트 줄 강조 */
|
||||
.pj-tree-row.is-task-drop { background: var(--pj-accent-tint); box-shadow: inset 0 0 0 2px var(--pj-accent); border-radius: 8px; }
|
||||
/* 다른 프로젝트로 이동 — 섹션 선택 창(body 에 붙음) */
|
||||
.pj-move-card { width: min(420px, 92vw); box-sizing: border-box; }
|
||||
.pj-move-card h3 { margin: 0 0 6px; }
|
||||
.pj-move-what { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
|
||||
.pj-move-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
|
||||
.pj-move-label { margin: 12px 0 6px; font-size: 12.5px; font-weight: 700; color: var(--pj-ink-soft); }
|
||||
.pj-move-stages { display: flex; flex-direction: column; gap: 4px; max-height: 46vh; overflow-y: auto; }
|
||||
.pj-move-stage {
|
||||
display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--pj-border); border-radius: 8px;
|
||||
cursor: pointer; font-size: 13.5px;
|
||||
}
|
||||
.pj-move-stage:hover { background: #f5f6f8; }
|
||||
.pj-move-stage:has(input:checked) { border-color: var(--pj-accent); background: var(--pj-accent-tint); }
|
||||
.pj-move-stage-name { flex: 1 1 auto; font-weight: 600; }
|
||||
.pj-move-stage small { flex-basis: 100%; color: var(--pj-ink-soft); font-size: 11.5px; }
|
||||
.pj-move-err { color: #c22b10; font-size: 12.5px; margin: 8px 0 0; }
|
||||
/* 업무 합계(프로젝트별) — 가로 막대 줄(채움 = 완료율) */
|
||||
.pj-dash-projbars { display: flex; flex-direction: column; gap: 4px; max-height: 210px; overflow-y: auto; margin: 0 -6px; }
|
||||
.pj-dash-projrow {
|
||||
|
||||
@@ -872,6 +872,9 @@
|
||||
'<circle cx="12" cy="9.6" r="3.1"/>' +
|
||||
'<path d="M6.8 17.2c1.1-2.2 3-3.3 5.2-3.3s4.1 1.1 5.2 3.3" stroke-linecap="round"/>' +
|
||||
"</svg>";
|
||||
// 보드 카드를 왼쪽 프로젝트 목록으로 끌어 다른 프로젝트로 옮길 때 쓰는 드래그 종류(값 = 업무 id).
|
||||
// 카드 안 섹션 이동은 예전처럼 text/plain — 사이드바는 이 종류만 받는다.
|
||||
const TASK_DRAG_TYPE = "application/x-pj-task";
|
||||
// 협업자 미지정 아이콘(점선 원 안의 두 사람) — 업무 창 세부 업무 줄.
|
||||
const FOLLOWER_EMPTY_ICON_SVG =
|
||||
'<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true">' +
|
||||
@@ -1641,6 +1644,41 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
// 업무 카드를 프로젝트 줄에 놓으면 → 그 프로젝트로 옮기기(섹션 선택 창은 프로젝트 화면이 연다, pj:task-to-project).
|
||||
// 사이드바는 한 번만 연결 — 목록은 다시 그려도 side 는 그대로다.
|
||||
function clearTaskDrop() {
|
||||
side.querySelectorAll(".pj-tree-row.is-task-drop").forEach(function (r) { r.classList.remove("is-task-drop"); });
|
||||
}
|
||||
function taskDropLi(e) {
|
||||
const li = e.target.closest && e.target.closest(".pj-tree-li[data-id]");
|
||||
return li && side.contains(li) ? li : null;
|
||||
}
|
||||
side.addEventListener("dragover", function (e) {
|
||||
if (!e.dataTransfer || !Array.prototype.includes.call(e.dataTransfer.types || [], TASK_DRAG_TYPE)) return;
|
||||
const li = taskDropLi(e);
|
||||
clearTaskDrop();
|
||||
if (!li) return;
|
||||
e.preventDefault();
|
||||
e.dataTransfer.dropEffect = "move";
|
||||
const row = li.querySelector(".pj-tree-row");
|
||||
if (row) row.classList.add("is-task-drop");
|
||||
});
|
||||
side.addEventListener("dragleave", function (e) { if (!side.contains(e.relatedTarget)) clearTaskDrop(); });
|
||||
side.addEventListener("drop", function (e) {
|
||||
if (!e.dataTransfer || !Array.prototype.includes.call(e.dataTransfer.types || [], TASK_DRAG_TYPE)) return;
|
||||
const li = taskDropLi(e);
|
||||
clearTaskDrop();
|
||||
if (!li) return;
|
||||
e.preventDefault();
|
||||
const taskId = parseInt(e.dataTransfer.getData(TASK_DRAG_TYPE), 10);
|
||||
const pid = parseInt(li.dataset.id, 10);
|
||||
const p = projects.find(function (x) { return String(x.id) === String(pid); }) || {};
|
||||
if (!taskId || !pid) return;
|
||||
document.dispatchEvent(new CustomEvent("pj:task-to-project", {
|
||||
detail: { taskId: taskId, projectId: pid, name: p.name || "", color: p.color || "" },
|
||||
}));
|
||||
});
|
||||
document.addEventListener("dragend", clearTaskDrop);
|
||||
function merge(p) {
|
||||
const i = projects.findIndex(function (x) { return String(x.id) === String(p.id); });
|
||||
if (i >= 0) projects[i] = Object.assign({}, projects[i], p);
|
||||
@@ -5017,6 +5055,100 @@
|
||||
return memberCacheByProject[pid];
|
||||
}
|
||||
|
||||
// ── 다른 프로젝트로 옮기기(2026-10-13) — 보드 카드를 왼쪽 프로젝트 목록에 놓으면 섹션 선택 창 → move-project.
|
||||
// 창은 body 에 붙인다(화면 배율 밖). 세부 업무는 함께 옮겨진다.
|
||||
let moveModalEl = null;
|
||||
function closeMoveModal() {
|
||||
if (!moveModalEl) return;
|
||||
moveModalEl.remove();
|
||||
moveModalEl = null;
|
||||
document.removeEventListener("keydown", onMoveKey, true);
|
||||
}
|
||||
function onMoveKey(e) {
|
||||
if (!moveModalEl) return;
|
||||
if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); closeMoveModal(); }
|
||||
else if (e.key === "Enter" && !e.isComposing && !e.target.closest("button")) {
|
||||
e.preventDefault(); const ok = moveModalEl.querySelector("[data-move-ok]"); if (ok && !ok.disabled) ok.click();
|
||||
}
|
||||
}
|
||||
async function openMoveToProject(t, target) {
|
||||
closeMoveModal();
|
||||
let stageList;
|
||||
try {
|
||||
const res = await api("GET", "/project/api/projects/" + target.projectId + "/stages");
|
||||
stageList = (res.stages || []).slice().sort(function (a, b) { return a.sort_order - b.sort_order; });
|
||||
} catch (e) {
|
||||
showToast(e.status === 403 ? "'" + target.name + "' 프로젝트 멤버만 업무를 옮겨 넣을 수 있습니다." : "섹션을 불러오지 못했습니다: " + e.message, "error");
|
||||
return;
|
||||
}
|
||||
const m = document.createElement("div");
|
||||
m.className = "pj-modal pj-move-modal";
|
||||
const nSub = t.subtask_total || 0;
|
||||
const options = stageList.length
|
||||
? stageList.map(function (s, i) {
|
||||
return '<label class="pj-move-stage"><input type="radio" name="pj-move-stage" value="' + s.id + '"' +
|
||||
(i === stageList.findIndex(function (x) { return !x.is_done_stage; }) ? " checked" : "") + " />" +
|
||||
'<span class="pj-move-stage-name"></span>' + (s.is_done_stage ? '<span class="pj-chip pj-chip-sm">완료</span>' : "") + "</label>";
|
||||
}).join("")
|
||||
: '<label class="pj-move-stage"><input type="radio" name="pj-move-stage" value="" checked />' +
|
||||
'<span class="pj-move-stage-name">섹션 없음</span><small>이 프로젝트에는 아직 섹션이 없어 \'미지정\'으로 들어갑니다</small></label>';
|
||||
m.innerHTML =
|
||||
'<div class="pj-modal-card pj-move-card" role="dialog" aria-modal="true" aria-labelledby="pj-move-title">' +
|
||||
'<h3 id="pj-move-title">다른 프로젝트로 이동</h3>' +
|
||||
'<p class="pj-modal-hint pj-move-what"><b class="pj-move-task"></b> → <span class="pj-move-dot"></span><b class="pj-move-proj"></b></p>' +
|
||||
'<div class="pj-move-label">어느 섹션으로 옮길까요?</div>' +
|
||||
'<div class="pj-move-stages">' + options + "</div>" +
|
||||
(nSub ? '<p class="pj-modal-hint">세부 업무 ' + nSub + "개도 함께 옮겨집니다.</p>" : "") +
|
||||
'<p class="pj-move-err" role="alert" hidden></p>' +
|
||||
'<div class="pj-modal-actions"><span style="flex:1"></span>' +
|
||||
'<button type="button" class="pj-btn" data-move-cancel>취소</button>' +
|
||||
'<button type="button" class="pj-btn pj-btn-primary" data-move-ok>이동</button></div>' +
|
||||
"</div>";
|
||||
m.querySelector(".pj-move-task").textContent = "‘" + (t.title || "") + "’";
|
||||
m.querySelector(".pj-move-proj").textContent = target.name || "프로젝트";
|
||||
m.querySelector(".pj-move-dot").style.background = target.color || "var(--pj-accent)";
|
||||
m.querySelectorAll(".pj-move-stage-name").forEach(function (n, i) { if (stageList[i]) n.textContent = stageList[i].name; });
|
||||
if (stageList.length && !m.querySelector("input:checked")) m.querySelector("input").checked = true;
|
||||
document.body.appendChild(m);
|
||||
moveModalEl = m;
|
||||
document.addEventListener("keydown", onMoveKey, true);
|
||||
m.addEventListener("click", function (e) {
|
||||
if (e.target === m || e.target.closest("[data-move-cancel]")) closeMoveModal();
|
||||
});
|
||||
const ok = m.querySelector("[data-move-ok]");
|
||||
ok.addEventListener("click", async function () {
|
||||
const sel = m.querySelector("input:checked");
|
||||
const stageId = sel && sel.value ? parseInt(sel.value, 10) : null;
|
||||
const err = m.querySelector(".pj-move-err");
|
||||
ok.disabled = true; err.hidden = true;
|
||||
try {
|
||||
const res = await api("POST", "/project/api/tasks/" + t.id + "/move-project",
|
||||
{ project_id: target.projectId, stage_id: stageId });
|
||||
closeMoveModal();
|
||||
const st = stageList.find(function (s) { return s.id === stageId; });
|
||||
showToast("‘" + (t.title || "") + "’ 을(를) " + target.name + (st ? " · " + st.name : "") + "(으)로 옮겼습니다.");
|
||||
if (res.unseen && res.unseen.length) {
|
||||
showToast(res.unseen.map(idOf).join(", ") + " 님은 '" + target.name + "' 멤버가 아니라 이 업무를 볼 수 없습니다.", "error");
|
||||
}
|
||||
await softSyncProjectRef();
|
||||
} catch (e2) {
|
||||
err.textContent = "옮기지 못했습니다: " + e2.message;
|
||||
err.hidden = false;
|
||||
ok.disabled = false;
|
||||
}
|
||||
});
|
||||
setTimeout(function () { const c = m.querySelector("input:checked") || ok; if (c && c.isConnected) c.focus(); }, 0);
|
||||
}
|
||||
document.addEventListener("pj:task-to-project", function (e) {
|
||||
const d = e.detail || {};
|
||||
const t = tasks.find(function (x) { return x.id === d.taskId && x.context_project_id === x.project_id; }) ||
|
||||
tasks.find(function (x) { return x.id === d.taskId; });
|
||||
if (!t) return;
|
||||
if (t.parent_task_id) { showToast("세부 업무는 상위 업무와 함께 옮겨집니다.", "error"); return; }
|
||||
if (t.project_id === d.projectId) { showToast("이미 이 프로젝트의 업무입니다."); return; }
|
||||
openMoveToProject(t, d);
|
||||
});
|
||||
|
||||
async function applyTaskPatch(t, patch, failMsg) {
|
||||
try {
|
||||
const res = await api("PUT", "/project/api/tasks/" + t.id, patch);
|
||||
@@ -5679,6 +5811,8 @@
|
||||
if (canManage) {
|
||||
card.addEventListener("dragstart", function (e) {
|
||||
e.dataTransfer.setData("text/plain", String(t.id));
|
||||
// 왼쪽 프로젝트 목록에 놓으면 다른 프로젝트로 옮기기(원 소속 업무만 — 연결로 보이는 카드는 원 소속에서 옮긴다)
|
||||
if (t.context_project_id === t.project_id || !t.is_linked) e.dataTransfer.setData(TASK_DRAG_TYPE, String(t.id));
|
||||
card.classList.add("is-dragging");
|
||||
});
|
||||
card.addEventListener("dragend", function () { card.classList.remove("is-dragging"); });
|
||||
|
||||
@@ -1284,6 +1284,21 @@ Windows 트레이 프로그램 **DBX 알림**(`desktop/notifier/`, C# .NET Frame
|
||||
- 검증: `tests/test_project_module.py::test_create_with_followers_and_my_overdue`(실제 PG), `tests/js/project_ui.test.js`
|
||||
([세부 추가 협업자]·[카드 세부 협업자]·[카드 새 세부 협업자]·[대시보드 프로젝트별]), `tests/js/overdue_ui.test.js`.
|
||||
|
||||
## 6-18. 업무를 다른 프로젝트로 이동 — 왼쪽 프로젝트 목록으로 드래그 (2026-10-13, 마이그레이션 없음)
|
||||
|
||||
- **화면**: 보드 카드를 끌어 왼쪽 사이드바의 프로젝트 줄에 놓는다(놓일 줄 강조 `.pj-tree-row.is-task-drop`). 카드 드래그는 섹션 이동용
|
||||
`text/plain` 에 더해 `application/x-pj-task`(= 업무 id, `TASK_DRAG_TYPE`)를 싣고, 사이드바(`initSideTree`)는 이 종류만 받아
|
||||
`pj:task-to-project` 이벤트를 낸다 → 프로젝트 화면이 **섹션 선택 창**(`openMoveToProject`, body 에 붙음 — 대상 프로젝트 섹션 목록,
|
||||
첫 진행 섹션이 기본, 섹션이 없으면 "섹션 없음") → [이동](Enter) = `POST /api/tasks/{id}/move-project` → `softSyncProjectRef` 로 다시 그림.
|
||||
같은 프로젝트·세부 업무는 창 없이 안내. 대상 프로젝트 멤버가 아니면 섹션 목록 조회가 403 → 안내.
|
||||
- **API** `POST /api/tasks/{id}/move-project` `{project_id, stage_id|null}` — 원 소속 권한(FULL) + 대상 프로젝트 관리 권한(멤버, 403).
|
||||
`db.move_task_to_project` 한 트랜잭션: 메인 업무만(세부 업무면 400, 같은 프로젝트 400, 남의 섹션 400), 세부 업무(모든 단계)도 project_id 변경,
|
||||
대상 섹션 목록 끝, 섹션 이동과 같은 규칙(담당자가 비면 섹션 기본 담당자 — 배정 알림, 완료 섹션이면 완료 — 완료 알림), 대상 프로젝트로의
|
||||
연결(`task_project_links`)은 지움(다른 연결은 유지), `project_activity`·`project_notifications`·`goal_meeting_tasks` 의 프로젝트도 따라 바꿈,
|
||||
활동 `project_moved`("업무: 옛 프로젝트 → 새 프로젝트"). 응답 `unseen` = 대상 프로젝트를 볼 수 없는 담당자·협업자(화면이 안내 — 담당자는 그대로 둔다).
|
||||
- 아직 안 되는 것: 목록·캘린더·타임라인 보기에서 끌기(보드 카드만), 이동 되돌리기(다시 끌어 옮기면 됨).
|
||||
- 검증: `tests/test_project_module.py::test_move_task_to_other_project`(실제 PG), `tests/js/project_ui.test.js` [프로젝트 이동].
|
||||
|
||||
## 7. 추후 단계
|
||||
|
||||
작업 라벨(태그 분류) · 반복 작업 · 템플릿 · 작업 의존성.
|
||||
|
||||
@@ -773,6 +773,48 @@ function titleVal(d) { return d.getElementById("pj-t-title").value; }
|
||||
check("[세부 업무 협업자] 고른 뒤 메뉴가 다시 열려 이어서 고름", !!d.querySelector(".pj-ctxmenu"));
|
||||
d.dispatchEvent(new env.w.KeyboardEvent("keydown", { key: "Escape", bubbles: true })); await settle();
|
||||
}
|
||||
// ── 업무 카드를 왼쪽 프로젝트로 끌어 다른 프로젝트로 이동(2026-10-13) — 섹션 선택 창 → move-project ──
|
||||
{
|
||||
const env = makeEnv(); baseRoutes(env);
|
||||
const moves = [];
|
||||
env.route("GET", /\/project\/api\/projects\/2\/stages$/, function () {
|
||||
return { body: { stages: [
|
||||
{ id: 22, project_id: 2, name: "진행", is_done_stage: false, sort_order: 1 },
|
||||
{ id: 21, project_id: 2, name: "할 일", is_done_stage: false, sort_order: 0 },
|
||||
{ id: 23, project_id: 2, name: "완료", is_done_stage: true, sort_order: 2 }] } };
|
||||
});
|
||||
env.route("POST", /\/project\/api\/tasks\/101\/move-project$/, function (u, b) {
|
||||
moves.push(b); return { body: { task: detail(101, "작업 A", { project_id: 2, stage_id: b.stage_id }), unseen: [] } };
|
||||
});
|
||||
await boot(env); const d = env.d, w = env.w;
|
||||
const data = {}; const transfer = { types: [], dropEffect: "", effectAllowed: "",
|
||||
setData: function (k, v) { data[k] = v; this.types.push(k); }, getData: function (k) { return data[k] || ""; } };
|
||||
function fire(el, kind) {
|
||||
const e = new w.MouseEvent(kind, { bubbles: true, cancelable: true });
|
||||
Object.defineProperty(e, "dataTransfer", { value: transfer });
|
||||
el.dispatchEvent(e); return e;
|
||||
}
|
||||
const card = d.querySelector('.pj-card[data-task-id="101"]');
|
||||
fire(card, "dragstart");
|
||||
check("[프로젝트 이동] 카드 드래그에 이동 종류(업무 id)", data["application/x-pj-task"] === "101" && data["text/plain"] === "101");
|
||||
const li = d.querySelector('.pj-side .pj-tree-li[data-id="2"]');
|
||||
const over = fire(li.querySelector(".pj-tree-row") || li, "dragover");
|
||||
check("[프로젝트 이동] 왼쪽 프로젝트 줄 위 — 놓기 허용·강조", over.defaultPrevented && !!li.querySelector(".pj-tree-row.is-task-drop"));
|
||||
fire(li.querySelector(".pj-tree-row") || li, "drop"); await settle(); await settle();
|
||||
const modal = d.body.querySelector(".pj-move-modal");
|
||||
const names = modal ? Array.from(modal.querySelectorAll(".pj-move-stage-name")).map(function (n) { return n.textContent; }) : [];
|
||||
check("[프로젝트 이동] 섹션 선택 창(body 에, 섹션 순서대로, 첫 진행 섹션 선택)", !!modal && modal.parentElement === d.body &&
|
||||
JSON.stringify(names) === '["할 일","진행","완료"]' && modal.querySelector("input:checked").value === "21" &&
|
||||
/P2/.test(modal.textContent) && !li.querySelector(".is-task-drop"), [names, modal && modal.textContent]);
|
||||
modal.querySelector('input[value="22"]').checked = true;
|
||||
modal.querySelector("[data-move-ok]").click(); await settle(); await settle();
|
||||
check("[프로젝트 이동] [이동] → move-project(프로젝트·고른 섹션) 후 창 닫힘",
|
||||
moves.length === 1 && moves[0].project_id === 2 && moves[0].stage_id === 22 && !d.body.querySelector(".pj-move-modal"), moves);
|
||||
// 같은 프로젝트에 놓으면 창 없이 안내
|
||||
fire(card, "dragstart");
|
||||
fire(d.querySelector('.pj-side .pj-tree-li[data-id="1"]'), "drop"); await settle();
|
||||
check("[프로젝트 이동] 같은 프로젝트에 놓으면 창 없음", !d.body.querySelector(".pj-move-modal"));
|
||||
}
|
||||
// ── 세부 업무를 만들 때 협업자 같이(업무 창 추가 칸·보드 카드 새 줄) · 카드 기존 줄 협업자 · 대시보드 프로젝트별(2026-10-13) ──
|
||||
{
|
||||
const env = makeEnv(); baseRoutes(env);
|
||||
|
||||
@@ -1418,6 +1418,44 @@ def test_create_with_followers_and_my_overdue():
|
||||
assert not [x for x in req("GET", "/project/api/my-overdue", BOB).json()["tasks"] if x["project_id"] == p["id"]]
|
||||
|
||||
|
||||
def test_move_task_to_other_project():
|
||||
"""업무를 다른 프로젝트로 옮기기(2026-10-13) — 세부 업무 함께, 대상 섹션·기본 담당자·완료 섹션, 연결 정리, 권한."""
|
||||
a = _project("P-mvA", ADMIN, (ALICE, BOB))
|
||||
b = _project("P-mvB", ADMIN, (ALICE,))
|
||||
c = _project("P-mvC", ADMIN, (BOB,)) # ALICE 는 멤버 아님
|
||||
sa = _stage(a["id"], by=ADMIN)
|
||||
sb = _stage(b["id"], name="진행", by=ADMIN)
|
||||
sb_done = _stage(b["id"], name="완료", done=True, by=ADMIN)
|
||||
req("PUT", f"/project/api/projects/{b['id']}/stages/{sb['id']}", ADMIN, json={"default_assignee_email": ALICE})
|
||||
t = ST.create_task(project_id=a["id"], title="옮길 업무", stage_id=sa["id"], created_by=ALICE)
|
||||
sub = ST.create_task(project_id=a["id"], title="세부", parent_task_id=t["id"], created_by=ALICE)
|
||||
subsub = ST.create_task(project_id=a["id"], title="세부의 세부", parent_task_id=sub["id"], created_by=ALICE)
|
||||
assert req("POST", f"/project/api/tasks/{t['id']}/links", ALICE, json={"project_id": b["id"], "stage_id": sb["id"]}).status_code == 201
|
||||
url = f"/project/api/tasks/{t['id']}/move-project"
|
||||
# 권한 — 대상 프로젝트 멤버가 아니면 403, 세부 업무만은 400, 남의 섹션은 400, 같은 프로젝트는 400
|
||||
assert req("POST", url, ALICE, json={"project_id": c["id"], "stage_id": None}).status_code == 403
|
||||
assert req("POST", f"/project/api/tasks/{sub['id']}/move-project", ALICE, json={"project_id": b["id"]}).status_code == 400
|
||||
assert req("POST", url, ALICE, json={"project_id": b["id"], "stage_id": sa["id"]}).status_code == 400
|
||||
assert req("POST", url, ALICE, json={"project_id": a["id"], "stage_id": sa["id"]}).status_code == 400
|
||||
assert ST.get_task(task_id=t["id"])["project_id"] == a["id"]
|
||||
# 이동 — 세부 업무(모든 단계)까지 대상 프로젝트로, 섹션 기본 담당자 자동 배정, 대상 쪽 연결은 지움
|
||||
r = req("POST", url, ALICE, json={"project_id": b["id"], "stage_id": sb["id"]})
|
||||
assert r.status_code == 200, r.text
|
||||
moved = r.json()["task"]
|
||||
assert moved["project_id"] == b["id"] and moved["stage_id"] == sb["id"] and moved["assignee_email"] == ALICE
|
||||
assert ST.get_task(task_id=sub["id"])["project_id"] == b["id"] and ST.get_task(task_id=subsub["id"])["project_id"] == b["id"]
|
||||
assert _count("SELECT COUNT(*) AS n FROM task_project_links WHERE task_id=%s AND project_id=%s", t["id"], b["id"]) == 0
|
||||
assert _count("SELECT COUNT(*) AS n FROM project_activity WHERE task_id=%s AND action='project_moved' AND project_id=%s", t["id"], b["id"]) == 1
|
||||
# 옛 프로젝트 멤버(BOB, B 비멤버)는 이제 못 본다 / 새 프로젝트 멤버는 본다
|
||||
assert req("GET", f"/project/api/tasks/{t['id']}", BOB).status_code == 403
|
||||
assert req("GET", f"/project/api/tasks/{sub['id']}", ALICE).status_code == 200
|
||||
# 완료 섹션으로 옮기면 완료 처리
|
||||
t2 = ST.create_task(project_id=a["id"], title="완료로", stage_id=sa["id"], assignee_email=BOB, created_by=ALICE)
|
||||
r2 = req("POST", f"/project/api/tasks/{t2['id']}/move-project", ALICE, json={"project_id": b["id"], "stage_id": sb_done["id"]})
|
||||
assert r2.status_code == 200 and r2.json()["task"]["completed_at"]
|
||||
assert BOB in r2.json()["unseen"] # 담당자가 B 멤버가 아님 — 화면이 안내
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if not ENABLED:
|
||||
print("SKIP: PROJECT_TEST_DB_URL(localhost) not set")
|
||||
|
||||
Reference in New Issue
Block a user