fix(project): review fixes — access leaks, open paths, save safety, concurrency
- Subproject tasks via parent /tasks are re-filtered by current access (FULL/READ kept)
- PUT /api/projects/order: every id must be manageable; bad/duplicate ids -> 400, all-or-nothing
- Inbox, web alert popup, PC notifier open tasks via /project/t/{id}; embed=1 survives redirect;
old /p/{home}?task= redirects READ users to the linked project
- Project page / snapshot / workload include the opened archived or sub project only
- Alerts: DB-side filters + oldest-first paging (no 50-row cut); badges counted without caps;
my tasks keep every open task (completed capped)
- Meeting results: next-week meeting open, or own meeting open when no next meeting;
header edits + result checks under row locks (FOR UPDATE / FOR SHARE)
- Inbox panel waits for the task window save (same retry/discard flow) before switching/closing;
read failures stay unread
- Attachment upload removes only its own file on DB failure
- New project modal: create once, retry only failed member assignments
- update_task / update_project: locked-row validation in one transaction; completion hints from real transition
- Creator added as explicit member when another owner is chosen
- _once lock lifetime managed by refcount (no leak on failure)
- Section default assignee must still be a registered project user; follower add uses can_assign
- Docs (PROJECT_MODULE 6-15, help), tests (DB-less, real PostgreSQL, jsdom, Chrome)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+242
-75
@@ -1294,32 +1294,101 @@
|
||||
membersBox.innerHTML = "<span class='pj-empty-sm'>불러오기 실패</span>";
|
||||
}
|
||||
});
|
||||
el("pj-save-project").addEventListener("click", async function () {
|
||||
// 만들기는 두 단계 — ① 프로젝트 생성(한 번만) ② 고른 멤버 배정(사람마다). 생성이 끝난 뒤 배정이 실패하면
|
||||
// 창을 닫지 않고 실패한 사람을 표시한다 — [다시 배정]은 실패한 사람만 다시 보내고 프로젝트를 또 만들지 않는다.
|
||||
// 진행 중 연타는 무시하고, 진행 중 [취소]·바깥 클릭으로 닫아도 요청은 끝까지 가며 결과는 알림으로 알린다.
|
||||
const saveBtn = el("pj-save-project");
|
||||
const msgBox = el("pj-f-project-msg");
|
||||
let created = null; // 이번 창에서 이미 만든 프로젝트(다시 배정 때 재사용)
|
||||
let assigned = new Set(); // 이미 배정에 성공한 이메일
|
||||
let saving = false;
|
||||
function setMsg(html, isError) {
|
||||
if (!msgBox) return;
|
||||
msgBox.hidden = !html;
|
||||
msgBox.innerHTML = html || "";
|
||||
msgBox.classList.toggle("is-error", !!isError);
|
||||
}
|
||||
function resetForm() {
|
||||
created = null;
|
||||
assigned = new Set();
|
||||
setMsg("");
|
||||
saveBtn.textContent = "만들기";
|
||||
["pj-f-name", "pj-f-desc", "pj-f-due"].forEach(function (id) { el(id).value = ""; el(id).disabled = false; });
|
||||
if (membersBox) membersBox.querySelectorAll(".pj-member-pick").forEach(function (l) { l.classList.remove("is-failed"); });
|
||||
getColor = renderColorPalette(el("pj-f-colors"), null, "#4573d2");
|
||||
getIcon = renderIconPalette(el("pj-f-icons"), "");
|
||||
}
|
||||
function finish() {
|
||||
const p = created;
|
||||
closeModal(modal);
|
||||
resetForm();
|
||||
if (p && onCreated) onCreated(p);
|
||||
}
|
||||
// 만든 뒤 배정에 실패한 채로 창을 닫으면 — 만든 프로젝트로 넘어간다(멤버는 프로젝트 화면에서 다시 배정).
|
||||
new MutationObserver(function () {
|
||||
if (!modal.hidden || saving || !created) return;
|
||||
showToast("프로젝트는 만들어졌습니다. 배정하지 못한 멤버는 프로젝트 화면에서 다시 배정하세요.", "error");
|
||||
finish();
|
||||
}).observe(modal, { attributes: true, attributeFilter: ["hidden"] });
|
||||
saveBtn.addEventListener("click", async function () {
|
||||
if (saving) return;
|
||||
const name = el("pj-f-name").value.trim();
|
||||
if (!name) { alert("이름을 입력하세요."); return; }
|
||||
const memberEmails = membersBox
|
||||
? Array.from(membersBox.querySelectorAll("input[type=checkbox]:checked")).map(function (c) { return c.value; })
|
||||
if (!created && !name) { alert("이름을 입력하세요."); return; }
|
||||
const picked = membersBox
|
||||
? Array.from(membersBox.querySelectorAll("input[type=checkbox]:checked"))
|
||||
: [];
|
||||
saving = true;
|
||||
saveBtn.disabled = true;
|
||||
try {
|
||||
const res = await api("POST", "/project/api/projects", {
|
||||
name: name,
|
||||
description: el("pj-f-desc").value.trim(),
|
||||
due_date: el("pj-f-due").value || null,
|
||||
color: getColor(),
|
||||
icon: getIcon() || undefined,
|
||||
});
|
||||
const pid = res.project.id;
|
||||
for (const email of memberEmails) {
|
||||
try { await api("POST", "/project/api/projects/" + pid + "/members", { user_email: email }); }
|
||||
catch (_) {}
|
||||
if (!created) {
|
||||
try {
|
||||
const res = await api("POST", "/project/api/projects", {
|
||||
name: name,
|
||||
description: el("pj-f-desc").value.trim(),
|
||||
due_date: el("pj-f-due").value || null,
|
||||
color: getColor(),
|
||||
icon: getIcon() || undefined,
|
||||
});
|
||||
created = res.project;
|
||||
} catch (e) {
|
||||
if (modal.hidden) showToast("프로젝트를 만들지 못했습니다: " + e.message, "error");
|
||||
else setMsg("프로젝트를 만들지 못했습니다: " + escapeHtml(e.message), true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
closeModal(modal);
|
||||
el("pj-f-name").value = ""; el("pj-f-desc").value = "";
|
||||
el("pj-f-due").value = "";
|
||||
getColor = renderColorPalette(el("pj-f-colors"), null, "#4573d2");
|
||||
getIcon = renderIconPalette(el("pj-f-icons"), "");
|
||||
if (onCreated) onCreated(res.project);
|
||||
} catch (e) { showToast("생성 실패: " + e.message, "error"); }
|
||||
const failed = [];
|
||||
for (const box of picked) {
|
||||
const email = box.value;
|
||||
if (assigned.has(email)) continue;
|
||||
const label = box.closest(".pj-member-pick");
|
||||
try {
|
||||
await api("POST", "/project/api/projects/" + created.id + "/members", { user_email: email });
|
||||
assigned.add(email);
|
||||
if (label) label.classList.remove("is-failed");
|
||||
} catch (e) {
|
||||
failed.push({ email: email, reason: e.message });
|
||||
if (label) label.classList.add("is-failed");
|
||||
}
|
||||
}
|
||||
if (!failed.length) {
|
||||
if (modal.hidden) { showToast("프로젝트를 만들었습니다."); }
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
// 생성은 됐다 — 이름 등은 더 바꿀 수 없게 잠그고, 실패한 멤버만 다시 보내게 한다.
|
||||
["pj-f-name", "pj-f-desc", "pj-f-due"].forEach(function (id) { el(id).disabled = true; });
|
||||
saveBtn.textContent = "실패한 멤버 다시 배정";
|
||||
const html = "프로젝트 '" + escapeHtml(created.name || name) + "' 는 만들어졌습니다. 멤버 " + failed.length +
|
||||
"명을 배정하지 못했습니다: " + failed.map(function (f) {
|
||||
return "<b>" + escapeHtml(idOf(f.email)) + "</b>(" + escapeHtml(f.reason) + ")";
|
||||
}).join(", ") + ". [실패한 멤버 다시 배정]을 누르거나, 창을 닫고 프로젝트 화면에서 배정하세요.";
|
||||
if (modal.hidden) showToast("프로젝트는 만들어졌지만 멤버 " + failed.length + "명을 배정하지 못했습니다.", "error");
|
||||
else setMsg(html, true);
|
||||
} finally {
|
||||
saving = false;
|
||||
saveBtn.disabled = false;
|
||||
if (modal.hidden && created) finish(); // 진행 중에 창을 닫았다 — 끝난 뒤 만든 프로젝트로
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1439,8 +1508,9 @@
|
||||
}
|
||||
function render() {
|
||||
let rootUl = el("pj-tree-root");
|
||||
const active = projects.filter(function (p) { return p.status !== "completed"; });
|
||||
const done = projects.filter(function (p) { return p.status === "completed"; });
|
||||
// view_only = 보관된 프로젝트·서브프로젝트를 직접 연 경우 화면용으로만 받은 것 — 목록엔 안 그린다.
|
||||
const active = projects.filter(function (p) { return p.status !== "completed" && !p.view_only; });
|
||||
const done = projects.filter(function (p) { return p.status === "completed" && !p.view_only; });
|
||||
const block = side.querySelector(".pj-tree-block");
|
||||
// 처음에 프로젝트가 하나도 없었으면 서버가 "프로젝트 없음" 만 그렸다 —
|
||||
// 새로 만들면 그때 목록(ul)을 만든다.
|
||||
@@ -3277,10 +3347,19 @@
|
||||
let taskFilter = Object.assign({}, TASK_FILTER_DEFAULT);
|
||||
try { Object.assign(taskFilter, JSON.parse(localStorage.getItem(FILTER_KEY) || "{}")); } catch (_) {}
|
||||
const todayNowP = kstTodayIso; // 한국시간 오늘(그때그때)
|
||||
// 전체 보기는 작업마다 한 행 — 원 소속 행이 있으면 그 행, 원 소속을 볼 수 없어 연결된 프로젝트의
|
||||
// 행(읽기 전용)만 있으면 그중 첫 행(예전엔 원 소속 행만 남겨 이런 작업이 전체 보기에서 빠졌다).
|
||||
function scopeTasks() {
|
||||
return viewScope === "project"
|
||||
? tasks.filter(function (t) { return t.context_project_id === projectId; })
|
||||
: tasks.filter(function (t) { return t.context_project_id === t.project_id; });
|
||||
if (viewScope === "project") return tasks.filter(function (t) { return t.context_project_id === projectId; });
|
||||
const home = new Set();
|
||||
tasks.forEach(function (t) { if (t.context_project_id === t.project_id) home.add(t.id); });
|
||||
const seen = new Set();
|
||||
return tasks.filter(function (t) {
|
||||
if (t.context_project_id === t.project_id) return true;
|
||||
if (home.has(t.id) || seen.has(t.id)) return false;
|
||||
seen.add(t.id);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
// 모든 뷰가 이 함수로 업무를 받는다 — 스코프 → 필터 → 정렬 순.
|
||||
function visibleTasks() {
|
||||
@@ -6451,6 +6530,22 @@
|
||||
closeSlidePanel(taskModal);
|
||||
} finally { taskClosing = false; }
|
||||
}
|
||||
// 수신함 오른쪽 작업 창(iframe, html.pj-embed) — 바깥(수신함)이 다른 줄로 바꾸거나 창을 닫기 전에 부른다.
|
||||
// 작업 창 닫기와 같은 절차(이미지 업로드·만들기·저장 대기 → 실패 칸 재시도 → "버리고 넘어가기 / 계속 편집").
|
||||
// true = 넘어가도 됨(이 창의 늦은 응답은 버린다), false = 계속 편집(창·입력 그대로).
|
||||
if (document.documentElement.classList.contains("pj-embed")) {
|
||||
let embedSettling = null;
|
||||
window.__pjEmbedSettle = function () {
|
||||
if (embedSettling) return embedSettling; // 저장 중 Esc·다른 줄 연타 — 같은 확인 하나를 기다린다
|
||||
embedSettling = (async function () {
|
||||
if (taskModal.hidden) return true;
|
||||
if (!(await settleBeforeLeave())) return false;
|
||||
taskGen++;
|
||||
return true;
|
||||
})();
|
||||
return embedSettling.finally(function () { embedSettling = null; });
|
||||
};
|
||||
}
|
||||
taskModal.addEventListener("click", function (e) {
|
||||
if (e.target === taskModal || e.target.closest("[data-close]")) attemptCloseTaskModal();
|
||||
});
|
||||
@@ -8566,21 +8661,39 @@
|
||||
const notiList = document.getElementById("pj-inbox");
|
||||
const counter = document.getElementById("pj-mention-unread");
|
||||
let panel = null;
|
||||
let selected = []; // 지금 작업 창에 열린 줄들(같은 작업의 태그·알림)
|
||||
let selected = []; // 지금 작업 창에 열린 줄들(같은 작업의 태그·알림)
|
||||
let shownLi = null; // 지금 작업 창에 열린 줄(대표) — 창이 닫혀 있으면 null
|
||||
// 창 바꾸기(다른 줄 열기·닫기)는 한 번에 하나만, 마지막 요청만 따른다 — 저장을 기다리는 사이
|
||||
// A→B→A 를 빨리 눌러도 확인이 끝난 뒤 그때 원하는 쪽으로 한 번만 바꾼다. undefined = 요청 없음, null = 닫기.
|
||||
let wanted;
|
||||
let switching = null;
|
||||
const readReq = new WeakMap(); // 줄 → 읽음/확인 요청(Promise<boolean>)
|
||||
|
||||
function itemsOfTask(li) {
|
||||
const tid = li.dataset.taskId;
|
||||
if (!tid) return [li];
|
||||
return Array.prototype.slice.call(document.querySelectorAll('.pj-inbox-item[data-task-id="' + tid + '"]'));
|
||||
}
|
||||
// 읽음/확인 — 서버가 받았을 때만 확인한 것으로 둔다. 실패하면 굵게(읽지 않음) 되돌리고 목록에 남긴다.
|
||||
function markSeen(li) {
|
||||
if (li.dataset.seen) return;
|
||||
li.dataset.seen = "1";
|
||||
if (readReq.has(li)) return readReq.get(li);
|
||||
if (li.dataset.seen === "1") return Promise.resolve(true);
|
||||
li.classList.remove("is-unread");
|
||||
const req = li.classList.contains("pj-mention-item")
|
||||
? api("POST", "/project/api/mentions/read", { task_id: Number(li.dataset.taskId) })
|
||||
: fetch("/project/api/notifications/" + li.dataset.id + "/read", { method: "POST" });
|
||||
Promise.resolve(req).catch(function () {});
|
||||
: fetch("/project/api/notifications/" + li.dataset.id + "/read", { method: "POST" })
|
||||
.then(function (res) { if (!res.ok) throw new Error("HTTP " + res.status); });
|
||||
const p = Promise.resolve(req).then(function () {
|
||||
li.dataset.seen = "1";
|
||||
return true;
|
||||
}, function (e) {
|
||||
readReq.delete(li); // 다음에 누르면 다시 보낸다
|
||||
li.classList.add("is-unread");
|
||||
showToast("확인 처리에 실패해 목록에 그대로 둡니다: " + ((e && e.message) || ""), "error");
|
||||
return false;
|
||||
});
|
||||
readReq.set(li, p);
|
||||
return p;
|
||||
}
|
||||
function refreshEmpty() {
|
||||
[[mentionList, "태그된 작업이 없습니다."], [notiList, "알림이 없습니다."]].forEach(function (x) {
|
||||
@@ -8598,29 +8711,52 @@
|
||||
counter.hidden = n <= 0;
|
||||
}
|
||||
}
|
||||
// 확인한 줄을 목록에서 뺀다(살짝 접히며).
|
||||
// 확인이 끝난(서버가 받은) 줄만 목록에서 뺀다(살짝 접히며). 실패한 줄·지금 열린 줄은 남긴다.
|
||||
function removeItems(list) {
|
||||
list.forEach(function (li) {
|
||||
if (!li.isConnected) return;
|
||||
li.classList.add("is-leaving");
|
||||
setTimeout(function () { li.remove(); refreshEmpty(); }, 220);
|
||||
Promise.resolve(readReq.get(li) || li.dataset.seen === "1").then(function (ok) {
|
||||
if (!ok || !li.isConnected || selected.indexOf(li) >= 0) return;
|
||||
li.classList.add("is-leaving");
|
||||
setTimeout(function () { li.remove(); refreshEmpty(); }, 220);
|
||||
});
|
||||
});
|
||||
}
|
||||
function setSelected(list) {
|
||||
const prev = selected;
|
||||
selected = list;
|
||||
prev.forEach(function (li) { li.classList.remove("is-selected"); });
|
||||
removeItems(prev.filter(function (li) { return list.indexOf(li) < 0; }));
|
||||
list.forEach(function (li) { li.classList.add("is-selected"); });
|
||||
removeItems(prev.filter(function (li) { return list.indexOf(li) < 0; }));
|
||||
}
|
||||
function close() {
|
||||
if (!panel || !panel.classList.contains("is-open")) return;
|
||||
panel.classList.remove("is-open");
|
||||
setSelected([]);
|
||||
const p = panel;
|
||||
setTimeout(function () { if (!p.classList.contains("is-open")) p.querySelector("iframe").src = "about:blank"; }, 250);
|
||||
function isOpen() { return !!panel && panel.classList.contains("is-open"); }
|
||||
function isShown(target) {
|
||||
if (target === null) return !isOpen();
|
||||
return isOpen() && !!shownLi && itemsOfTask(shownLi).indexOf(target.li) >= 0;
|
||||
}
|
||||
function open(url) {
|
||||
// 지금 창의 작업 창 저장이 끝나길 기다린다 — 작업 창 닫기와 같은 절차(업로드·만들기·저장 대기 → 실패 칸
|
||||
// 재시도 → "버리고 넘어가기 / 계속 편집", project.js 의 __pjEmbedSettle). 창이 아직 안 열렸거나 권한 없음
|
||||
// 화면이면 저장할 입력이 없다. beforeunload 경고에 기대지 않는다(iframe 주소를 바꾸면 경고 없이 사라진다).
|
||||
async function settleFrame() {
|
||||
if (!isOpen()) return true;
|
||||
let fn = null;
|
||||
try { fn = panel.querySelector("iframe").contentWindow.__pjEmbedSettle; } catch (_) { fn = null; }
|
||||
if (typeof fn !== "function") return true;
|
||||
try { return !!(await fn()); } catch (e) {
|
||||
showToast("작업 창 저장 상태를 확인하지 못했습니다. 작업 창에서 닫아 주세요.", "error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function applyTarget(target) {
|
||||
if (target === null) {
|
||||
if (!isOpen()) return;
|
||||
panel.classList.remove("is-open");
|
||||
shownLi = null;
|
||||
setSelected([]);
|
||||
const p = panel;
|
||||
setTimeout(function () { if (!p.classList.contains("is-open")) p.querySelector("iframe").src = "about:blank"; }, 250);
|
||||
return;
|
||||
}
|
||||
if (!panel) {
|
||||
panel = document.createElement("div");
|
||||
panel.className = "pj-inbox-panel";
|
||||
@@ -8631,31 +8767,53 @@
|
||||
if (w) panel.style.width = "min(" + Math.round(w * uiZoom()) + "px, 92vw)";
|
||||
} catch (_) {}
|
||||
}
|
||||
panel.querySelector("iframe").src = url + (url.indexOf("?") >= 0 ? "&" : "?") + "embed=1";
|
||||
const group = itemsOfTask(target.li);
|
||||
group.forEach(markSeen); // 실제로 여는 줄만 확인한다(계속 편집을 고르면 새 줄은 그대로)
|
||||
shownLi = target.li;
|
||||
setSelected(group);
|
||||
// /project/t/{id} — 서버가 지금 권한으로 열 수 있는 프로젝트(연결된 프로젝트 포함)로 보내며 embed=1 을 이어 준다.
|
||||
panel.querySelector("iframe").src = target.href + (target.href.indexOf("?") >= 0 ? "&" : "?") + "embed=1";
|
||||
void panel.offsetWidth;
|
||||
panel.classList.add("is-open");
|
||||
}
|
||||
function requestPanel(target) {
|
||||
wanted = target;
|
||||
if (switching) return switching;
|
||||
switching = (async function () {
|
||||
while (wanted !== undefined) {
|
||||
const t = wanted;
|
||||
if (isShown(t)) { wanted = undefined; break; }
|
||||
const ok = await settleFrame();
|
||||
if (!ok) { wanted = undefined; break; } // 계속 편집 — 창·입력·선택 그대로
|
||||
if (wanted !== t) continue; // 기다리는 사이 다른 줄·닫기를 눌렀다 — 그쪽으로 다시
|
||||
wanted = undefined;
|
||||
applyTarget(t);
|
||||
}
|
||||
})().finally(function () { switching = null; });
|
||||
return switching;
|
||||
}
|
||||
function activate(li, newTab) {
|
||||
const href = li.dataset.href || "";
|
||||
const group = itemsOfTask(li);
|
||||
group.forEach(markSeen);
|
||||
if (newTab && href) { window.open(href, "_blank"); removeItems(group); return; }
|
||||
if (li.dataset.taskId && href) {
|
||||
if (selected.indexOf(li) >= 0 && panel && panel.classList.contains("is-open")) return;
|
||||
setSelected(group);
|
||||
open(href);
|
||||
} else if (href) {
|
||||
location.href = href; // 작업이 없는 프로젝트 알림 — 그 프로젝트로
|
||||
} else {
|
||||
removeItems(group); // 갈 곳이 없는 알림 — 읽음 처리하고 빼기만
|
||||
if (newTab && href) { group.forEach(markSeen); window.open(href, "_blank"); removeItems(group); return; }
|
||||
if (li.dataset.taskId && href) { requestPanel({ li: li, href: href }); return; }
|
||||
if (href) {
|
||||
// 작업이 없는 프로젝트 알림 — 열린 작업 창의 저장을 마친 뒤 그 프로젝트로
|
||||
requestPanel(null).then(function () {
|
||||
if (!isShown(null)) return; // 계속 편집
|
||||
Promise.all(group.map(markSeen)).then(function () { location.href = href; });
|
||||
});
|
||||
return;
|
||||
}
|
||||
group.forEach(markSeen);
|
||||
removeItems(group); // 갈 곳이 없는 알림 — 읽음 처리하고 빼기만
|
||||
}
|
||||
|
||||
window.addEventListener("message", function (e) {
|
||||
if (e.origin === location.origin && e.data && e.data.type === "pj-embed-close") close();
|
||||
if (e.origin === location.origin && e.data && e.data.type === "pj-embed-close") requestPanel(null);
|
||||
});
|
||||
document.addEventListener("keydown", function (e) {
|
||||
if (e.key === "Escape") { close(); return; }
|
||||
if (e.key === "Escape") { if (isOpen() || switching) requestPanel(null); return; }
|
||||
const li = (e.key === "Enter" || e.key === " ") && e.target.closest && e.target.closest(".pj-inbox-item");
|
||||
if (li && !isImeEnter(e)) { e.preventDefault(); activate(li, false); }
|
||||
});
|
||||
@@ -8667,8 +8825,8 @@
|
||||
return;
|
||||
}
|
||||
// 작업 창이 열린 채 왼쪽 수신함 영역(줄 밖)을 누르면 작업 창을 닫는다. 메뉴·모달·알림 팝업 안은 제외.
|
||||
if (panel && panel.classList.contains("is-open") && e.target.closest &&
|
||||
e.target.closest(".pj-inbox-view") && !e.target.closest(".pj-inbox-panel, .pj-modal, .pj-ctxmenu, .pj-alert-pop, button")) close();
|
||||
if (isOpen() && e.target.closest &&
|
||||
e.target.closest(".pj-inbox-view") && !e.target.closest(".pj-inbox-panel, .pj-modal, .pj-ctxmenu, .pj-alert-pop, button")) requestPanel(null);
|
||||
});
|
||||
// 오른쪽 클릭 — 열지 않고 확인(읽음)만
|
||||
document.addEventListener("contextmenu", function (e) {
|
||||
@@ -8679,24 +8837,31 @@
|
||||
{ label: "확인(목록에서 빼기)", onClick: function () { const g = itemsOfTask(li); g.forEach(markSeen); if (selected.indexOf(li) < 0) removeItems(g); } },
|
||||
]);
|
||||
});
|
||||
// 모두 확인 — 그 목록 줄을 모두 빼고, 열린 작업 창도 닫는다
|
||||
// 모두 확인 — 열린 작업 창의 저장을 마친 뒤 그 목록 줄을 모두 뺀다
|
||||
function readAll(list, send) {
|
||||
return async function () {
|
||||
await requestPanel(null);
|
||||
if (!isShown(null)) return; // 계속 편집 — 아무것도 바꾸지 않는다
|
||||
try {
|
||||
await send();
|
||||
if (!list) return;
|
||||
const items = Array.prototype.slice.call(list.querySelectorAll(".pj-inbox-item"));
|
||||
items.forEach(function (li) { li.dataset.seen = "1"; li.classList.remove("is-unread"); });
|
||||
removeItems(items);
|
||||
} catch (e) { showToast("처리 실패: " + e.message, "error"); }
|
||||
};
|
||||
}
|
||||
const mentionsAll = document.getElementById("pj-mentions-readall");
|
||||
if (mentionsAll) mentionsAll.addEventListener("click", async function () {
|
||||
try {
|
||||
await api("POST", "/project/api/mentions/read", {});
|
||||
close();
|
||||
if (mentionList) removeItems(Array.prototype.slice.call(mentionList.querySelectorAll(".pj-inbox-item")));
|
||||
} catch (e) { showToast("처리 실패: " + e.message, "error"); }
|
||||
});
|
||||
if (mentionsAll) mentionsAll.addEventListener("click", readAll(mentionList, function () {
|
||||
return api("POST", "/project/api/mentions/read", {});
|
||||
}));
|
||||
const notiAll = document.getElementById("pj-readall");
|
||||
if (notiAll) notiAll.addEventListener("click", async function () {
|
||||
try {
|
||||
const res = await fetch("/project/api/notifications/read-all", { method: "POST" });
|
||||
if (!res.ok) throw new Error("HTTP " + res.status);
|
||||
close();
|
||||
if (notiList) removeItems(Array.prototype.slice.call(notiList.querySelectorAll(".pj-inbox-item")));
|
||||
} catch (e) { showToast("실패: " + e.message, "error"); }
|
||||
});
|
||||
if (notiAll) notiAll.addEventListener("click", readAll(notiList, function () {
|
||||
return fetch("/project/api/notifications/read-all", { method: "POST" })
|
||||
.then(function (res) { if (!res.ok) throw new Error("HTTP " + res.status); });
|
||||
}));
|
||||
// 자동 테스트(tests/js)에서만 — 창 바꾸기 진행 상태를 기다릴 수 있게.
|
||||
if (window.__PJ_TEST__) window.__pjInbox = { settling: function () { return switching || Promise.resolve(); } };
|
||||
}
|
||||
|
||||
// ── 실시간 새로고침 ──
|
||||
@@ -11160,7 +11325,9 @@
|
||||
'<button type="button" class="pj-btn pj-btn-sm" data-alert-close>닫기</button></div>' +
|
||||
'<div class="pj-alert-list">' + items.map(function (n) {
|
||||
const isMention = n.type === "mention";
|
||||
const href = n.project_id ? "/project/p/" + n.project_id + (n.task_id ? "?task=" + n.task_id : "") : "/project/inbox";
|
||||
// 서버가 준 주소(작업 = /project/t/{id} — 연결된 프로젝트에서만 읽을 수 있는 작업도 열린다)
|
||||
const href = n.href || (n.task_id ? "/project/t/" + n.task_id
|
||||
: n.project_id ? "/project/p/" + n.project_id : "/project/inbox");
|
||||
return '<a class="pj-alert-item" href="' + escapeHtml(href) + '" data-alert-open="' + escapeHtml(n.id) + '">' +
|
||||
'<span class="pj-alert-kind ' + (isMention ? "is-mention" : "is-assigned") + '">' +
|
||||
(isMention ? "나를 태그" : "작업 배정") + "</span>" +
|
||||
|
||||
Reference in New Issue
Block a user