diff --git a/app/modules/notice/router.py b/app/modules/notice/router.py index 86f3058..c0055f5 100644 --- a/app/modules/notice/router.py +++ b/app/modules/notice/router.py @@ -75,9 +75,11 @@ def notice_admin_page(request: Request) -> HTMLResponse: user = _super(request) st = getattr(request.app.state, "notice_store", None) enabled = bool(st) and st.enabled() + # 받는 사람 후보 = 등록 사용자 전원 — 프로젝트 멤버 고르기와 같은 모양(아이콘 + 이름)으로 그린다(project.js memberPickHtml) people = sorted( - ({"email": u["email"], "name": u.get("name") or u["email"].split("@")[0]} for u in user_store.list_all()), - key=lambda p: p["email"], + ({"email": u["email"], "id": u["email"].split("@")[0], "name": u.get("name") or u["email"].split("@")[0], + "avatar": u.get("picture") or ""} for u in user_store.list_all()), + key=lambda p: p["id"], ) return render_template(request, "notice/admin.html", { "user": user, "is_admin": is_admin(user), diff --git a/app/modules/notice/templates/notice/admin.html b/app/modules/notice/templates/notice/admin.html index 9f649cc..7b87cb8 100644 --- a/app/modules/notice/templates/notice/admin.html +++ b/app/modules/notice/templates/notice/admin.html @@ -1,7 +1,10 @@ {% extends "erp_base.html" %} {% block head_extra %} +{# 프로젝트 화면 부품(설명 편집기·날짜 팝업·멤버 고르기)을 그대로 쓴다 — project.js 는 PJ_LIB_ONLY 로 부품만 #} + + {% endblock %} {% block content %} @@ -18,36 +21,39 @@ -
내용 -
- - - + {# 내용 — 작업 설명란과 같은 편집기(서식 도구 전체·이미지 붙여넣기/버튼·크기 조절·링크·체크리스트) #} +
+
내용
+ {% with fmtbar_id = "ntc-fmtbar", img_input_id = "ntc-img-input" %}{% include "project/_desc_fmtbar.html" %}{% endwith %} +
+
+
+
+ {# 띄울 날짜 — 프로젝트와 같은 날짜 팝업(공휴일·오늘·지우기), 시각은 옆 칸. 둘 다 비우면 바로 #} +
띄울 시각 한국시간 · 날짜를 비우면 바로 +
+ +
-
-
받는 사람
- - -
-
- + + {% endif %} {% endblock %} diff --git a/app/modules/project/templates/project/_desc_fmtbar.html b/app/modules/project/templates/project/_desc_fmtbar.html new file mode 100644 index 0000000..c02f0a3 --- /dev/null +++ b/app/modules/project/templates/project/_desc_fmtbar.html @@ -0,0 +1,23 @@ +{# 설명란 서식 도구(작업 창·긴급 공지 관리 공용). fmtbar_id·img_input_id 를 주면 그 id 로(기본 = 작업 창 id). + 동작은 project.js createDescEditor — 버튼 data-cmd 를 그대로 쓴다. #} +{# 서식 도구 — 모든 버튼을 같은 아이콘 글꼴(Material Symbols)·같은 크기로 그려 + 한 줄에 딱 맞춰 선다(예전엔 글자·이모지가 섞여 높이가 들쭉날쭉했다). #} +
+ + + + + {# 글자 색·크기(2026-10-08) — 누르면 고르는 창(body 에 붙음). 저장 때 서버가 span 의 color·font-size 만 남긴다 #} + + + + + + + + + + + + +
diff --git a/app/modules/project/templates/project/goal_meeting.html b/app/modules/project/templates/project/goal_meeting.html index 7720987..95ba4f4 100644 --- a/app/modules/project/templates/project/goal_meeting.html +++ b/app/modules/project/templates/project/goal_meeting.html @@ -292,5 +292,5 @@ - + {% endblock %} diff --git a/app/modules/project/templates/project/goals.html b/app/modules/project/templates/project/goals.html index 54464d1..ff1938e 100644 --- a/app/modules/project/templates/project/goals.html +++ b/app/modules/project/templates/project/goals.html @@ -207,5 +207,5 @@ {% include "project/_member_tasks_modal.html" %} - + {% endblock %} diff --git a/app/modules/project/templates/project/inbox.html b/app/modules/project/templates/project/inbox.html index 9e56910..3cbb42f 100644 --- a/app/modules/project/templates/project/inbox.html +++ b/app/modules/project/templates/project/inbox.html @@ -101,5 +101,5 @@ {% include "project/_side_modals.html" %} {% 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 7f83b41..330da56 100644 --- a/app/modules/project/templates/project/mytasks.html +++ b/app/modules/project/templates/project/mytasks.html @@ -100,5 +100,5 @@ "today": {{ today | tojson }} } - + {% endblock %} diff --git a/app/modules/project/templates/project/notifier.html b/app/modules/project/templates/project/notifier.html index 0506714..9f035b0 100644 --- a/app/modules/project/templates/project/notifier.html +++ b/app/modules/project/templates/project/notifier.html @@ -108,5 +108,5 @@ }); })(); - + {% endblock %} diff --git a/app/modules/project/templates/project/project.html b/app/modules/project/templates/project/project.html index cc98bb3..8ecdea7 100644 --- a/app/modules/project/templates/project/project.html +++ b/app/modules/project/templates/project/project.html @@ -349,27 +349,7 @@ 설명
- {# 서식 도구 — 모든 버튼을 같은 아이콘 글꼴(Material Symbols)·같은 크기로 그려 - 한 줄에 딱 맞춰 선다(예전엔 글자·이모지가 섞여 높이가 들쭉날쭉했다). #} -
- - - - - {# 글자 색·크기(2026-10-08) — 누르면 고르는 창(body 에 붙음). 저장 때 서버가 span 의 color·font-size 만 남긴다 #} - - - - - - - - - - - - -
+ {% include "project/_desc_fmtbar.html" %}
@@ -488,5 +468,5 @@ - + {% endblock %} diff --git a/app/modules/project/templates/project/trash.html b/app/modules/project/templates/project/trash.html index 07ec898..f90b889 100644 --- a/app/modules/project/templates/project/trash.html +++ b/app/modules/project/templates/project/trash.html @@ -70,5 +70,5 @@ {% include "project/_side_modals.html" %} {% include "project/_member_tasks_modal.html" %} - + {% endblock %} diff --git a/app/static/erp-notice-admin.js b/app/static/erp-notice-admin.js index 4de62d3..0f2f59f 100644 --- a/app/static/erp-notice-admin.js +++ b/app/static/erp-notice-admin.js @@ -1,12 +1,19 @@ -// 긴급 공지 관리(/notice/, 수퍼관리자) — 만들기·고치기·취소·이미지·미리 보기·확인 현황. +// 긴급 공지 관리(/notice/, 수퍼관리자) — 만들기·고치기·취소·미리 보기·확인 현황. +// 내용 편집기·날짜 팝업·받는 사람 고르기는 프로젝트 화면 부품 그대로(window.PJLib — project.js, PJ_LIB_ONLY): +// · 내용 = 작업 설명란과 같은 편집기(굵게·기울임·밑줄·취소선·글자 색/크기·목록·체크리스트·인용·링크·서식 지우기·이미지 +// 붙여넣기/버튼·크기 조절), 이미지는 /notice/api/images 로 올린다. +// · 띄울 날짜 = 아사나식 날짜 팝업(공휴일·오늘·지우기), 시각은 옆 칸. +// · 받는 사람 = 프로젝트 멤버 고르기와 같은 아이콘 + 이름 + 체크. (function () { "use strict"; const root = document.getElementById("ntc-root"); - if (!root) return; + if (!root || !window.PJLib) return; + const L = window.PJLib; const $ = function (id) { return document.getElementById(id); }; - const people = {}; - (window.NTC_PEOPLE || []).forEach(function (p) { people[String(p.email).toLowerCase()] = p.name; }); - const nameOf = function (e) { return people[String(e).toLowerCase()] || String(e).split("@")[0]; }; + const people = window.NTC_PEOPLE || []; + const byEmail = {}; + people.forEach(function (p) { byEmail[String(p.email).toLowerCase()] = p; }); + const nameOf = function (e) { const p = byEmail[String(e).toLowerCase()]; return p ? p.name : String(e).split("@")[0]; }; const esc = function (s) { return String(s == null ? "" : s).replace(/[&<>"']/g, function (c) { return { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]; @@ -32,94 +39,65 @@ return data || {}; } - const title = $("ntc-title"), body = $("ntc-body"), showAt = $("ntc-show-at"), idEl = $("ntc-id"); + const title = $("ntc-title"), dateEl = $("ntc-date"), timeEl = $("ntc-time"), idEl = $("ntc-id"); const peopleBox = $("ntc-people"), msg = $("ntc-msg"), save = $("ntc-save"); - const say = function (text, ok) { msg.textContent = text || ""; msg.hidden = !text; msg.style.color = ok ? "#1f7a3a" : ""; }; + const say = function (text, ok) { msg.textContent = text || ""; msg.hidden = !text; msg.classList.toggle("is-ok", !!ok); }; + + // ── 내용 — 작업 설명란 편집기 ── + const editor = L.createDescEditor({ + box: $("ntc-body"), fmtbar: $("ntc-fmtbar"), imgInput: $("ntc-img-input"), hint: $("ntc-hint"), mentions: false, + uploadImage: async function (file) { + const fd = new FormData(); + fd.append("file", file, file.name || "image"); + return (await api("POST", "/notice/api/images", fd, true)).image.url; + }, + }); + // ── 날짜 — 프로젝트 날짜 팝업 ── + L.enhanceDateInput(dateEl, { placeholder: "날짜(비우면 바로)" }); + // ── 받는 사람 — 프로젝트 멤버 고르기 모양 ── + peopleBox.innerHTML = people.map(L.memberPickHtml).join("") || '등록된 사람이 없습니다.'; function toAll() { return root.querySelector('input[name="ntc-to"]:checked').value === "all"; } root.querySelectorAll('input[name="ntc-to"]').forEach(function (r) { r.addEventListener("change", function () { peopleBox.hidden = toAll(); }); }); - - // ── 본문 편집 — 굵게, 이미지(버튼·붙여넣기·끌어 놓기 → 서버에 올리고 주소로 넣는다) ── - root.querySelector('[data-cmd="bold"]').addEventListener("click", function () { body.focus(); document.execCommand("bold"); }); - let savedRange = null; - body.addEventListener("keyup", keepRange); - body.addEventListener("mouseup", keepRange); - body.addEventListener("blur", keepRange); - function keepRange() { - const s = window.getSelection(); - if (s.rangeCount && body.contains(s.getRangeAt(0).commonAncestorContainer)) savedRange = s.getRangeAt(0).cloneRange(); + function picked() { + return Array.from(peopleBox.querySelectorAll("input[type=checkbox]:checked")).map(function (c) { return c.value; }); } - function insertNode(node) { - body.focus(); - const s = window.getSelection(); - let r = savedRange && body.contains(savedRange.commonAncestorContainer) ? savedRange : null; - if (!r) { r = document.createRange(); r.selectNodeContents(body); r.collapse(false); } - r.deleteContents(); - r.insertNode(node); - r.setStartAfter(node); r.collapse(true); - s.removeAllRanges(); s.addRange(r); - savedRange = r.cloneRange(); + function setPicked(emails) { + const want = (emails || []).map(function (e) { return String(e).toLowerCase(); }); + peopleBox.querySelectorAll("input[type=checkbox]").forEach(function (c) { c.checked = want.indexOf(c.value.toLowerCase()) >= 0; }); } - let uploading = 0; - async function uploadImages(files) { - for (const f of files) { - if (!/^image\/(png|jpeg|gif|webp)$/.test(f.type)) { say("이미지(png·jpg·gif·webp)만 넣을 수 있습니다: " + f.name); continue; } - uploading++; - save.disabled = true; - try { - const fd = new FormData(); - fd.append("file", f, f.name || "image"); - const res = await api("POST", "/notice/api/images", fd, true); - const img = document.createElement("img"); - img.src = res.image.url; - img.alt = f.name || ""; - insertNode(img); - say(""); - } catch (e) { say("이미지를 올리지 못했습니다: " + e.message); } - finally { uploading--; if (!uploading) save.disabled = false; } - } - } - $("ntc-image-btn").addEventListener("click", function () { keepRange(); $("ntc-image-file").click(); }); - $("ntc-image-file").addEventListener("change", function (e) { uploadImages(Array.from(e.target.files || [])); e.target.value = ""; }); - body.addEventListener("paste", function (e) { - const files = Array.from((e.clipboardData && e.clipboardData.files) || []).filter(function (f) { return /^image\//.test(f.type); }); - if (files.length) { e.preventDefault(); keepRange(); uploadImages(files); } - }); - body.addEventListener("dragover", function (e) { e.preventDefault(); }); - body.addEventListener("drop", function (e) { - const files = Array.from((e.dataTransfer && e.dataTransfer.files) || []).filter(function (f) { return /^image\//.test(f.type); }); - if (files.length) { e.preventDefault(); keepRange(); uploadImages(files); } - }); // ── 저장(만들기·고치기) ── + function showAtValue() { + // 날짜를 비우면 바로(서버가 지금으로), 날짜만 있으면 그날 00:00, 시각까지 있으면 그 시각 — 모두 한국시간 + return dateEl.value ? dateEl.value + "T" + (timeEl.value || "00:00") : ""; + } function payload() { return { - title: title.value.trim(), body_html: body.innerHTML, show_at: showAt.value || "", - to_all: toAll(), - targets: Array.from(peopleBox.querySelectorAll("input:checked")).map(function (c) { return c.value; }), - reshow: $("ntc-reshow").checked, + title: title.value.trim(), body_html: editor.getHtml(), show_at: showAtValue(), + to_all: toAll(), targets: picked(), reshow: $("ntc-reshow").checked, }; } function resetForm() { - idEl.value = ""; title.value = ""; body.innerHTML = ""; showAt.value = ""; + idEl.value = ""; title.value = ""; editor.setHtml(""); dateEl.value = ""; timeEl.value = ""; root.querySelector('input[name="ntc-to"][value="all"]').checked = true; peopleBox.hidden = true; - peopleBox.querySelectorAll("input").forEach(function (c) { c.checked = false; }); + setPicked([]); $("ntc-reshow").checked = false; $("ntc-reshow-row").hidden = true; $("ntc-form-title").textContent = "새 긴급 공지"; save.textContent = "공지 만들기"; - savedRange = null; } $("ntc-reset").addEventListener("click", function () { resetForm(); say(""); }); let saving = false; save.addEventListener("click", async function () { - if (saving || uploading) return; - const p = payload(); - if (!p.title) { say("제목을 입력하세요."); title.focus(); return; } - if (!p.to_all && !p.targets.length) { say("받는 사람을 한 명 이상 고르거나 '전체'를 고르세요."); return; } + if (saving) return; saving = true; save.disabled = true; try { + await editor.whenIdle(); // 이미지 올리는 중이면 끝난 뒤 저장(빠진 채 저장되지 않게) + const p = payload(); + if (!p.title) { say("제목을 입력하세요."); title.focus(); return; } + if (!p.to_all && !p.targets.length) { say("받는 사람을 한 명 이상 고르거나 '전체'를 고르세요."); return; } const id = idEl.value; if (id) await api("PUT", "/notice/api/notices/" + id, p); else await api("POST", "/notice/api/notices", p); @@ -131,7 +109,7 @@ }); // ── 미리 보기 — 받는 사람 화면과 같은 모양 ── - $("ntc-preview").addEventListener("click", function () { preview(title.value.trim() || "(제목 없음)", body.innerHTML); }); + $("ntc-preview").addEventListener("click", function () { preview(title.value.trim() || "(제목 없음)", editor.getHtml()); }); function preview(t, html) { const box = document.createElement("div"); box.className = "erp-notice-backdrop"; @@ -173,9 +151,9 @@ '
' + esc(st[1]) + "" + '' + esc(n.title) + "" + '' + - '' + - '' + - '" + + '' + + '' + + '" + "
" + '
띄울 시각 ' + esc(shortWhen(n.show_at)) + " · 받는 사람 " + esc(who) + " · 만든 사람 " + esc(nameOf(n.created_by)) + "
" + @@ -194,10 +172,11 @@ if (!n) return; if (b.dataset.act === "preview") { preview(n.title, n.body_html); return; } if (b.dataset.act === "edit") { - idEl.value = n.id; title.value = n.title; body.innerHTML = n.body_html; showAt.value = (n.show_at || "").slice(0, 16); + idEl.value = n.id; title.value = n.title; editor.setHtml(n.body_html); + dateEl.value = (n.show_at || "").slice(0, 10); timeEl.value = (n.show_at || "").slice(11, 16); root.querySelector('input[name="ntc-to"][value="' + (n.to_all ? "all" : "some") + '"]').checked = true; peopleBox.hidden = n.to_all; - peopleBox.querySelectorAll("input").forEach(function (c) { c.checked = n.targets.indexOf(c.value.toLowerCase()) >= 0; }); + setPicked(n.targets); $("ntc-reshow-row").hidden = false; $("ntc-reshow").checked = false; $("ntc-form-title").textContent = "공지 고치기"; save.textContent = "고친 내용 저장"; diff --git a/app/static/erp-notice.css b/app/static/erp-notice.css index afba7a0..afa9288 100644 --- a/app/static/erp-notice.css +++ b/app/static/erp-notice.css @@ -27,7 +27,22 @@ } .erp-notice-body p { margin: 0 0 .6em; } .erp-notice-body img { display: block; max-width: 100%; height: auto; margin: 8px 0; border-radius: 8px; } -.erp-notice-body a { color: #3b6fd8; } +.erp-notice-body a { color: #3b6fd8; text-decoration: underline; } +/* 작업 설명란 편집기와 같은 서식(project.css .pj-desc-editor) — 프로젝트 밖 화면에서도 같게 보이게 */ +.erp-notice-body blockquote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid #d5d9de; color: #565c66; } +.erp-notice-body ul, .erp-notice-body ol { margin: 4px 0; padding-left: 22px; } +.erp-notice-body ul.pj-checklist { list-style: none; padding-left: 24px; } +.erp-notice-body ul.pj-checklist > li { position: relative; } +.erp-notice-body ul.pj-checklist > li::before { + content: ""; position: absolute; left: -22px; top: .3em; width: 14px; height: 14px; + box-sizing: border-box; border: 1.5px solid #8f959d; border-radius: 3px; background: #fff; +} +.erp-notice-body ul.pj-checklist > li[data-checked="true"]::before { + border-color: #7b68ee; background: #7b68ee center / 10px 10px no-repeat + url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.3l2.6 2.6L10 3.4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); +} +.erp-notice-body ul.pj-checklist > li[data-checked="true"] { color: #9aa1a9; text-decoration: line-through; } +.erp-notice-body img[width] { height: auto; } .erp-notice-error { margin: 0; padding: 6px 10px; border-radius: 6px; background: #fdecec; color: #b42318; font-size: 13px; } .erp-notice-error[hidden] { display: none; } .erp-notice-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px; border-top: 1px solid #eceef1; } @@ -41,31 +56,31 @@ .erp-notice-ok:disabled { opacity: .6; cursor: default; } /* 관리 화면(/notice/) */ -.ntc-wrap { display: grid; grid-template-columns: minmax(360px, 520px) 1fr; gap: 18px; align-items: start; } +.ntc-wrap { display: grid; grid-template-columns: minmax(420px, 640px) 1fr; gap: 18px; align-items: start; } @media (max-width: 1100px) { .ntc-wrap { grid-template-columns: 1fr; } } .ntc-card { background: #fff; border: 1px solid #e6e8eb; border-radius: 12px; padding: 18px; } .ntc-card h2 { margin: 0 0 12px; font-size: 16px; } .ntc-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; font-weight: 700; color: #3b4048; } -.ntc-field input[type=text], .ntc-field input[type=datetime-local] { +.ntc-field input[type=text], .ntc-time { font: inherit; font-weight: 500; padding: 8px 10px; border: 1px solid #d5d9de; border-radius: 8px; } -.ntc-editor-bar { display: flex; gap: 4px; } -.ntc-editor-bar button { padding: 4px 10px; border: 1px solid #d5d9de; border-radius: 6px; background: #fff; cursor: pointer; font: inherit; font-size: 12.5px; } -.ntc-editor { - min-height: 160px; max-height: 420px; overflow: auto; padding: 10px 12px; border: 1px solid #d5d9de; border-radius: 8px; - font-weight: 400; font-size: 14px; line-height: 1.6; color: #2b2f36; outline: none; -} -.ntc-editor:focus { border-color: #7b68ee; box-shadow: 0 0 0 3px rgba(123, 104, 238, .15); } -.ntc-editor:empty::before { content: attr(data-placeholder); color: #a0a5ad; } -.ntc-editor img { max-width: 100%; height: auto; border-radius: 6px; } -.ntc-targets { display: flex; flex-direction: column; gap: 6px; font-weight: 500; } -.ntc-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 10px; max-height: 220px; overflow: auto; - padding: 8px; border: 1px solid #e6e8eb; border-radius: 8px; } +.ntc-sub { font-weight: 500; color: #8a9099; } +.ntc-desc .pj-desc-toolbar { display: flex; align-items: center; gap: 8px; } +.ntc-desc .pj-desc-wrap { position: relative; } +.ntc-desc .pj-desc-editor { min-height: 180px; max-height: 460px; overflow: auto; font-weight: 400; + padding: 10px 12px; border: 1px solid #d5d9de; border-radius: 8px; } +.ntc-desc .pj-desc-editor:focus { border-color: #7b68ee; box-shadow: 0 0 0 3px rgba(123, 104, 238, .15); outline: none; } +.ntc-when { display: flex; align-items: center; gap: 8px; font-weight: 500; } +.ntc-time { padding: 6px 8px; } +.ntc-targets { display: flex; flex-direction: column; gap: 8px; font-weight: 500; } +.ntc-to { display: flex; gap: 16px; flex-wrap: wrap; } +.ntc-people { max-height: 260px; } .ntc-people[hidden] { display: none; } -.ntc-people label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; } +.ntc-inline { flex-direction: row; align-items: center; font-weight: 500; } .ntc-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; } .ntc-msg { margin: 8px 0 0; font-size: 13px; color: #b42318; } .ntc-msg[hidden] { display: none; } +.ntc-msg.is-ok { color: #1f7a3a; } .ntc-list { display: flex; flex-direction: column; gap: 10px; } .ntc-item { border: 1px solid #e6e8eb; border-radius: 10px; padding: 12px 14px; } .ntc-item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } diff --git a/app/static/project.js b/app/static/project.js index b8e7c09..75a0d6b 100644 --- a/app/static/project.js +++ b/app/static/project.js @@ -7511,14 +7511,23 @@ // ── 설명(contenteditable) — 붙여넣기/업로드로 이미지를 끼워 넣는다 ── function initDescEditor() { - const box = el("pj-t-desc"); + return createDescEditor({ + box: el("pj-t-desc"), fmtbar: el("pj-desc-fmtbar"), imgInput: el("pj-desc-img-input"), + hint: el("pj-desc-hint"), mentions: true, + }); + } + // 설명 편집기 본체 — 작업 창(initDescEditor)과 긴급 공지 관리 화면(window.PJLib)이 같이 쓴다. + // cfg.box·fmtbar·imgInput·hint — 요소, cfg.mentions — @태그(작업 설명란만), + // cfg.uploadImage(file) → Promise<이미지 주소> — 주면 그걸로 올린다(없으면 작업 첨부로, setTaskId 필요). + function createDescEditor(cfg) { + const box = cfg.box; if (!box) return null; // @ 를 누르면 멤버 목록 → 고르면 멘션 칩이 들어간다(수신함에 쌓인다). - attachMentionEditor(box); + if (cfg.mentions) attachMentionEditor(box); const wrap = box.parentElement; - const imgInput = el("pj-desc-img-input"); - const hint = el("pj-desc-hint"); - let taskId = null; + const imgInput = cfg.imgInput || null; + const hint = cfg.hint || null; + let taskId = cfg.uploadImage ? "custom" : null; // 자체 업로드면 늘 이미지 추가 가능 // ── 서식 도구 모음(간단 워드프로세서) — execCommand 는 구식 API지만 // 크롬/엣지는 여전히 지원하고, 이미 같은 파일의 이미지 삽입에서도 쓰고 @@ -7608,7 +7617,7 @@ box.dispatchEvent(new Event("input", { bubbles: true })); }); - const fmtbar = el("pj-desc-fmtbar"); + const fmtbar = cfg.fmtbar || null; if (fmtbar) { fmtbar.addEventListener("mousedown", function (e) { e.preventDefault(); }); fmtbar.addEventListener("click", function (e) { @@ -7964,16 +7973,18 @@ saveSelection(); const insertAt = lastRange ? lastRange.cloneRange() : null; beginUpload(); - const fd = new FormData(); - fd.append("file", file); - try { - const results = await Promise.all([ - naturalImageSize(file), - fetch("/project/api/tasks/" + myTaskId + "/attachments", { method: "POST", body: fd }), - ]); - const dims = results[0], res = results[1]; + // 작업 설명란 = 그 작업 첨부로 올린다. 다른 화면(긴급 공지)은 cfg.uploadImage 가 주소를 돌려준다. + const upload = cfg.uploadImage || async function (f) { + const fd = new FormData(); + fd.append("file", f); + const res = await fetch("/project/api/tasks/" + myTaskId + "/attachments", { method: "POST", body: fd }); if (!res.ok) { let m = res.statusText; try { m = (await res.json()).detail; } catch (_) {} throw new Error(m); } const data = await res.json(); + return "/project/api/attachments/" + data.attachment.id + "/inline"; + }; + try { + const results = await Promise.all([naturalImageSize(file), upload(file)]); + const dims = results[0], imgSrc = results[1]; if (myGen !== editorGen || myTaskId !== taskId) { showToast("이미지는 원래 작업의 첨부 파일로 저장됐습니다(작업 창이 바뀌어 설명에는 넣지 않았습니다)."); return; @@ -7985,7 +7996,7 @@ if (insertAt) { try { const sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(insertAt); } catch (_) {} } - insertHtmlAtCursor(''); + insertHtmlAtCursor(''); } catch (e) { alert("이미지 업로드 실패: " + e.message); } finally { endUpload(); } } @@ -11410,7 +11421,15 @@ poll(); } + // 다른 화면이 프로젝트 부품을 같이 쓴다(긴급 공지 관리 — app/modules/notice): 설명 편집기(서식 도구 전체·이미지)· + // 아사나식 날짜 팝업·멤버 고르기(아이콘 + 이름)·알림. window.PJ_LIB_ONLY 면 프로젝트 화면 초기화는 하지 않고 + // 공용 말풍선만 켠다(프로젝트 알림 팝업 확인·실시간 동기화 등이 그 화면에서 돌지 않게). + window.PJLib = { + createDescEditor: createDescEditor, enhanceDateInput: enhanceDateInput, + memberPickHtml: memberPickHtml, showToast: showToast, + }; document.addEventListener("DOMContentLoaded", function () { + if (window.PJ_LIB_ONLY) { initHoverTips(); return; } // 좌측 프로젝트 목록 — 프로젝트 화면은 initProject 가 자기 데이터로 직접 연다. if (!document.querySelector(".pj-project-view")) initSideTree(); initTrash(); diff --git a/app/templates/admin.html b/app/templates/admin.html index e782288..e090181 100644 --- a/app/templates/admin.html +++ b/app/templates/admin.html @@ -341,7 +341,7 @@ }); {# 긴급 공지 — erp_base 를 쓰지 않는 화면도 같이(app/modules/notice) #} - + diff --git a/app/templates/erp_base.html b/app/templates/erp_base.html index 9f3ebff..192b717 100644 --- a/app/templates/erp_base.html +++ b/app/templates/erp_base.html @@ -8,7 +8,7 @@ - + {% block head_extra %}{% endblock %} diff --git a/app/templates/main.html b/app/templates/main.html index 6d6c43e..9e060be 100644 --- a/app/templates/main.html +++ b/app/templates/main.html @@ -168,7 +168,7 @@ setInterval(refreshHealth, 30000); {# 긴급 공지 — erp_base 를 쓰지 않는 화면도 같이(app/modules/notice) #} - + diff --git a/docs/NOTICE_MODULE.md b/docs/NOTICE_MODULE.md index f4844f6..f0b1e76 100644 --- a/docs/NOTICE_MODULE.md +++ b/docs/NOTICE_MODULE.md @@ -15,11 +15,17 @@ ## 화면 -- **관리(`/notice/`)** — 제목, 내용(굵게·이미지: 버튼·붙여넣기·끌어 놓기 → 서버에 올리고 주소로 넣음), 띄울 시각(한국시간, - 비우면 바로), 받는 사람(전체 / 고른 사람 — 등록 사용자 목록), [미리 보기](받는 사람 화면과 같은 모양). 목록 = 상태(예약 · 표시 중 · - 취소됨) · 받는 사람 · 확인 현황(확인한 사람·시각, 아직 안 한 사람). [고치기]([이미 확인한 사람에게도 다시 띄우기] 선택 가능) · - [취소](더 띄우지 않음, 기록은 남음) · [취소 되돌리기]. -- **표시(`static/erp-notice.js`)** — `erp_base.html` 을 쓰는 모든 화면 + 업무 모듈 첫 화면(`main.html`)·관리자 페이지(`admin.html`). +- **관리(`/notice/`)** — 프로젝트 화면 부품을 그대로 쓴다(`project.js` 를 `window.PJ_LIB_ONLY` 로 불러 `window.PJLib` 만 — + 프로젝트 알림 팝업·실시간 동기화 등은 이 화면에서 돌지 않는다): + · **내용** = 작업 설명란과 같은 편집기(`createDescEditor`, 서식 도구 `project/_desc_fmtbar.html` 공용 — 굵게·기울임·밑줄·취소선· + 글자 색/크기·글머리/번호 목록·체크리스트·인용·링크·서식 지우기·이미지 버튼/붙여넣기·크기 조절·더블클릭 크게 보기). @태그만 뺐다 + (공지는 작업이 아니라 수신함에 쌓일 곳이 없다). 이미지는 `/notice/api/images` 로 올린다. + · **띄울 날짜** = 프로젝트 날짜 팝업(`enhanceDateInput` — 일요일·공휴일 빨강·오늘·지우기), 시각은 옆 칸(5분 단위). 날짜를 비우면 바로. + · **받는 사람** = 전체 / 고른 사람 — 프로젝트 멤버 고르기와 같은 아이콘 + 이름 + 체크(`memberPickHtml`, 등록 사용자 전원). + · [미리 보기](받는 사람 화면과 같은 모양). 목록 = 상태(예약 · 표시 중 · 취소됨) · 받는 사람 · 확인 현황(확인한 사람·시각, 아직 안 한 사람). + [고치기]([이미 확인한 사람에게도 다시 띄우기] 선택 가능) · [취소](더 띄우지 않음, 기록은 남음) · [취소 되돌리기]. +- **표시(`static/erp-notice.js`)** — `erp_base.html` 을 쓰는 모든 화면 + 업무 모듈 첫 화면(`main.html`)·관리자 페이지(`admin.html`). 본문 서식(목록·체크리스트·인용)은 + `erp-notice.css` 가 작업 설명란과 같게 그린다(프로젝트 밖 화면에서도). `GET /notice/api/pending` 을 열 때·30초마다·창을 다시 볼 때 확인(띄울 시각 정밀도 ≈30초). 여러 건이면 오래된 것부터 차례대로(1/3). `document.body` 에 붙여 화면 배율(`.erp-app` zoom)과 무관하게 정가운데. [확인] 저장이 실패하면 창을 그대로 두고 알린다. 다른 탭·다른 곳에서 확인·취소되면 다음 확인 때 닫힌다(같은 브라우저 다른 탭은 localStorage 신호로 바로). iframe(수신함 오른쪽 작업 창) 안에선 안 돈다.