feat(project): 작업 팝업의 하위 작업 줄을 아사나식으로(드래그 순서·아이콘·날짜)

- ⠿ 손잡이로 끌어 하위 작업 순서 변경
  (PUT /project/api/tasks/{id}/subtasks/order → db.reorder_subtasks)
- 담당자는 아이콘만(아바타/점선 원), 누르면 아이콘+이름 메뉴
- 마감일은 날짜 글자만(없으면 점선 달력 아이콘), 누르면 아사나식 날짜 팝업
- 제목 칸은 글자 길이만큼, 줄의 빈 곳을 누르면 하위 작업 열기
- 완료는 ✓ 아이콘, 삭제는 우클릭 메뉴로(줄의 × 제거)
- 정적 파일 버전 20260925g

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 19:44:39 +09:00
parent ea15c90a61
commit 3620482913
9 changed files with 294 additions and 77 deletions
+11
View File
@@ -1277,6 +1277,17 @@ class ProjectStore:
([int(i) for i in ordered_ids], stage_id),
)
def reorder_subtasks(self, *, parent_task_id: int, ordered_ids: list[int]) -> None:
"""작업 팝업의 하위 작업 목록 드래그 재정렬 — 이 상위 작업의 하위 작업만
0부터 다시 매긴다(목록은 parent_task_id 로 먼저 거른 뒤 sort_order 순)."""
with self._pool.connection() as conn:
conn.execute(
"UPDATE tasks t SET sort_order = v.ord - 1 "
"FROM unnest(%s::bigint[]) WITH ORDINALITY AS v(id, ord) "
"WHERE t.id = v.id AND t.parent_task_id = %s",
([int(i) for i in ordered_ids], parent_task_id),
)
# ════════════════════════════════════════════════════════════
# 알림센터 (project_notifications)
# ════════════════════════════════════════════════════════════
+22
View File
@@ -1359,6 +1359,28 @@ def api_get_task(request: Request, task_id: int) -> JSONResponse:
return JSONResponse({"task": task})
@router.put("/api/tasks/{task_id}/subtasks/order")
def api_reorder_subtasks(
request: Request, task_id: int, payload: dict[str, Any] = Body(...)
) -> JSONResponse:
"""작업 팝업의 하위 작업 목록을 드래그로 재정렬. body: {"ordered_ids": [...]}"""
user = _require_user(request)
st = _db_or_503(request)
parent = st.get_task(task_id=task_id)
if parent is None:
raise HTTPException(status_code=404, detail="작업을 찾을 수 없습니다.")
_require_manage(request, st, user, parent["project_id"])
ids = payload.get("ordered_ids") or []
if not isinstance(ids, list) or not ids:
raise HTTPException(status_code=400, detail="ordered_ids 가 필요합니다.")
try:
ordered = [int(i) for i in ids]
except (TypeError, ValueError):
raise HTTPException(status_code=400, detail="ordered_ids 가 올바르지 않습니다.")
st.reorder_subtasks(parent_task_id=task_id, ordered_ids=ordered)
return JSONResponse({"ok": True})
@router.post("/api/tasks/{task_id}/move-parent")
def api_move_subtask(
request: Request,
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20260925f" />
<link rel="stylesheet" href="/static/project.css?v=20260925g" />
<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=20260925f" defer></script>
<script src="/static/project.js?v=20260925g" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20260925f" />
<link rel="stylesheet" href="/static/project.css?v=20260925g" />
<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=20260925f" defer></script>
<script src="/static/project.js?v=20260925g" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20260925f" />
<link rel="stylesheet" href="/static/project.css?v=20260925g" />
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — self-host -->
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
<!-- 타임라인 vis-timeline — self-host -->
@@ -465,5 +465,5 @@
</script>
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
<script src="/static/project.js?v=20260925f" defer></script>
<script src="/static/project.js?v=20260925g" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20260925f" />
<link rel="stylesheet" href="/static/project.css?v=20260925g" />
<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=20260925f" defer></script>
<script src="/static/project.js?v=20260925g" defer></script>
{% endblock %}
+57 -17
View File
@@ -922,27 +922,67 @@ label.pj-desc-fmtbtn { line-height: 26px; }
/* ── 하위 업무(인라인) ── */
.pj-subtask-list { list-style: none; margin: 0 0 8px; padding: 0; }
.pj-subtask-row { display: flex; align-items: center; gap: 6px; padding: 4px 2px; }
/* 완료된 하위 업무는 행 전체를 반투명하게(체크박스 포함) + 제목 취소선. */
.pj-subtask-row.is-done { opacity: .5; }
/* 하위 작업 한 줄(아사나식): ⠿ · ✓ · 제목(글자 폭만큼) · 빈 곳(누르면 열기) · 마감일 · 담당자 · › */
.pj-subtask-row {
display: flex; align-items: center; gap: 4px; padding: 3px 2px; min-height: 36px;
border-bottom: 1px solid #eef0f2; cursor: pointer; border-radius: 4px;
}
.pj-subtask-row:hover { background: #f6f7f8; }
.pj-subtask-row.is-dragging { opacity: .4; }
/* 완료된 하위 작업은 제목을 흐리게 + 취소선(아사나) */
.pj-subtask-row.is-done .pj-subtask-title { text-decoration: line-through; color: #9aa1a9; }
.pj-subtask-row input[type="checkbox"] { width: auto; margin: 0; flex: 0 0 auto; }
/* 하위 업무 열기(›) — 줄에 마우스를 올리면 진해진다 */
.pj-subtask-handle {
flex: 0 0 auto; display: inline-flex; width: 16px; justify-content: center;
color: #9aa1a9; cursor: grab; opacity: 0; transition: opacity .12s;
}
.pj-subtask-handle .material-symbols-outlined { font-size: 18px; }
.pj-subtask-row:hover .pj-subtask-handle { opacity: 1; }
.pj-subtask-check {
flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
width: 26px; height: 26px; padding: 0; border: none; background: transparent; border-radius: 50%;
color: #6d6e6f; cursor: pointer;
}
.pj-subtask-check .material-symbols-outlined { font-size: 21px; }
.pj-subtask-check:hover { color: #3f8f6b; }
.pj-subtask-row.is-done .pj-subtask-check { color: #3f8f6b; }
.pj-subtask-row.is-done .pj-subtask-check .material-symbols-outlined { font-variation-settings: "FILL" 1; }
.pj-subtask-title {
/* 폭은 JS(fitTitle)가 글자 길이만큼 인라인으로 준다. 공용 input[type=text]
규칙의 width:100% 는 인라인 폭이 이긴다. */
flex: 0 1 auto; min-width: 40px; max-width: 100%; cursor: text;
border: 1px solid transparent !important; background: transparent;
padding: 3px 6px !important; font-size: 14px !important; margin: 0 !important;
}
.pj-subtask-title:hover, .pj-subtask-title:focus { border-color: #d8dce2 !important; background: #fff; }
.pj-subtask-fill { flex: 1 1 0; align-self: stretch; min-width: 8px; }
/* 마감일 — 날짜 글자만(아사나). 없으면 줄에 마우스를 올릴 때만 점선 원 달력 아이콘 */
.pj-subtask-due {
flex: 0 0 auto; white-space: nowrap; font-size: 12px; color: var(--pj-ink-soft);
padding: 2px 4px; border-radius: 4px; cursor: pointer;
}
.pj-subtask-due:not(.is-empty):hover { background: #eceef0; }
.pj-subtask-due.is-overdue { color: #c22b10; }
.pj-subtask-due.is-soon { color: #3f8f6b; }
.pj-subtask-due.is-empty {
display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0;
border-radius: 50%; color: #6d6e6f; opacity: 0; transition: opacity .12s;
}
.pj-subtask-row:hover .pj-subtask-due.is-empty { opacity: 1; }
.pj-subtask-due.is-empty:hover { color: #1e1f21; background: #eceef0; }
/* 담당자 — 아이콘만(아바타 / 없으면 점선 원 사람 아이콘, 줄 hover 때만) */
.pj-subtask-av {
flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
width: 26px; height: 26px; border-radius: 50%; cursor: pointer; color: #6d6e6f;
}
.pj-subtask-av img.pj-person-ic { width: 22px; height: 22px; border-radius: 50%; }
.pj-subtask-av .pj-gicon { font-size: 22px; }
.pj-subtask-av.is-empty { opacity: 0; transition: opacity .12s; }
.pj-subtask-row:hover .pj-subtask-av.is-empty { opacity: 1; }
.pj-subtask-av.is-empty:hover { color: #1e1f21; background: #eceef0; }
/* 하위 작업 열기(›) — 줄에 마우스를 올리면 진해진다 */
.pj-subtask-open { flex: 0 0 auto; width: 26px; height: 26px; color: #9aa1a9; }
.pj-subtask-row:hover .pj-subtask-open { color: var(--pj-ink); }
.pj-subtask-open .material-symbols-outlined { font-size: 20px; }
.pj-subtask-title {
/* flex-basis 는 반드시 0(퍼센트 아님) — auto 로 두면 .pj-modal-card 의 공용
input[type=text] 규칙이 준 width:100% 로 넘어가 버려 한 줄 배치가 깨진다. */
flex: 1 1 0; width: auto !important; min-width: 0;
border: 1px solid transparent !important; background: transparent;
padding: 4px 6px !important; font-size: 13px !important; margin: 0 !important;
}
.pj-subtask-title:hover, .pj-subtask-title:focus { border-color: #d8dce2 !important; background: #fff; }
.pj-subtask-assignee {
flex: 0 0 auto; width: 110px !important; font-size: 12px !important; padding: 4px 6px !important; margin: 0 !important;
}
.pj-subtask-due { flex: 0 0 auto; width: 128px !important; font-size: 12px !important; padding: 4px 6px !important; margin: 0 !important; }
.pj-subtask-form { display: flex; gap: 6px; flex-wrap: wrap; }
.pj-subtask-form input[type="text"] {
flex: 1 1 120px; width: auto !important; min-width: 90px; margin: 0 !important;
+191 -52
View File
@@ -510,6 +510,13 @@
'<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>";
// 마감일 미지정 아이콘(아사나 모양: 점선 원 안의 달력) — 보드 카드·하위 작업 줄 공용.
const DUE_EMPTY_ICON_SVG =
'<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true">' +
'<circle cx="12" cy="12" r="10.3" stroke-dasharray="2.6 2.2"/>' +
'<rect x="7.3" y="8.2" width="9.4" height="8.6" rx="1.6"/>' +
'<path d="M7.3 11.2h9.4M9.8 6.8v2.4M14.2 6.8v2.4" stroke-linecap="round"/>' +
"</svg>";
function personIconHtml(email) {
if (!email) return '<span class="pj-person-ic is-empty">' + EMPTY_PERSON_SVG + "</span>";
const url = pageAvatarUrl(email);
@@ -3204,13 +3211,6 @@
: '<span class="pj-card-sub-av is-empty" data-tip="이 작업 배정">' + ASSIGN_EMPTY_ICON_SVG + "</span>") +
"</div>";
}
// 마감일 미지정 아이콘(아사나 모양: 점선 원 안의 달력).
const DUE_EMPTY_ICON_SVG =
'<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true">' +
'<circle cx="12" cy="12" r="10.3" stroke-dasharray="2.6 2.2"/>' +
'<rect x="7.3" y="8.2" width="9.4" height="8.6" rx="1.6"/>' +
'<path d="M7.3 11.2h9.4M9.8 6.8v2.4M14.2 6.8v2.4" stroke-linecap="round"/>' +
"</svg>";
// 담당자 미지정 아이콘(아사나 모양: 점선 원 안의 사람).
const ASSIGN_EMPTY_ICON_SVG =
'<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true">' +
@@ -4950,77 +4950,214 @@
const addBtn = el("pj-subtask-add");
let taskId = null, projectId = null, canDeleteFn = function () { return false; }, onChange = null, onOpen = null;
// 담당자 후보(프로젝트 멤버) — 줄마다 다시 받지 않게 프로젝트별로 한 번만.
const memberCache = {};
function memberEmails(pid) {
if (!memberCache[pid]) {
memberCache[pid] = api("GET", "/project/api/projects/" + pid + "/members")
.then(function (res) { return (res.members || []).map(function (m) { return m.user_email; }); })
.catch(function () { delete memberCache[pid]; return []; });
}
return memberCache[pid];
}
async function membersOptionsHtml(pid) {
try {
const res = await api("GET", "/project/api/projects/" + pid + "/members");
return (res.members || []).map(function (m) {
return '<option value="' + m.user_email + '">' + escapeHtml(idOf(m.user_email)) + "</option>";
}).join("");
} catch (_) { return ""; }
const emails = await memberEmails(pid);
return emails.map(function (e) {
return '<option value="' + escapeHtml(e) + '">' + escapeHtml(idOf(e)) + "</option>";
}).join("");
}
function rowEl(sub, optionsHtml) {
// 제목 칸은 글자 길이만큼만(아사나) — 남는 자리를 누르면 하위 작업이 열린다.
let measureCtx = null;
function fitTitle(inp) {
if (!inp.isConnected) return;
const cs = getComputedStyle(inp);
measureCtx = measureCtx || document.createElement("canvas").getContext("2d");
const text = inp.value || inp.placeholder || "";
if (!measureCtx) { inp.style.width = (text.length * 1.1 + 2) + "em"; return; }
measureCtx.font = cs.fontWeight + " " + cs.fontSize + " " + cs.fontFamily;
const pad = parseFloat(cs.paddingLeft) + parseFloat(cs.paddingRight) +
parseFloat(cs.borderLeftWidth) + parseFloat(cs.borderRightWidth);
inp.style.width = Math.ceil(measureCtx.measureText(text).width + pad + 4) + "px";
}
// 하위 작업 한 줄(아사나식): ⠿ 끌어서 순서 변경 · ✓ 완료 · 제목(글자 폭만큼) ·
// [빈 곳 = 열기] · 마감일(날짜 글자만, 없으면 점선 달력 아이콘) · 담당자(아이콘만) · › 열기.
// 삭제는 우클릭 메뉴로(아사나처럼 줄에 × 없음).
function rowEl(sub, emails) {
const li = document.createElement("li");
li.className = "pj-subtask-row" + (sub.completed_at ? " is-done" : "");
li.dataset.id = sub.id;
li.innerHTML =
'<input type="checkbox" class="pj-subtask-done"' + (sub.completed_at ? " checked" : "") + " />" +
'<span class="pj-subtask-handle" title="드래그해서 순서 변경">' +
'<span class="material-symbols-outlined">drag_indicator</span></span>' +
'<button type="button" class="pj-subtask-check">' +
'<span class="material-symbols-outlined">check_circle</span></button>' +
'<input type="text" class="pj-subtask-title" />' +
'<select class="pj-subtask-assignee"><option value="">담당자 없음</option>' + optionsHtml + "</select>" +
'<input type="date" class="pj-subtask-due" />' +
'<span class="pj-subtask-fill"></span>' +
'<span class="pj-subtask-due"></span>' +
'<span class="pj-subtask-av"></span>' +
'<button type="button" class="pj-icon-btn pj-subtask-open" title="하위 작업 열기">' +
'<span class="material-symbols-outlined">chevron_right</span></button>' +
'<button type="button" class="pj-icon-btn pj-subtask-del" title="삭제" hidden>×</button>';
'<span class="material-symbols-outlined">chevron_right</span></button>';
const titleInp = li.querySelector(".pj-subtask-title");
// 열기 — 이 하위 업무를 업무처럼 팝업 전체로(설명·댓글·첨부·하위 업무까지).
li.querySelector(".pj-subtask-open").addEventListener("click", function () {
if (onOpen) onOpen(sub);
});
const doneChk = li.querySelector(".pj-subtask-done");
const assigneeSel = li.querySelector(".pj-subtask-assignee");
const dueInp = li.querySelector(".pj-subtask-due");
const delBtn = li.querySelector(".pj-subtask-del");
const checkBtn = li.querySelector(".pj-subtask-check");
const dueEl = li.querySelector(".pj-subtask-due");
const avEl = li.querySelector(".pj-subtask-av");
titleInp.value = sub.title || "";
assigneeSel.value = sub.assignee_email || "";
enhanceAssigneeSelect(assigneeSel);
dueInp.value = sub.due_date || "";
if (canDeleteFn(sub.created_by)) delBtn.hidden = false;
function renderCheck() {
li.classList.toggle("is-done", !!sub.completed_at);
checkBtn.title = sub.completed_at ? "완료 취소" : "완료로 표시";
}
function renderDue() {
const di = dueInfo(sub.due_date, !!sub.completed_at);
dueEl.className = "pj-subtask-due" + (di ? " " + di.cls : " is-empty");
dueEl.innerHTML = di ? escapeHtml(di.text) : DUE_EMPTY_ICON_SVG;
dueEl.title = sub.due_date ? "마감일 변경 (" + sub.due_date.slice(0, 10) + ")" : "마감일 추가";
}
function renderAv() {
const e = sub.assignee_email || "";
avEl.className = "pj-subtask-av" + (e ? "" : " is-empty");
avEl.innerHTML = personIconHtml(e);
avEl.title = e ? idOf(e) : "담당자 지정";
}
renderCheck(); renderDue(); renderAv();
async function patch(fields) {
try { await api("PUT", "/project/api/tasks/" + sub.id, fields); if (onChange) onChange(); }
catch (e) { alert("저장 실패: " + e.message); }
try {
const res = await api("PUT", "/project/api/tasks/" + sub.id, fields);
if (res && res.task) {
sub.completed_at = res.task.completed_at;
sub.due_date = res.task.due_date;
}
if (onChange) onChange();
return true;
} catch (e) { showToast("저장 실패: " + e.message, "error"); return false; }
}
titleInp.addEventListener("input", function () { fitTitle(titleInp); });
titleInp.addEventListener("keydown", function (e) { if (e.key === "Enter") { e.preventDefault(); titleInp.blur(); } });
titleInp.addEventListener("change", function () {
const v = titleInp.value.trim();
if (!v) { titleInp.value = sub.title || ""; return; }
if (!v) { titleInp.value = sub.title || ""; fitTitle(titleInp); return; }
sub.title = v; patch({ title: v });
});
doneChk.addEventListener("change", function () {
li.classList.toggle("is-done", doneChk.checked);
patch({ completed: doneChk.checked });
async function toggleDone() {
const done = !sub.completed_at;
sub.completed_at = done ? isoToday() : null;
renderCheck(); renderDue();
if (!(await patch({ completed: done }))) { sub.completed_at = done ? null : isoToday(); renderCheck(); renderDue(); }
}
checkBtn.addEventListener("click", function (e) { e.stopPropagation(); toggleDone(); });
// 마감일 — 보드와 같은 아사나식 날짜 팝업.
dueEl.addEventListener("click", function (e) {
e.stopPropagation();
openDatePopover(dueEl, {
due: sub.due_date, allowStart: false,
onChange: async function (p) {
const prev = sub.due_date;
sub.due_date = p.due_date || null;
renderDue();
if (!(await patch({ due_date: sub.due_date }))) { sub.due_date = prev; renderDue(); }
},
});
});
assigneeSel.addEventListener("change", function () {
const opt = assigneeSel.selectedOptions[0];
patch({ assignee_email: assigneeSel.value, assignee_name: opt ? opt.textContent : "" });
// 담당자 — 아이콘만. 누르면 "아이콘 + 이름" 메뉴(아사나).
avEl.addEventListener("click", function (e) {
e.stopPropagation();
const r = avEl.getBoundingClientRect();
showContextMenu(r.left, r.bottom + 4, assigneeMenuItems(emails, sub.assignee_email, async function (v) {
if ((v || "") === (sub.assignee_email || "")) return;
const prev = sub.assignee_email;
sub.assignee_email = v;
renderAv();
if (!(await patch({ assignee_email: v, assignee_name: v ? idOf(v) : "" }))) { sub.assignee_email = prev; renderAv(); }
}));
});
dueInp.addEventListener("change", function () { patch({ due_date: dueInp.value || null }); });
delBtn.addEventListener("click", async function () {
if (!(await confirmTaskDelete(sub.id, sub.title, null))) return;
try {
await deleteTaskRequest(sub.id);
li.remove();
if (onChange) onChange();
} catch (e) { alert("삭제 실패: " + e.message); }
function open() { if (onOpen) onOpen(sub); }
li.querySelector(".pj-subtask-open").addEventListener("click", function (e) { e.stopPropagation(); open(); });
// 제목 칸·아이콘 말고 줄의 나머지(빈 곳)를 누르면 하위 작업 열기(아사나).
li.addEventListener("click", function (e) {
if (e.target.closest(".pj-subtask-title, .pj-subtask-handle, button, .pj-subtask-due, .pj-subtask-av")) return;
open();
});
// 우클릭 — 열기 / 완료 / 삭제.
li.addEventListener("contextmenu", function (e) {
e.preventDefault();
const items = [
{ label: "열기", onClick: open },
{ label: sub.completed_at ? "완료 취소" : "완료로 표시", onClick: toggleDone },
];
if (canDeleteFn(sub.created_by)) {
items.push(null, {
label: "하위 작업 삭제", danger: true,
onClick: async function () {
if (!(await confirmTaskDelete(sub.id, sub.title, null))) return;
try {
await deleteTaskRequest(sub.id);
li.remove();
if (!listEl.querySelector(".pj-subtask-row")) listEl.innerHTML = "<li class='pj-empty-sm'>없음</li>";
if (onChange) onChange();
} catch (err) { showToast("삭제 실패: " + err.message, "error"); }
},
});
}
showContextMenu(e.clientX, e.clientY, items);
});
// 끌어서 순서 변경 — ⠿ 손잡이를 잡았을 때만 줄이 끌린다(제목 글자 선택과 안 섞이게).
const handle = li.querySelector(".pj-subtask-handle");
handle.addEventListener("mousedown", function () { li.draggable = true; });
li.addEventListener("dragstart", function (e) {
if (!li.draggable) return;
dragRow = li;
e.dataTransfer.setData("application/x-pj-subrow", String(sub.id));
e.dataTransfer.effectAllowed = "move";
li.classList.add("is-dragging");
});
li.addEventListener("dragend", function () {
li.draggable = false;
li.classList.remove("is-dragging");
dragRow = null;
});
return li;
}
// 하위 작업 줄 드래그 재정렬 — 목록(ul) 하나에 한 번만 건다.
let dragRow = null;
let orderBefore = "";
listEl.addEventListener("dragstart", function () {
orderBefore = rowIds().join(",");
});
function rowIds() {
return Array.prototype.map.call(listEl.querySelectorAll(".pj-subtask-row"), function (r) {
return parseInt(r.dataset.id, 10);
});
}
listEl.addEventListener("dragover", function (e) {
if (!dragRow) return;
e.preventDefault();
const over = e.target.closest(".pj-subtask-row");
if (!over || over === dragRow) return;
const r = over.getBoundingClientRect();
listEl.insertBefore(dragRow, (e.clientY - r.top) < r.height / 2 ? over : over.nextSibling);
});
listEl.addEventListener("drop", async function (e) {
if (!dragRow) return;
e.preventDefault();
const ids = rowIds();
if (ids.join(",") === orderBefore || !taskId) return;
try {
await api("PUT", "/project/api/tasks/" + taskId + "/subtasks/order", { ordered_ids: ids });
if (onChange) onChange();
} catch (err) { showToast("순서 변경 실패: " + err.message, "error"); }
});
async function render(subtasks) {
listEl.innerHTML = subtasks.length ? "" : "<li class='pj-empty-sm'>없음</li>";
if (!subtasks.length) return;
const optionsHtml = projectId ? await membersOptionsHtml(projectId) : "";
const emails = projectId ? await memberEmails(projectId) : [];
listEl.innerHTML = "";
subtasks.forEach(function (sub) { listEl.appendChild(rowEl(sub, optionsHtml)); });
subtasks.forEach(function (sub) { listEl.appendChild(rowEl(sub, emails)); });
listEl.querySelectorAll(".pj-subtask-title").forEach(fitTitle);
}
if (addBtn) addBtn.addEventListener("click", async function () {
@@ -5038,10 +5175,12 @@
input.value = "";
if (addAssignee) addAssignee.value = "";
if (addDue) addDue.value = "";
const optionsHtml = await membersOptionsHtml(projectId);
const emails = await memberEmails(projectId);
const empty = listEl.querySelector(".pj-empty-sm");
if (empty) empty.remove();
listEl.appendChild(rowEl(res.task, optionsHtml));
const row = rowEl(res.task, emails);
listEl.appendChild(row);
fitTitle(row.querySelector(".pj-subtask-title"));
if (onChange) onChange();
} catch (e) { alert("추가 실패: " + e.message); }
});
+5
View File
@@ -52,6 +52,11 @@
작업 팝업 하위 작업 줄의 › 버튼, 공유 링크로 연다(`openTaskById`). 제목 위에 상위 작업 경로
(`#pj-t-parent`, 누르면 상위 작업으로 — `GET /api/tasks/{id}` 가 `parent_title` 을 준다),
섹션 칸·다른 프로젝트 연결은 숨긴다. 저장해도 보드 목록(`tasks`)엔 넣지 않는다(`mergeTask`).
작업 팝업의 하위 작업 줄(`initSubtaskBlock`)도 아사나식 — ⠿ 손잡이로 끌어 순서 변경
(`PUT /api/tasks/{id}/subtasks/order` → `db.reorder_subtasks`), ✓ 완료, 제목 칸은 글자 폭만큼
(`fitTitle`)이고 줄의 빈 곳을 누르면 하위 작업 열기, 마감일은 날짜 글자만(없으면 점선 달력
아이콘, 누르면 아사나식 날짜 팝업 `openDatePopover`), 담당자는 아이콘만(누르면 아이콘+이름 메뉴).
삭제는 우클릭 메뉴(줄에 × 없음).
- **멀티호밍(다른 프로젝트에 연결)** — `task_project_links` 테이블. 작업 하나가
원래 소속(기본 홈, `tasks.project_id`/`stage_id`)과 무관하게 다른 프로젝트의
한 섹션에도 동시에 나타날 수 있다(아사나의 "Add to project"). 작업 편집