diff --git a/app/modules/project/templates/project/inbox.html b/app/modules/project/templates/project/inbox.html index 2c62916..aabc336 100644 --- a/app/modules/project/templates/project/inbox.html +++ b/app/modules/project/templates/project/inbox.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -98,5 +98,5 @@ {% include "project/_member_tasks_modal.html" %} - + {% endblock %} diff --git a/app/modules/project/templates/project/mytasks.html b/app/modules/project/templates/project/mytasks.html index 00a2f1f..047fb8d 100644 --- a/app/modules/project/templates/project/mytasks.html +++ b/app/modules/project/templates/project/mytasks.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -119,5 +119,5 @@ "today": {{ today | tojson }} } - + {% endblock %} diff --git a/app/modules/project/templates/project/project.html b/app/modules/project/templates/project/project.html index dcae9bf..7cfb52a 100644 --- a/app/modules/project/templates/project/project.html +++ b/app/modules/project/templates/project/project.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + @@ -505,5 +505,5 @@ - + {% endblock %} diff --git a/app/static/project.css b/app/static/project.css index 7cc5697..6bc1210 100644 --- a/app/static/project.css +++ b/app/static/project.css @@ -1134,12 +1134,87 @@ img.pj-person-ic { width: 22px; height: 22px; } .pj-card-meta .is-empty { opacity: 0; transition: opacity .12s; color: #9aa1a9; } .pj-card:hover .pj-card-meta .is-empty { opacity: .8; } .pj-card-due.is-overdue { color: #c22b10; } -.pj-inline-date { - position: absolute; z-index: 1200; background: #fff; border: 1px solid #d8dce2; - border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 8px; - display: flex; align-items: center; gap: 6px; +/* ── 아사나식 날짜 팝업(openDatePopover) — 시작일/마감일 칸 + 월 달력 + 지우기. + 앵커 아래(자리 없으면 위)에 뜨고 꼬리가 앵커를 가리킨다(--pj-dp-tail). ── */ +.pj-datepop { + position: fixed; z-index: 2300; width: 300px; box-sizing: border-box; + background: #fff; border: 1px solid #e3e5e8; border-radius: 12px; + box-shadow: 0 8px 28px rgba(15,23,42,.16), 0 1px 3px rgba(15,23,42,.08); + padding: 14px 14px 8px; font-size: 13px; color: var(--pj-ink); + animation: pj-dp-in .12s ease-out; } -.pj-inline-date input[type="date"] { border: 1px solid #d8dce2; border-radius: 7px; padding: 5px 7px; font-size: 13px; } +@keyframes pj-dp-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } } +.pj-datepop::before, .pj-datepop::after { + content: ""; position: absolute; left: var(--pj-dp-tail, 50%); transform: translateX(-50%); + border: 8px solid transparent; +} +/* 아래에 뜸 → 위쪽 꼬리 */ +.pj-datepop::before { bottom: 100%; border-bottom-color: #e3e5e8; } +.pj-datepop::after { bottom: calc(100% - 1px); border-bottom-color: #fff; } +/* 위에 뜸 → 아래쪽 꼬리 */ +.pj-datepop.is-above::before { bottom: auto; top: 100%; border-bottom-color: transparent; border-top-color: #e3e5e8; } +.pj-datepop.is-above::after { bottom: auto; top: calc(100% - 1px); border-bottom-color: transparent; border-top-color: #fff; } + +.pj-dp-fields { display: flex; gap: 8px; margin-bottom: 10px; } +.pj-dp-field, .pj-dp-addstart { + flex: 1 1 0; min-width: 0; height: 36px; box-sizing: border-box; + border: 1px solid #d8dce2; border-radius: 8px; padding: 0 10px; + font: inherit; font-size: 13.5px; color: var(--pj-ink); background: #fff; +} +.pj-dp-field:focus, .pj-dp-field.is-active { outline: none; border: 2px solid #4573d2; padding: 0 9px; } +.pj-dp-field::placeholder { color: #9aa1a9; } +.pj-dp-addstart { + border-color: transparent; background: transparent; cursor: pointer; font-weight: 600; color: #525860; text-align: left; +} +.pj-dp-addstart:hover { background: #f1f2f4; } + +.pj-dp-nav { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 6px; } +.pj-dp-title { font-size: 14px; font-weight: 500; color: var(--pj-ink); } +.pj-dp-navbtn { + width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; + border: 0; background: transparent; border-radius: 6px; color: #525860; cursor: pointer; +} +.pj-dp-navbtn:hover { background: #f1f2f4; color: var(--pj-ink); } +.pj-dp-navbtn .material-symbols-outlined { font-size: 22px; } + +.pj-dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; } +.pj-dp-wd { text-align: center; font-size: 12px; font-weight: 600; color: #6d6e6f; padding: 4px 0 6px; } +.pj-dp-day { + position: relative; height: 34px; border: 0; background: transparent; cursor: pointer; + font: inherit; font-size: 13.5px; color: var(--pj-ink); display: flex; align-items: center; justify-content: center; +} +.pj-dp-day::before { + content: ""; position: absolute; width: 30px; height: 30px; border-radius: 50%; z-index: 0; + left: 50%; top: 50%; transform: translate(-50%, -50%); +} +.pj-dp-day { z-index: 0; } +.pj-dp-day > * { position: relative; } +.pj-dp-day:hover::before { background: #f1f2f4; } +.pj-dp-day.is-weekend, .pj-dp-day.is-out { color: #8b929b; } +.pj-dp-day.is-out { color: #b3b8bf; } +/* 오늘 = 파란 테두리 원 + 굵게 */ +.pj-dp-day.is-today { font-weight: 800; } +.pj-dp-day.is-today::before { border: 1.5px solid #4573d2; } +/* 선택 = 파란 원 + 흰 글자 (숫자가 원 위에 보이도록 글자는 z 위로) */ +.pj-dp-day.is-selected { color: #fff; font-weight: 600; } +.pj-dp-day.is-selected::before { background: #4573d2; border: 0; } +.pj-dp-day.is-inrange { background: #e8effb; } +.pj-dp-day { isolation: isolate; } +.pj-dp-day::before { z-index: -1; } + +.pj-dp-foot { + display: flex; justify-content: space-between; align-items: center; + margin-top: 8px; padding-top: 8px; border-top: 1px solid #eef0f2; +} +.pj-dp-link { + border: 0; background: transparent; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; + color: #525860; padding: 6px 8px; border-radius: 6px; +} +.pj-dp-link:hover { background: #f1f2f4; color: var(--pj-ink); } + +/* 마감일 표기 색 — 오늘·내일 초록, 어제·지남 빨강(아사나) */ +.pj-card-due.is-soon, .pj-card-sub-due.is-soon, .pj-due-label.is-soon, .pj-due-btn.is-soon { color: #3f8f6b; } +.pj-card-due.is-overdue, .pj-card-sub-due.is-overdue, .pj-due-label.is-overdue { color: #c22b10; } /* ── 멘션(@태그) ── */ .pj-mention { diff --git a/app/static/project.js b/app/static/project.js index 36822e1..aeedd28 100644 --- a/app/static/project.js +++ b/app/static/project.js @@ -180,6 +180,219 @@ return mm + "/" + dd + "(" + wd + ")"; } + // ── 마감일 표기(아사나처럼) — 어제(빨강) / 오늘·내일(초록) / 그 밖엔 mm/dd(요일), + // 지난 날짜는 빨강. 완료된 업무는 색 없이. 반환 {text, cls}. + function isoOf(d) { + return d.getFullYear() + "-" + String(d.getMonth() + 1).padStart(2, "0") + "-" + String(d.getDate()).padStart(2, "0"); + } + function isoToday() { return isoOf(new Date()); } + function dayDiff(iso, baseIso) { + const a = new Date(String(iso).slice(0, 10) + "T00:00:00"), b = new Date(baseIso + "T00:00:00"); + return Math.round((a - b) / 86400000); + } + function dueInfo(iso, done) { + if (!iso) return null; + const diff = dayDiff(iso, isoToday()); + let text, cls = ""; + if (diff === 0) { text = "오늘"; cls = "is-soon"; } + else if (diff === 1) { text = "내일"; cls = "is-soon"; } + else if (diff === -1) { text = "어제"; cls = "is-overdue"; } + else { text = fmtDateKr(iso); if (diff < 0) cls = "is-overdue"; } + if (done) cls = ""; + return { text: text, cls: cls }; + } + + // ── 아사나식 날짜 팝업 — 마감일(과 선택적으로 시작일)을 월 달력에서 고른다. + // opts: { start, due, allowStart, onChange(patch) }. 날짜를 누를 때마다 + // onChange({due_date[, start_date]}) 로 바로 저장하고 팝업은 열어 둔다(아사나와 + // 같음). 바깥 클릭·Esc 로 닫힘. "지우기" = 둘 다 비우고 닫기. 앵커 아래(자리가 + // 없으면 위)에 뜨고 꼬리가 앵커를 가리킨다. 한 번에 하나만. + let datePopEl = null, datePopCleanup = null; + function closeDatePopover() { + if (datePopCleanup) datePopCleanup(); + datePopCleanup = null; + if (datePopEl) { datePopEl.remove(); datePopEl = null; } + } + // 직접 입력 해석 — 2026-09-30 / 2026.9.30 / 9/30 / 9월 30일 / 0930. + // 빈 값 = "" (지우기), 해석 불가 = null. + function parseTypedDate(text, baseIso) { + const v = String(text || "").trim().replace(/\s+/g, ""); + if (!v) return ""; + let m = v.match(/^(\d{4})[-./년](\d{1,2})[-./월](\d{1,2})[.일]?$/); + let y, mo, d; + if (m) { y = +m[1]; mo = +m[2]; d = +m[3]; } + else if ((m = v.match(/^(\d{1,2})[-./월](\d{1,2})[.일]?$/))) { y = +baseIso.slice(0, 4); mo = +m[1]; d = +m[2]; } + else if ((m = v.match(/^(\d{2})(\d{2})$/))) { y = +baseIso.slice(0, 4); mo = +m[1]; d = +m[2]; } + else return null; + const dt = new Date(y, mo - 1, d); + if (dt.getFullYear() !== y || dt.getMonth() !== mo - 1 || dt.getDate() !== d) return null; + return isoOf(dt); + } + function fmtFieldDate(iso) { + if (!iso) return ""; + const d = new Date(iso + "T00:00:00"); + const same = d.getFullYear() === new Date().getFullYear(); + return (same ? "" : d.getFullYear() + "년 ") + (d.getMonth() + 1) + "월 " + d.getDate() + "일"; + } + function openDatePopover(anchor, opts) { + closeDatePopover(); + const today = isoToday(); + let start = opts.start ? String(opts.start).slice(0, 10) : ""; + let due = opts.due ? String(opts.due).slice(0, 10) : ""; + let showStart = !!(opts.allowStart && start); + let active = "due"; + const base = new Date((due || start || today) + "T00:00:00"); + let viewY = base.getFullYear(), viewM = base.getMonth(); + + const pop = document.createElement("div"); + pop.className = "pj-datepop"; + document.body.appendChild(pop); + datePopEl = pop; + + function emit() { + const patch = { due_date: due || null }; + if (opts.allowStart) patch.start_date = start || null; + if (opts.onChange) opts.onChange(patch); + } + function field(kind, val, ph) { + return ''; + } + function render() { + const first = new Date(viewY, viewM, 1); + const gridStart = new Date(viewY, viewM, 1 - first.getDay()); + let days = ""; + for (let i = 0; i < 42; i++) { + const d = new Date(gridStart.getFullYear(), gridStart.getMonth(), gridStart.getDate() + i); + const iso = isoOf(d); + const cls = ["pj-dp-day"]; + if (d.getMonth() !== viewM) cls.push("is-out"); + if (d.getDay() === 0 || d.getDay() === 6) cls.push("is-weekend"); + if (iso === today) cls.push("is-today"); + if (iso === due || (showStart && iso === start)) cls.push("is-selected"); + if (showStart && start && due && iso > start && iso < due) cls.push("is-inrange"); + days += '"; + } + pop.innerHTML = + '
' + + (opts.allowStart + ? (showStart ? field("start", start, "시작일") : '') + : "") + + field("due", due, "마감일") + + "
" + + '
' + + '' + + '' + viewY + "년 " + (viewM + 1) + "월" + + '' + + "
" + + '
' + + ["일", "월", "화", "수", "목", "금", "토"].map(function (w) { return '' + w + ""; }).join("") + + days + + "
" + + '
' + + '' + + '' + + "
"; + wire(); + } + // 날짜 하나 고르기 — 시작일 칸이 활성이면 시작일(그 뒤 마감일로 넘어감), + // 아니면 마감일. 시작일 > 마감일이 되지 않게 맞춘다. + function pick(iso) { + if (active === "start") { + start = iso; + if (due && due < iso) due = iso; + active = "due"; + } else { + due = iso; + if (start && start > iso) start = iso; + } + render(); + emit(); + } + function wire() { + pop.querySelectorAll(".pj-dp-day").forEach(function (b) { + b.addEventListener("click", function () { pick(b.dataset.iso); }); + }); + pop.querySelectorAll(".pj-dp-navbtn").forEach(function (b) { + b.addEventListener("click", function () { + viewM += +b.dataset.nav; + if (viewM < 0) { viewM = 11; viewY--; } else if (viewM > 11) { viewM = 0; viewY++; } + render(); + }); + }); + const add = pop.querySelector(".pj-dp-addstart"); + if (add) add.addEventListener("click", function () { + showStart = true; active = "start"; render(); focusActive(); + }); + pop.querySelectorAll(".pj-dp-field").forEach(function (inp) { + inp.addEventListener("focus", function () { + active = inp.dataset.kind; + pop.querySelectorAll(".pj-dp-field").forEach(function (x) { x.classList.toggle("is-active", x === inp); }); + }); + function commit() { + const kind = inp.dataset.kind; + const cur = kind === "start" ? start : due; + const parsed = parseTypedDate(inp.value, today); + if (parsed === null || parsed === cur) { inp.value = fmtFieldDate(cur); return; } + if (!parsed) { + if (kind === "start") { start = ""; showStart = false; } else due = ""; + render(); emit(); return; + } + active = kind; + const d = new Date(parsed + "T00:00:00"); + viewY = d.getFullYear(); viewM = d.getMonth(); + pick(parsed); + } + inp.addEventListener("keydown", function (e) { + if (e.isComposing) return; + if (e.key === "Enter") { e.preventDefault(); commit(); } + }); + inp.addEventListener("change", commit); + }); + pop.querySelector(".pj-dp-today").addEventListener("click", function () { + const d = new Date(); viewY = d.getFullYear(); viewM = d.getMonth(); + pick(today); + }); + pop.querySelector(".pj-dp-clear").addEventListener("click", function () { + start = ""; due = ""; emit(); closeDatePopover(); + }); + } + function focusActive() { + const f = pop.querySelector('.pj-dp-field[data-kind="' + active + '"]'); + if (f) f.focus(); + } + function place() { + const r = anchor.getBoundingClientRect(); + const vw = document.documentElement.clientWidth, vh = document.documentElement.clientHeight; + const w = pop.offsetWidth, h = pop.offsetHeight; + const ax = r.left + r.width / 2; + const left = Math.min(Math.max(8, ax - w / 2), vw - w - 8); + const below = r.bottom + 10 + h <= vh - 8 || r.top - 10 - h < 8; + pop.classList.toggle("is-above", !below); + pop.style.left = left + "px"; + pop.style.top = (below ? r.bottom + 10 : r.top - 10 - h) + "px"; + pop.style.setProperty("--pj-dp-tail", Math.min(Math.max(ax - left, 16), w - 16) + "px"); + } + function onDown(e) { + if (pop.contains(e.target) || anchor.contains(e.target)) return; + closeDatePopover(); + } + function onKey(e) { if (e.key === "Escape") { e.stopPropagation(); closeDatePopover(); } } + render(); + place(); + setTimeout(function () { + document.addEventListener("mousedown", onDown, true); + document.addEventListener("keydown", onKey, true); + }, 0); + window.addEventListener("resize", closeDatePopover); + datePopCleanup = function () { + document.removeEventListener("mousedown", onDown, true); + document.removeEventListener("keydown", onKey, true); + window.removeEventListener("resize", closeDatePopover); + }; + focusActive(); + } + // ── 탭 그룹(뷰 탭/스코프 토글, 둘 다 .pj-view-tabs 마크업 공유)에 슬라이드 // 하이라이트를 붙인다 — is-active 를 단순 배경색 대신, 실제 위치가 움직이는 // 절대배치 요소 하나로 표현한다. 탭 클릭·초기 렌더·리사이즈마다 위치 재계산. @@ -1208,8 +1421,9 @@ key: "due", label: "마감", cls: "pj-mtk-date", html: function (t) { if (!t.due_date) return "-"; - const overdue = !t.completed_at && t.due_date.slice(0, 10) < today; - return '' + fmtDateKr(t.due_date) + ""; + const di = dueInfo(t.due_date, !!t.completed_at); + return '' + + escapeHtml(di.text) + ""; }, sort: function (t) { return t.due_date || "9999-99-99"; }, }, @@ -2638,48 +2852,12 @@ )); } - // 마감일 — 카드 위에 작은 날짜 입력칸을 띄운다. 값이 바뀌면 바로 저장하고, - // "지우기"로 마감일을 없앨 수 있다. 바깥을 누르면 닫힌다. - let inlineDateEl = null; - function closeInlineDate() { - if (inlineDateEl) { inlineDateEl.remove(); inlineDateEl = null; } - document.removeEventListener("mousedown", onInlineDateDown, true); - } - function onInlineDateDown(e) { - if (inlineDateEl && !inlineDateEl.contains(e.target)) closeInlineDate(); - } - // onPick(v) 를 주면 저장을 그쪽에 맡긴다(카드의 하위 업무 줄 — 보드 전체가 - // 아니라 그 목록만 다시 그림). 없으면 applyTaskPatch 로 업무에 저장. + // 마감일(+시작일) — 아사나식 날짜 팝업(openDatePopover). onPick(patch) 를 + // 주면 저장을 그쪽에 맡긴다(카드의 하위 업무 줄 — 그 목록만 다시 그림). + // 없으면 applyTaskPatch 로 업무에 저장. function openDuePicker(t, anchorEl, onPick) { - closeInlineDate(); - const save = onPick || function (v) { applyTaskPatch(t, { due_date: v }, "마감일 변경 실패"); }; - const box = document.createElement("div"); - box.className = "pj-inline-date"; - box.innerHTML = '' + - ''; - document.body.appendChild(box); - const r = anchorEl.getBoundingClientRect(); - let left = window.scrollX + r.left; - left = Math.min(left, window.scrollX + document.documentElement.clientWidth - box.offsetWidth - 8); - box.style.left = Math.max(8, left) + "px"; - box.style.top = (window.scrollY + r.bottom + 4) + "px"; - inlineDateEl = box; - const input = box.querySelector("input"); - input.addEventListener("change", function () { - const v = input.value || null; - closeInlineDate(); - if (v === (t.due_date || null)) return; - save(v); - }); - box.querySelector("button").addEventListener("click", function () { - closeInlineDate(); - if (!t.due_date) return; - save(null); - }); - setTimeout(function () { - document.addEventListener("mousedown", onInlineDateDown, true); - try { input.focus(); if (input.showPicker) input.showPicker(); } catch (_) {} - }, 0); + const save = onPick || function (patch) { applyTaskPatch(t, patch, "마감일 변경 실패"); }; + openDatePopover(anchorEl, { start: t.start_date, due: t.due_date, allowStart: true, onChange: save }); } // ── 카드 하위 업무 펼치기(아사나처럼) — 카드의 "N ⤷ ▾" 버튼을 누르면 카드 @@ -2699,7 +2877,7 @@ '' + ""; function cardSubRowHtml(sub) { - const overdue = sub.due_date && !sub.completed_at && sub.due_date < todayIso; + const di = dueInfo(sub.due_date, !!sub.completed_at); return '
' + '' + @@ -2707,8 +2885,7 @@ // 마감일 — 있으면 날짜, 없으면 아사나처럼 점선 원 달력 아이콘(줄에 마우스를 // 올리면 보임). 둘 다 누르면 날짜 선택. (sub.due_date - ? '' + - escapeHtml(fmtDateKr(sub.due_date)) + "" + ? '' + escapeHtml(di.text) + "" : '' + DUE_EMPTY_ICON_SVG + "") + // 담당자 — 있으면 아바타, 없으면 아사나처럼 점선 원 사람 아이콘(줄에 // 마우스를 올리면 보임). 누르면 멤버 선택, 말풍선은 data-tip(initHoverTips). @@ -2786,10 +2963,10 @@ const due = row.querySelector(".pj-card-sub-due"); if (due && canManage) due.addEventListener("click", function (e) { e.stopPropagation(); - openDuePicker(sub, due, async function (v) { + openDuePicker(sub, due, async function (patch) { try { - await api("PUT", "/project/api/tasks/" + sub.id, { due_date: v }); - sub.due_date = v; + await api("PUT", "/project/api/tasks/" + sub.id, patch); + Object.assign(sub, patch); if (box.isConnected) fillCardSubs(box, t); } catch (err) { showToast("마감일 변경 실패: " + err.message, "error"); } }); @@ -2879,8 +3056,12 @@ (t.assignee_email ? '' : ' is-empty') + '" title="담당자 변경">' + avatarHtml(t.assignee_email, "pj-gicon-sm") + escapeHtml(t.assignee_email ? idOf(t.assignee_email) : "담당자") + "" + - '' + (t.due_date ? escapeHtml(t.due_date) : "마감일") + "" + + (function () { + const di = dueInfo(t.due_date, !!t.completed_at); + return '' + + (di ? escapeHtml(di.text) : "마감일") + ""; + })() + // 하위 업무 — 아사나처럼 "개수 + 하위 업무 아이콘 + ▾", 누르면 카드 아래로 펼침. (t.subtask_total ? '