From ad66cd9c1fe8d21401b4fb240c10aa7a27dd2504 Mon Sep 17 00:00:00 2001 From: Mantas Date: Mon, 30 Nov 2020 18:30:56 +0200 Subject: [PATCH] Fixes #3309 - No icon / thumbnail for attached files when added via API --- .../javascripts/app/lib/mixins/view_helpers.coffee | 4 ++++ .../javascripts/app/views/generic/attachments.jst.eco | 4 ++-- .../ticket_zoom/sidebar_article_attachment.jst.eco | 11 ++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/app/lib/mixins/view_helpers.coffee b/app/assets/javascripts/app/lib/mixins/view_helpers.coffee index 2d41d48e7..64686fd3c 100644 --- a/app/assets/javascripts/app/lib/mixins/view_helpers.coffee +++ b/app/assets/javascripts/app/lib/mixins/view_helpers.coffee @@ -155,6 +155,10 @@ App.ViewHelpers = return marked(string) App.i18n.translateContent(string) + ContentOrMimeType: (attachment) -> + types = ['Content-Type', 'content_type', 'Mime-Type', 'mime_type'] + _.values(_.pick(attachment?.preferences, types))[0] + ContentTypeIcon: (contentType) -> contentType = App.Utils.contentTypeCleanup(contentType) icons = diff --git a/app/assets/javascripts/app/views/generic/attachments.jst.eco b/app/assets/javascripts/app/views/generic/attachments.jst.eco index b1cc3907a..9f00bb4a7 100644 --- a/app/assets/javascripts/app/views/generic/attachments.jst.eco +++ b/app/assets/javascripts/app/views/generic/attachments.jst.eco @@ -9,7 +9,7 @@
<%- @humanFileSize(attachment.size) %>
<% else: %> - <% content_type = attachment.preferences['Content-Type'] || attachment.preferences['content_type'] %> + <% content_type = @ContentOrMimeType(attachment) %> download<% else: %>target="_blank"<% end %>>
<% if attachment.preferences && content_type && @ContentTypeIcon(content_type): %> @@ -28,4 +28,4 @@ <% end %> <% end %>
-<% end %> \ No newline at end of file +<% end %> diff --git a/app/assets/javascripts/app/views/ticket_zoom/sidebar_article_attachment.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/sidebar_article_attachment.jst.eco index 7a0ba5748..b8bf35a33 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/sidebar_article_attachment.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/sidebar_article_attachment.jst.eco @@ -1,13 +1,14 @@
<%- @humanTime(@article.created_at) %>
<% for attachment in @article.attachments: %> -
download<% end %>> + <% content_type = @ContentOrMimeType(attachment) %> + download<% end %>> \ No newline at end of file +