feat(project): 4-tier roles (super/admin/pro/user), meeting header 구분
- app.store: role "pro" (ROLES, ROLE_LABELS); admin page grade select Admin / Pro user / User, super admin fixed to one account. - project.access: role_of, is_pro, is_project_admin. - router: _require_admin -> _require_pro (goals, meetings complete/delete, members, reorder, trash restore, assignable users); new project and project edit/owner change need Pro user+; task delete open to any member; project/section delete = Admin+ or creator; comment edit/delete of others and workload summary = Pro user+. Templates get pj_pro / pj_admin. - Weekly meeting table first header "구역" -> "구분". - Docs (CLAUDE.md, PROJECT_MODULE 6-14, overview, help page) and tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+40
-39
@@ -1267,7 +1267,7 @@
|
||||
// ── 새 프로젝트 모달 (#pj-modal-project) — 좌측 사이드바 "+" 버튼 ──
|
||||
// 내 업무 화면과 프로젝트 화면이 같은 마크업/동작을 쓴다. 만들어진 뒤
|
||||
// 화면마다 할 일(트리 갱신 등)만 onCreated 로 받는다.
|
||||
function initNewProjectModal(isAdmin, onCreated) {
|
||||
function initNewProjectModal(isPro, onCreated) {
|
||||
const btn = el("pj-new-project-side");
|
||||
const modal = el("pj-modal-project");
|
||||
if (!btn || !modal) return;
|
||||
@@ -1278,9 +1278,9 @@
|
||||
btn.addEventListener("click", async function () {
|
||||
openModal(modal);
|
||||
if (!membersBox) return;
|
||||
// 멤버 배정은 관리자 전용 API — 관리자가 아니면 시도하지 않고 안내만.
|
||||
if (!isAdmin) {
|
||||
membersBox.innerHTML = "<span class='pj-empty-sm'>멤버 배정은 관리자가 나중에 할 수 있습니다.</span>";
|
||||
// 멤버 배정은 Pro user 이상 API — 아니면 시도하지 않고 안내만(모달 자체가 Pro user 이상에게만 그려진다).
|
||||
if (!isPro) {
|
||||
membersBox.innerHTML = "<span class='pj-empty-sm'>멤버 배정은 Pro user 이상이 나중에 할 수 있습니다.</span>";
|
||||
return;
|
||||
}
|
||||
membersBox.innerHTML = "불러오는 중…";
|
||||
@@ -1325,7 +1325,7 @@
|
||||
|
||||
// ── 좌측 프로젝트 목록(project/_side.html) — 수신함·내 업무·휴지통·프로젝트
|
||||
// 네 화면이 모두 이 구현 하나를 쓴다(예전엔 프로젝트 화면에만 있어서 다른
|
||||
// 화면에선 ✎/×·드래그 순서 변경이 없었다). 관리자에게만 손잡이(⣿)·✎·×·
|
||||
// 화면에선 ✎/×·드래그 순서 변경이 없었다). Pro user 이상에게만 손잡이(⣿)·✎·×·
|
||||
// 우클릭 메뉴를 붙이고, 수정/새 프로젝트 모달은 project/_side_modals.html.
|
||||
// cfg:
|
||||
// projects 프로젝트 배열 — 주면 제자리에서 고친다(프로젝트 화면이 뷰와
|
||||
@@ -1337,13 +1337,14 @@
|
||||
const side = document.querySelector(".pj-side");
|
||||
const noop = { render: function () {}, merge: function () {} };
|
||||
if (!side) return noop;
|
||||
const isAdmin = side.dataset.isAdmin === "true";
|
||||
const isSuper = side.dataset.isSuper === "true";
|
||||
// 등급(2026-10-12) — isPro = Pro user 이상(새 프로젝트·✎ 수정·순서 변경), isPAdmin = Admin 이상(남이 만든 프로젝트도 삭제)
|
||||
const isPro = side.dataset.isPro === "true";
|
||||
const isPAdmin = side.dataset.isPadmin === "true";
|
||||
const me = (side.dataset.me || "").toLowerCase();
|
||||
const currentId = cfg.currentId || 0;
|
||||
const DELETE_DENIED = "삭제는 만든 사람만 할 수 있습니다.";
|
||||
function canDelete(createdBy) {
|
||||
if (isSuper) return true;
|
||||
if (isPAdmin) return true;
|
||||
const cb = (createdBy || "").toLowerCase();
|
||||
return !!cb && cb === me;
|
||||
}
|
||||
@@ -1362,7 +1363,7 @@
|
||||
|
||||
function treeProjLi(p) {
|
||||
let acts = "";
|
||||
if (isAdmin) {
|
||||
if (isPro) {
|
||||
acts = '<span class="pj-tree-acts">' +
|
||||
'<button type="button" class="pj-icon-btn pj-tree-edit" data-id="' + p.id +
|
||||
'" data-name="' + escapeHtml(p.name) + '" data-desc="' + escapeHtml(p.description || "") +
|
||||
@@ -1373,9 +1374,9 @@
|
||||
'" data-name="' + escapeHtml(p.name) + '" data-creator="' + escapeHtml(p.created_by || "") + '" title="프로젝트 삭제">×</button>' +
|
||||
"</span>";
|
||||
}
|
||||
// 드래그로 순서 변경 가능함을 알려주는 손잡이(⣿) — 관리자에게만 보인다.
|
||||
const handle = isAdmin ? '<span class="pj-tree-handle" title="드래그로 순서 변경">⣿</span>' : "";
|
||||
return '<li class="pj-tree-li"' + (isAdmin ? ' draggable="true"' : "") + ' data-id="' + p.id + '"><div class="pj-tree-row ' +
|
||||
// 드래그로 순서 변경 가능함을 알려주는 손잡이(⣿) — Pro user 이상에게만 보인다.
|
||||
const handle = isPro ? '<span class="pj-tree-handle" title="드래그로 순서 변경">⣿</span>' : "";
|
||||
return '<li class="pj-tree-li"' + (isPro ? ' draggable="true"' : "") + ' data-id="' + p.id + '"><div class="pj-tree-row ' +
|
||||
(p.id === currentId ? "is-active" : "") + '">' +
|
||||
handle +
|
||||
'<a class="pj-tree-link" href="/project/p/' + p.id + '">' +
|
||||
@@ -1404,7 +1405,7 @@
|
||||
function wireTreeHandlers(rootUl) {
|
||||
// <a> 는 기본 draggable="true" — 그대로 두면 li 대신 링크(URL) 드래그가
|
||||
// 시작돼 아래 wireTreeDrag 의 dragstart 핸들러가 무력화된다.
|
||||
if (isAdmin) rootUl.querySelectorAll(".pj-tree-link").forEach(function (a) { a.draggable = false; });
|
||||
if (isPro) rootUl.querySelectorAll(".pj-tree-link").forEach(function (a) { a.draggable = false; });
|
||||
rootUl.querySelectorAll(".pj-tree-del").forEach(function (b) {
|
||||
b.addEventListener("click", function (e) {
|
||||
e.preventDefault(); e.stopPropagation();
|
||||
@@ -1417,7 +1418,7 @@
|
||||
openProjectEditModal(b.dataset);
|
||||
});
|
||||
});
|
||||
if (isAdmin) rootUl.querySelectorAll(".pj-tree-li").forEach(function (li) {
|
||||
if (isPro) rootUl.querySelectorAll(".pj-tree-li").forEach(function (li) {
|
||||
li.addEventListener("contextmenu", function (e) {
|
||||
e.preventDefault();
|
||||
const editBtn = li.querySelector(".pj-tree-edit");
|
||||
@@ -1481,11 +1482,11 @@
|
||||
doneUl.remove();
|
||||
}
|
||||
}
|
||||
// 드래그 순서 변경 — 관리자 전용, 최상위 프로젝트만. rootUl 자체는
|
||||
// 드래그 순서 변경 — Pro user 이상, 최상위 프로젝트만. rootUl 자체는
|
||||
// render() 가 innerHTML 만 바꾸고 element 를 갈아치우지 않으므로 리스너는
|
||||
// 한 번만 붙이면 된다.
|
||||
function wireTreeDrag(rootUl) {
|
||||
if (!isAdmin || !rootUl) return;
|
||||
if (!isPro || !rootUl) return;
|
||||
let dragLi = null;
|
||||
rootUl.addEventListener("dragstart", function (e) {
|
||||
const li = e.target.closest(".pj-tree-li");
|
||||
@@ -1582,7 +1583,7 @@
|
||||
enhanceDateInput(el("pj-e-due"), { startInput: el("pj-e-start"), iconOnly: true });
|
||||
|
||||
// "+" — 새 최상위 프로젝트. 기본은 만든 프로젝트 화면으로 이동한다.
|
||||
initNewProjectModal(isAdmin, cfg.onCreated || function (project) {
|
||||
initNewProjectModal(isPro, cfg.onCreated || function (project) {
|
||||
location.href = "/project/p/" + project.id;
|
||||
});
|
||||
|
||||
@@ -3091,15 +3092,19 @@
|
||||
if (!root) return;
|
||||
const projectId = parseInt(root.dataset.projectId, 10);
|
||||
const canManage = root.dataset.canManage === "true";
|
||||
const isAdmin = root.dataset.isAdmin === "true";
|
||||
// 등급(2026-10-12) — isPro = Pro user 이상(프로젝트 수정·멤버 배정·전체 보기·담당자별 합계·남의 댓글 수정),
|
||||
// isPAdmin = Admin 이상(남이 만든 섹션도 삭제).
|
||||
const isPro = root.dataset.isPro === "true";
|
||||
const isPAdmin = root.dataset.isPadmin === "true";
|
||||
const me = (root.dataset.me || "").toLowerCase();
|
||||
const isSuper = root.dataset.isSuper === "true";
|
||||
// 삭제는 만든 사람만(슈퍼관리자 예외). created_by 없으면 서버가 최종 판정.
|
||||
// 섹션 삭제 — Admin 이상은 누구 것이든, 그 밖은 만든 사람만. created_by 없으면 서버가 최종 판정.
|
||||
function canDelete(createdBy) {
|
||||
if (isSuper) return true;
|
||||
if (isPAdmin) return true;
|
||||
const cb = (createdBy || "").toLowerCase();
|
||||
return !!cb && cb === me;
|
||||
}
|
||||
// 작업·세부 작업 삭제(휴지통으로)는 멤버 누구나(2026-10-12) — 서버도 생성자를 보지 않는다.
|
||||
function canDeleteTask() { return true; }
|
||||
const DELETE_DENIED = "삭제는 만든 사람만 할 수 있습니다.";
|
||||
// 댓글 있으면 말풍선 아이콘(+개수). 색은 currentColor 상속(막대=흰, 카드/리스트=진회색).
|
||||
function cmtBadgeInner(t, cls) {
|
||||
@@ -3161,7 +3166,7 @@
|
||||
// Enter/바깥 클릭=저장, Esc=취소. 저장 권한(_require_manage)이 있을 때만.
|
||||
(function () {
|
||||
const pill = document.querySelector(".pj-project-title-pill");
|
||||
if (!pill || !canManage || !projectId) return;
|
||||
if (!pill || !canManage || !isPro || !projectId) return;
|
||||
pill.classList.add("is-editable");
|
||||
pill.title = "클릭해서 프로젝트 이름 수정";
|
||||
let editing = false;
|
||||
@@ -3407,8 +3412,8 @@
|
||||
r.classList.toggle("is-active", !on);
|
||||
});
|
||||
}
|
||||
if (isAdmin && new URLSearchParams(location.search).get("scope") === "all") applyAllScope(true); // 첫 그리기 전에
|
||||
if (allViewLink && isAdmin) {
|
||||
if (isPro && new URLSearchParams(location.search).get("scope") === "all") applyAllScope(true); // 첫 그리기 전에
|
||||
if (allViewLink && isPro) {
|
||||
allViewLink.addEventListener("click", function (e) {
|
||||
if (e.ctrlKey || e.metaKey || e.shiftKey || e.button === 1) return;
|
||||
e.preventDefault(); // 같은 화면 안에서 바로 전환
|
||||
@@ -5049,7 +5054,6 @@
|
||||
{
|
||||
label: "세부 작업 삭제", danger: true,
|
||||
onClick: async function () {
|
||||
if (!canDelete(sub.created_by)) { alert(DELETE_DENIED); return; }
|
||||
if (!(await confirmTaskDelete(sub.id, sub.title, null))) return;
|
||||
try {
|
||||
await deleteTaskRequest(sub.id);
|
||||
@@ -5833,8 +5837,8 @@
|
||||
|
||||
// 담당자별 작업 합계(2026-10-07) — 이 범위에서 그 사람에게 배정된 작업 전부(마감일·필터와 무관),
|
||||
// 메인 작업과 세부 작업을 나눠 세고 완료 수·완료율. 세부 업무는 화면 목록에 없어 서버에서 따로 받는다.
|
||||
// 사람별 업무량이 드러나는 표라 관리자에게만 보여준다.
|
||||
if (isAdmin) {
|
||||
// 사람별 업무량이 드러나는 표라 Pro user 이상에게만 보여준다(User 는 안 보임).
|
||||
if (isPro) {
|
||||
const assigneeCard = document.createElement("div");
|
||||
assigneeCard.className = "pj-dash-card pj-dash-card-wide";
|
||||
assigneeCard.innerHTML = '<div class="pj-dash-card-title">담당자별 작업 합계(메인·세부 작업, 완료)</div>' +
|
||||
@@ -6110,7 +6114,6 @@
|
||||
{
|
||||
label: "삭제", danger: true,
|
||||
onClick: async function () {
|
||||
if (!canDelete(t.created_by)) { alert(DELETE_DENIED); return; }
|
||||
if (!(await confirmTaskDelete(t.id, t.title, t.subtask_total))) return;
|
||||
try {
|
||||
await deleteTaskRequest(t.id);
|
||||
@@ -6535,7 +6538,7 @@
|
||||
showFollowers(task, detail.followers);
|
||||
if (subtaskBlock) {
|
||||
subtaskBlock.setContext({
|
||||
taskId: task.id, projectId: task.project_id, canDelete: canDelete,
|
||||
taskId: task.id, projectId: task.project_id, canDelete: canDeleteTask,
|
||||
readOnly: taskReadOnly,
|
||||
onOpen: function (sub) { openTaskById(sub.id); },
|
||||
});
|
||||
@@ -6962,7 +6965,7 @@
|
||||
(c.body ? '<div class="pj-comment-body">' + commentBodyHtml(c.body) + "</div>" : "") +
|
||||
commentAttachmentsHtml((feats._atts || {})[c.id] || []) +
|
||||
'<div class="pj-react-slot">' + reactionRowHtml(c, me, feats.reactions) + "</div></div>" +
|
||||
(taskReadOnly ? "" : commentHoverBarHtml(feats, { reply: true, edit: (mine || isAdmin) && !!c.body, del: mine || isAdmin }));
|
||||
(taskReadOnly ? "" : commentHoverBarHtml(feats, { reply: true, edit: (mine || isPro) && !!c.body, del: mine || isPro }));
|
||||
wireCommentReactions(item, c, function () {
|
||||
item.querySelector(".pj-react-slot").innerHTML = reactionRowHtml(c, me, feats.reactions);
|
||||
});
|
||||
@@ -7139,7 +7142,6 @@
|
||||
const id = el("pj-t-id").value;
|
||||
if (!id) return;
|
||||
const t = tasks.find(function (x) { return String(x.id) === String(id); });
|
||||
if (t && !canDelete(t.created_by)) { alert(DELETE_DENIED); return; }
|
||||
if (!(await confirmTaskDelete(id, el("pj-t-title").value.trim(), null))) return;
|
||||
try {
|
||||
await deleteTaskRequest(id);
|
||||
@@ -7185,7 +7187,7 @@
|
||||
projectId: projectId, projectName: currentProject.name,
|
||||
});
|
||||
});
|
||||
if (isAdmin) chip.addEventListener("contextmenu", function (e) {
|
||||
if (isPro) chip.addEventListener("contextmenu", function (e) {
|
||||
e.preventDefault();
|
||||
showContextMenu(e.clientX, e.clientY, [
|
||||
{ label: "제외", danger: true, onClick: function () { removeMember(chip.dataset.email); } },
|
||||
@@ -9018,7 +9020,7 @@
|
||||
const table = el("pj-goal-table");
|
||||
if (!table) return;
|
||||
const year = table.dataset.year;
|
||||
const isAdmin = table.dataset.admin === "true";
|
||||
const isPro = table.dataset.pro === "true"; // 입력·구조 변경 = Pro user 이상(2026-10-12)
|
||||
|
||||
// ── 열 너비 — 셀 오른쪽 경계에서 끌기·더블클릭 맞춤, 브라우저에 기억(localStorage pj_goal_col_w) ──
|
||||
// · c1·c2 = 왼쪽 이름 두 칸(구분·항목) → 표의 CSS 변수 --goal-c1-w·--goal-c2-w(c2 의 left 도 c1 너비로 정해진다)
|
||||
@@ -9161,7 +9163,7 @@
|
||||
function queueCellGrowth(e) {
|
||||
const field = e.target.closest("input, textarea, [contenteditable='true']");
|
||||
const td = field && field.closest("td, th");
|
||||
if (!isAdmin || !td || !table.contains(td)) return;
|
||||
if (!isPro || !td || !table.contains(td)) return;
|
||||
growingCells.add(td);
|
||||
if (growFrame) return;
|
||||
growFrame = requestAnimationFrame(function () {
|
||||
@@ -9183,7 +9185,7 @@
|
||||
const td = e.target.closest("th, td");
|
||||
if (!td || !table.contains(td)) return;
|
||||
// 관리자 업무 셀·이름 칸은 아래의 기존 편집 메뉴에 합쳐 표시한다.
|
||||
if (isAdmin && td.closest("tbody.pj-goal-area") &&
|
||||
if (isPro && td.closest("tbody.pj-goal-area") &&
|
||||
(td.tagName === "TH" || table.dataset.halves === "true" || td.dataset.month === "0")) return;
|
||||
e.preventDefault(); showContextMenu(e.clientX, e.clientY, widthMenuItems(td));
|
||||
});
|
||||
@@ -9416,7 +9418,7 @@
|
||||
closeWeekPop();
|
||||
const mo = cell.dataset.month, list = (WEEKS && WEEKS[mo]) || [];
|
||||
const unit = window.PJ_GOAL_UNIT || "";
|
||||
const edit = isAdmin && cell.tagName === "INPUT";
|
||||
const edit = isPro && cell.tagName === "INPUT";
|
||||
weekPop = document.createElement("div");
|
||||
weekPop.className = "pj-goal-wkpop";
|
||||
weekPop.innerHTML = '<div class="pj-goal-wkpop-head">' + mo + "월 주차별 매출 목표" +
|
||||
@@ -9503,7 +9505,7 @@
|
||||
|
||||
// 병합 선택(Shift+클릭) — 관리자 전용, 아래에서 채운다. 접기 버튼이 먼저 부르므로 여기 둔다.
|
||||
let clearMergeSel = function () {};
|
||||
if (!isAdmin) return;
|
||||
if (!isPro) return;
|
||||
|
||||
// ── 숫자 칸 — Enter·칸 떠남에 저장(createFieldSaver: 같은 칸 요청 차례대로, 늦은 응답이 새 입력을 덮지 않음).
|
||||
// 서버 표기(쉼표)는 요청 뒤 입력이 그대로일 때만 칸에 넣는다. 실패해도 입력값은 그대로(빨간 테두리), Esc = 저장된 값으로.
|
||||
@@ -10663,8 +10665,7 @@
|
||||
initMeetBoard(pane.dataset.week);
|
||||
initMeetQuickTasks();
|
||||
const week = pane.dataset.week, year = pane.dataset.year;
|
||||
const isAdmin = pane.dataset.admin === "true";
|
||||
// 회의록은 누구나 고친다(2026-10-07) — 회의 완료(잠금)면 아무도 못 고친다(data-edit). 관리자만 삭제·완료·완료 해제.
|
||||
// 회의록은 누구나 고친다(2026-10-07) — 회의 완료(잠금)면 아무도 못 고친다(data-edit). Pro user 이상만 삭제·완료·완료 해제.
|
||||
const canEdit = pane.dataset.edit === "true";
|
||||
const SCROLL_KEY = "pj_meet_scroll";
|
||||
function reloadKeepScroll() {
|
||||
|
||||
Reference in New Issue
Block a user