feat(project): 업무를 왼쪽 프로젝트로 끌어 다른 프로젝트로 이동(섹션 선택 창)
- 보드 카드를 사이드바 프로젝트 줄에 놓으면 섹션 선택 창 → POST /api/tasks/{id}/move-project
- 세부 업무(모든 단계)까지 한 트랜잭션으로 이동, 섹션 기본 담당자·완료 섹션 규칙, 대상 쪽 연결 정리
- 원 소속 권한 + 대상 프로젝트 멤버만, 대상 프로젝트를 볼 수 없는 담당자·협업자는 화면에 안내
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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"); });
|
||||
|
||||
Reference in New Issue
Block a user