scinote-web/app/views/results/_result_asset.html.erb
2017-01-18 13:28:56 +01:00

35 lines
1.4 KiB
Text

<% if can_view_or_download_result_assets(result.my_module) %>
<% if result.asset.file.processing? %>
<span data-status='asset-loading'
data-present-url='<%= file_present_asset_path(result.asset) %>'>
<%= image_tag 'medium/processing.gif' %>
</span>
<% else %>
<% if result.asset.is_image? %>
<%= link_to download_asset_path(result.asset),
class: 'image-preview-link',
id: "modal_link#{result.asset.id}",
data: {no_turbolink: true,
description: "#{truncate(result.name, length: Constants::FILENAME_TRUNCATION_LENGTH)}"} do %>
<%= image_tag result.asset.url(:medium), data: {'preview-url': large_image_url_asset_path(result.asset)} %>
<p><%= truncate(result.asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %></p>
<% end %>
<% else %>
<%= link_to download_asset_path(result.asset), data: {no_turbolink: true} do %>
<p><%= truncate(result.asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %></p>
<% end %>
<% end %>
<% end %>
<% else %>
<% if result.asset.file.processing? %>
<span data-status='asset-loading'
data-present-url='<%= file_present_asset_path(result.asset) %>'>
<%= image_tag 'medium/processing.gif' %>
</span>
<% else %>
<%= image_tag result.asset.url(:medium) if result.asset.is_image? %>
<p><%= result.asset.file_file_name %></p>
<% end %>
<% end %>