Update
This commit is contained in:
@@ -41,7 +41,9 @@
|
||||
<div class="card-body">
|
||||
<div class="d-flex flex-wrap gap-2 align-items-start">
|
||||
{% for att in ticket_atts %}
|
||||
{% if att.mime_type and att.mime_type.startswith('image/') %}
|
||||
{% set ext = att.filename.rsplit('.', 1)[-1].lower() if '.' in att.filename else '' %}
|
||||
{% set is_img = (att.mime_type and att.mime_type.startswith('image/')) or ext in ('png','jpg','jpeg','gif','webp','svg') %}
|
||||
{% if is_img %}
|
||||
<a href="{{ url_for('tickets.download_attachment', att_id=att.id) }}"
|
||||
target="_blank" class="comment-img-link" title="{{ att.filename }}">
|
||||
<img src="{{ url_for('tickets.download_attachment', att_id=att.id) }}"
|
||||
@@ -124,7 +126,9 @@
|
||||
{% if c_atts %}
|
||||
<div class="mt-2">
|
||||
{% for att in c_atts %}
|
||||
{% if att.mime_type and att.mime_type.startswith('image/') %}
|
||||
{% set ext = att.filename.rsplit('.', 1)[-1].lower() if '.' in att.filename else '' %}
|
||||
{% set is_img = (att.mime_type and att.mime_type.startswith('image/')) or ext in ('png','jpg','jpeg','gif','webp','svg') %}
|
||||
{% if is_img %}
|
||||
<a href="{{ url_for('tickets.download_attachment', att_id=att.id) }}"
|
||||
target="_blank" class="comment-img-link">
|
||||
<img src="{{ url_for('tickets.download_attachment', att_id=att.id) }}"
|
||||
@@ -187,9 +191,12 @@
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
const TICKET_ID = {{ ticket.id }};
|
||||
const CURRENT_UID = {{ current_user.id }};
|
||||
const IS_IT_STAFF = {{ 'true' if current_user.is_it_staff else 'false' }};
|
||||
const TICKET_ID = {{ ticket.id }};
|
||||
const CURRENT_UID = {{ current_user.id }};
|
||||
const IS_IT_STAFF = {{ 'true' if current_user.is_it_staff else 'false' }};
|
||||
const ATTACHMENT_URL = '{{ url_for("tickets.download_attachment", att_id=0) }}'.replace('/0', '/');
|
||||
const DELETE_COMMENT_URL = '{{ url_for("tickets.delete_comment", comment_id=0) }}'.replace('/0/', '/{id}/');
|
||||
const AVATAR_URL = '{{ url_for("auth.serve_avatar", filename="__name__") }}'.replace('__name__', '');
|
||||
const DELETE_URLS = {}; // populated dynamically for new comments
|
||||
let seenCommentIds = new Set([{% for c in comments %}{{ c.id }},{% endfor %}]);
|
||||
|
||||
@@ -449,26 +456,30 @@ function buildCommentEl(c) {
|
||||
? '<span style="font-size:10px;background:rgba(251,191,36,.15);color:var(--warning);padding:1px 7px;border-radius:4px;font-weight:600;">INTERNAL NOTE</span>'
|
||||
: '';
|
||||
const deleteBtn = c.can_delete
|
||||
? `<form method="POST" action="/comments/${c.id}/delete" onsubmit="return confirm('Delete this comment?');" style="margin:0;">
|
||||
? `<form method="POST" action="${DELETE_COMMENT_URL.replace('{id}', c.id)}" onsubmit="return confirm('Delete this comment?');" style="margin:0;">
|
||||
<input type="hidden" name="csrf_token" value="${document.querySelector('meta[name=csrf-token]').content}"/>
|
||||
<button type="submit" class="btn btn-sm" style="background:none;border:none;color:var(--muted);padding:2px 6px;" title="Delete comment">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</form>`
|
||||
: '';
|
||||
const IMG_EXTS = new Set(['png','jpg','jpeg','gif','webp','svg']);
|
||||
const atts = (c.attachments || []).map(a => {
|
||||
if (a.is_image) {
|
||||
return `<a href="/attachments/${a.id}" target="_blank" class="comment-img-link">
|
||||
<img src="/attachments/${a.id}" alt="${a.filename}" class="comment-img-thumb"/>
|
||||
const url = ATTACHMENT_URL + a.id;
|
||||
const ext = a.filename.includes('.') ? a.filename.split('.').pop().toLowerCase() : '';
|
||||
const isImg = a.is_image || IMG_EXTS.has(ext);
|
||||
if (isImg) {
|
||||
return `<a href="${url}" target="_blank" class="comment-img-link">
|
||||
<img src="${url}" alt="${a.filename}" class="comment-img-thumb"/>
|
||||
</a>`;
|
||||
}
|
||||
return `<a href="/attachments/${a.id}" class="btn btn-secondary btn-sm me-1 mb-1">
|
||||
return `<a href="${url}" class="btn btn-secondary btn-sm me-1 mb-1">
|
||||
<i class="bi bi-download me-1"></i>${a.filename}
|
||||
</a>`;
|
||||
}).join('');
|
||||
|
||||
const avatarInner = c.author_avatar
|
||||
? `<img src="/auth/avatar/${c.author_avatar}" alt="${c.author_init}"
|
||||
? `<img src="${AVATAR_URL}${c.author_avatar}" alt="${c.author_init}"
|
||||
style="width:28px;height:28px;object-fit:cover;display:block;border-radius:50%;"/>`
|
||||
: c.author_init;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user