Fix feedback attachment links in detail view
Deploy EG-BIM QA Gateway / deploy (push) Successful in 54s
Deploy EG-BIM QA Gateway / deploy (push) Successful in 54s
This commit is contained in:
1 parent
f460986039
commit
61fd4edf97
2 files changed
+23
-1
No files matched your search
@@ -276,6 +276,8 @@ button { cursor: pointer; }
|
||||
.attachments h3 { margin: 0 0 8px; font-size: 14px; }
|
||||
.attachment-item { padding: 7px 0; color: #555; font-size: 13px; }
|
||||
.attachments a { color: var(--navy); text-decoration: underline; }
|
||||
.detail-attachment-preview-link { display: block; width: fit-content; margin-bottom: 8px; }
|
||||
.detail-attachment-preview { display: block; max-width: min(100%, 420px); max-height: 320px; border: 1px solid var(--line); border-radius: 4px; object-fit: contain; }
|
||||
.completion-notice[hidden], .completion-done-notice[hidden] { display: none; }
|
||||
.completion-notice { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 20px 22px 0; padding: 15px 17px; border: 1px solid #f0c45c; background: #fff9e8; color: #5b4500; }
|
||||
.completion-notice strong { display: block; margin-bottom: 4px; }
|
||||
|
||||
+21
-1
@@ -28,6 +28,22 @@
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeFeedbackAttachment(attachment) {
|
||||
const item = typeof attachment === 'string' ? { url: attachment } : (attachment || {});
|
||||
const url = item.url || item.download_url || item.downloadUrl || item.file_url || item.fileUrl || item.signed_url || item.signedUrl || item.presigned_url || item.presignedUrl || '';
|
||||
const safeUrl = /^(https?:\/\/|\/)/i.test(String(url)) ? String(url) : '';
|
||||
let name = item.original_file_name || item.originalFileName || item.file_name || item.fileName || item.name || '';
|
||||
if (!name && safeUrl) {
|
||||
try {
|
||||
name = decodeURIComponent(new URL(safeUrl, window.location.origin).pathname.split('/').pop() || '');
|
||||
} catch (error) {}
|
||||
}
|
||||
name = name || '첨부파일';
|
||||
const mimeType = item.content_type || item.contentType || item.mime_type || item.mimeType || '';
|
||||
const isImage = /^image\//i.test(String(mimeType)) || /\.(avif|gif|jpe?g|png|webp|bmp|svg)(?:$|[?#])/i.test(name) || /\.(avif|gif|jpe?g|png|webp|bmp|svg)(?:$|[?#])/i.test(safeUrl);
|
||||
return { name: name, url: safeUrl, isImage: isImage };
|
||||
}
|
||||
|
||||
function readJson(key, fallback) {
|
||||
try { return JSON.parse(localStorage.getItem(key) || 'null') || fallback; } catch (error) { return fallback; }
|
||||
}
|
||||
@@ -578,7 +594,11 @@
|
||||
const attachmentBox = qs('[data-detail-attachments]');
|
||||
const attachments = Array.isArray(post.attachments) ? post.attachments : [];
|
||||
if (attachmentBox) attachmentBox.innerHTML = attachments.length ? attachments.map(function (attachment) {
|
||||
return '<div class="attachment-item">📎 ' + escapeHtml(attachment.originalFileName || '첨부파일') + '</div>';
|
||||
const file = normalizeFeedbackAttachment(attachment);
|
||||
if (!file.url) return '<div class="attachment-item">📎 ' + escapeHtml(file.name) + '</div>';
|
||||
const link = '<a href="' + escapeHtml(file.url) + '" target="_blank" rel="noopener noreferrer">📎 ' + escapeHtml(file.name) + '</a>';
|
||||
const preview = file.isImage ? '<a class="detail-attachment-preview-link" href="' + escapeHtml(file.url) + '" target="_blank" rel="noopener noreferrer"><img class="detail-attachment-preview" src="' + escapeHtml(file.url) + '" alt="' + escapeHtml(file.name) + '" loading="lazy"></a>' : '';
|
||||
return '<div class="attachment-item">' + preview + link + '</div>';
|
||||
}).join('') : '<span class="help-text">첨부된 파일이 없습니다.</span>';
|
||||
const editButton = qs('#editButton');
|
||||
const deleteButton = qs('#deleteButton');
|
||||
|
||||
Reference in new issue
Block a user