Improved attachment preview api, introduced @canPreview().
This commit is contained in:
parent
b0597ad04d
commit
327749c29b
|
@ -143,6 +143,7 @@ class App extends Spine.Controller
|
||||||
'image/jpg': 'file-image'
|
'image/jpg': 'file-image'
|
||||||
'image/png': 'file-image'
|
'image/png': 'file-image'
|
||||||
'image/svg': 'file-image'
|
'image/svg': 'file-image'
|
||||||
|
'image/gif': 'file-image'
|
||||||
# documents
|
# documents
|
||||||
'application/pdf': 'file-pdf'
|
'application/pdf': 'file-pdf'
|
||||||
'application/msword': 'file-word' # .doc, .dot
|
'application/msword': 'file-word' # .doc, .dot
|
||||||
|
@ -173,6 +174,11 @@ class App extends Spine.Controller
|
||||||
canDownload: (contentType) ->
|
canDownload: (contentType) ->
|
||||||
contentType != 'text/html'
|
contentType != 'text/html'
|
||||||
|
|
||||||
|
canPreview: (contentType) ->
|
||||||
|
return false if _.isEmpty(contentType)
|
||||||
|
return true if contentType.match(/image\/(png|jpg|jpeg|gif)/i)
|
||||||
|
false
|
||||||
|
|
||||||
@viewPrint: (object, attributeName, attributes, table) ->
|
@viewPrint: (object, attributeName, attributes, table) ->
|
||||||
if !attributes
|
if !attributes
|
||||||
attributes = {}
|
attributes = {}
|
||||||
|
|
|
@ -64,10 +64,10 @@
|
||||||
<a class="attachment attachment--preview" title="<%- attachment.preferences['Content-Type'] %>" target="_blank" href="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>?disposition=attachment" data-type="attachment"<% if @canDownload(attachment.preferences['Content-Type']): %> download<% end %>>
|
<a class="attachment attachment--preview" title="<%- attachment.preferences['Content-Type'] %>" target="_blank" href="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>?disposition=attachment" data-type="attachment"<% if @canDownload(attachment.preferences['Content-Type']): %> download<% end %>>
|
||||||
<div class="attachment-icon">
|
<div class="attachment-icon">
|
||||||
<% if attachment.preferences && attachment.preferences['Content-Type'] && @ContentTypeIcon(attachment.preferences['Content-Type']): %>
|
<% if attachment.preferences && attachment.preferences['Content-Type'] && @ContentTypeIcon(attachment.preferences['Content-Type']): %>
|
||||||
<% if attachment.preferences['Content-Type'].match(/image\/(png|jpg|jpeg)/i): %>
|
<% if @canPreview(attachment.preferences['Content-Type']): %>
|
||||||
<img src="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>">
|
<img src="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>">
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<%- @Icon( @ContentTypeIcon(attachment.preferences['Content-Type']) ) %>
|
<%- @Icon( @ContentTypeIcon(attachment.preferences['Content-Type']) ) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<%- @Icon('file-unknown') %>
|
<%- @Icon('file-unknown') %>
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
<a class="attachment attachment--preview" title="<%- attachment.preferences['Content-Type'] %>" target="_blank" href="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>?disposition=attachment" data-type="attachment"<% if @canDownload(attachment.preferences['Content-Type']): %> download<% end %>>
|
<a class="attachment attachment--preview" title="<%- attachment.preferences['Content-Type'] %>" target="_blank" href="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>?disposition=attachment" data-type="attachment"<% if @canDownload(attachment.preferences['Content-Type']): %> download<% end %>>
|
||||||
<div class="attachment-icon">
|
<div class="attachment-icon">
|
||||||
<% if attachment.preferences && attachment.preferences['Content-Type'] && @ContentTypeIcon(attachment.preferences['Content-Type']): %>
|
<% if attachment.preferences && attachment.preferences['Content-Type'] && @ContentTypeIcon(attachment.preferences['Content-Type']): %>
|
||||||
<% if attachment.preferences['Content-Type'].match(/image\/(png|jpg|jpeg)/i): %>
|
<% if @canPreview(attachment.preferences['Content-Type']): %>
|
||||||
<img src="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>">
|
<img src="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>">
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<%- @Icon( @ContentTypeIcon(attachment.preferences['Content-Type']) ) %>
|
<%- @Icon( @ContentTypeIcon(attachment.preferences['Content-Type']) ) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<%- @Icon('file-unknown') %>
|
<%- @Icon('file-unknown') %>
|
||||||
|
|
Loading…
Reference in a new issue