feat(project): compact links and add file icons
This commit is contained in:
+31
-1
@@ -6567,6 +6567,34 @@
|
||||
});
|
||||
|
||||
// ── 첨부파일 ──
|
||||
function attachmentIconHtml(a) {
|
||||
const suffix = String(a.filename || "").trim().toLowerCase().match(/\.([^.]+)$/);
|
||||
const ext = suffix ? suffix[1] : "";
|
||||
const mime = String(a.content_type || "").split(";")[0].trim().toLowerCase();
|
||||
// 확장자를 먼저 확인 — CSV/마크다운처럼 MIME 이 일반 text 인 파일도 구분한다.
|
||||
let kind;
|
||||
if (/^(png|jpe?g|gif|webp|bmp|svg|tiff?|ico|heic|heif|avif)$/.test(ext)) kind = "image";
|
||||
else if (/^(xlsx?|xlsm|xlsb|xltx?|xltm|csv|ods)$/.test(ext)) kind = "excel";
|
||||
else if (/^(pptx?|pptm|ppsx?|ppsm|potx?|potm|odp)$/.test(ext)) kind = "ppt";
|
||||
else if (/^(docx?|docm|dotx?|dotm|hwp|hwpx|odt|rtf)$/.test(ext)) kind = "document";
|
||||
else if (ext === "pdf") kind = "pdf";
|
||||
else if (/^(txt|text|md|markdown|log|json|xml|ya?ml|ini|conf)$/.test(ext)) kind = "text";
|
||||
else if (mime.startsWith("image/")) kind = "image";
|
||||
else if (/excel|spreadsheet|opendocument.spreadsheet|csv/.test(mime)) kind = "excel";
|
||||
else if (/powerpoint|presentation/.test(mime)) kind = "ppt";
|
||||
else if (/msword|wordprocessing|opendocument.text|hwp|rtf/.test(mime)) kind = "document";
|
||||
else if (mime === "application/pdf") kind = "pdf";
|
||||
else if (mime.startsWith("text/") || /json|xml/.test(mime)) kind = "text";
|
||||
else kind = "file";
|
||||
const types = {
|
||||
image: ["image", "이미지 파일"], excel: ["table_chart", "엑셀 파일"],
|
||||
text: ["article", "텍스트 파일"], ppt: ["slideshow", "PPT 파일"],
|
||||
document: ["description", "문서 파일"], pdf: ["picture_as_pdf", "PDF 파일"],
|
||||
file: ["draft", "파일"],
|
||||
};
|
||||
return '<span class="material-symbols-outlined pj-attach-icon is-' + kind +
|
||||
'" role="img" aria-label="' + types[kind][1] + '" title="' + types[kind][1] + '">' + types[kind][0] + '</span>';
|
||||
}
|
||||
function fmtSize(n) {
|
||||
if (n < 1024) return n + " B";
|
||||
if (n < 1048576) return (n / 1024).toFixed(1) + " KB";
|
||||
@@ -6586,7 +6614,8 @@
|
||||
li.className = "pj-attach-item";
|
||||
// 댓글에 붙은 파일은 "댓글" 표시 — 아래 댓글 목록에도 같은 파일이 보인다(같은 파일임을 알 수 있게).
|
||||
li.innerHTML =
|
||||
'<a href="/project/api/attachments/' + a.id + '/download">' + escapeHtml(a.filename) + "</a>" +
|
||||
'<a href="/project/api/attachments/' + a.id + '/download">' + attachmentIconHtml(a) +
|
||||
'<span class="pj-attach-name">' + escapeHtml(a.filename) + "</span></a>" +
|
||||
(a.comment_id != null ? '<span class="pj-attach-from-comment" title="댓글에 첨부한 파일">댓글</span>' : "") +
|
||||
'<span class="pj-attach-size">' + fmtSize(a.size_bytes) + "</span>" +
|
||||
(canManage && !taskReadOnly ? '<button type="button" class="pj-icon-btn pj-attach-del" data-id="' + a.id + '">×</button>' : "");
|
||||
@@ -7937,6 +7966,7 @@
|
||||
ctxSeq++;
|
||||
taskId = opts.taskId; homeProjectId = opts.projectId; onChange = opts.onChange || null;
|
||||
readOnly = !!opts.readOnly;
|
||||
el("pj-links-block").classList.toggle("is-readonly", readOnly);
|
||||
if (linkForm) linkForm.hidden = readOnly;
|
||||
if (!readOnly) loadProjects();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user