feat(project): add Asana-style board completion checks

This commit is contained in:
2026-10-02 17:55:31 +09:00
parent 20232baf06
commit 22af196d56
11 changed files with 88 additions and 15 deletions
+30 -1
View File
@@ -5227,6 +5227,7 @@
});
}
const cardCompletionSaving = new Set();
function taskCard(t) {
const card = document.createElement("div");
card.className = "pj-card" + (t.completed_at ? " is-done" : "");
@@ -5247,7 +5248,13 @@
(showProjTag && t.project_name
? '<div class="pj-card-proj" style="color:' + (t.project_color || "#4573d2") + '">● ' + escapeHtml(t.project_name) + "</div>"
: "") +
'<div class="pj-card-title">' + escapeHtml(t.title) + "</div>" +
'<div class="pj-card-title-row"><button type="button" class="pj-card-check" role="checkbox" aria-checked="' + (!!t.completed_at) +
'" aria-label="' + escapeHtml((t.completed_at ? "완료 취소: " : "완료로 표시: ") + t.title) +
'" title="' + (t.completed_at ? "완료 취소" : "완료로 표시") + '"' +
(!(canManage && taskAccessLevel(t) === "full") || cardCompletionSaving.has(t.id) ? " disabled" : "") +
(cardCompletionSaving.has(t.id) ? ' aria-busy="true"' : "") +
'><span class="material-symbols-outlined" aria-hidden="true">check_circle</span></button>' +
'<div class="pj-card-title">' + escapeHtml(t.title) + "</div></div>" +
'<div class="pj-card-meta">' +
(t.priority && t.priority !== "normal"
? '<span class="pj-pri pj-pri-' + t.priority + '">' + (priorityLabels[t.priority] || t.priority) + "</span>"
@@ -5301,6 +5308,28 @@
: "");
const subsBox = card.querySelector(".pj-card-subs");
if (subsBox) fillCardSubs(subsBox, t);
const check = card.querySelector(".pj-card-check");
check.addEventListener("click", async function (e) {
e.stopPropagation();
if (!canManage || taskAccessLevel(t) !== "full" || cardCompletionSaving.has(t.id)) return;
cardCompletionSaving.add(t.id); check.disabled = true; check.setAttribute("aria-busy", "true");
let updated = false;
const hadFocus = document.activeElement === check;
try {
const res = await api("PUT", "/project/api/tasks/" + t.id, { completed: !t.completed_at });
mergeTask(res.task); updated = true;
} catch (err) { showToast("완료 상태 변경 실패: " + err.message, "error"); }
finally {
cardCompletionSaving.delete(t.id);
const restoreFocus = hadFocus && (document.activeElement === check || document.activeElement === document.body);
refreshActiveView();
if (restoreFocus) {
const liveCheck = document.querySelector('.pj-card[data-task-id="' + t.id + '"] .pj-card-check');
if (liveCheck) liveCheck.focus();
}
}
if (updated) refreshMyOpenBadge();
});
card.addEventListener("click", function (e) {
// 하위 업무 펼치기/접기 — 보기 권한만 있어도 된다.
const tog = e.target.closest(".pj-card-subtoggle");