scinote-web/app/views/steps/_form_assets.html.erb

56 lines
2.3 KiB
Plaintext
Raw Normal View History

2016-02-12 23:52:43 +08:00
<div class="panel panel-default panel-step-attachment">
<div class="panel-heading">
<span class="glyphicon glyphicon-file"></span>
2016-07-21 19:11:15 +08:00
<%= t("protocols.steps.new.asset_panel_title") %>
2016-02-12 23:52:43 +08:00
<div class="pull-right">
2016-10-02 00:47:05 +08:00
<% unless ff.object.file.exists? && ff.object.locked? %>
<%= ff.remove_nested_fields_link do %>
<span class="glyphicon glyphicon-remove"></span>
<% end %>
2016-02-12 23:52:43 +08:00
<% end %>
</div>
</div>
<div class="panel-body">
<% if ff.object.file.exists? %>
<% if @protocol.in_module? && can_view_or_download_step_assets(@protocol) || @protocol.in_repository? && can_read_protocol_in_repository?(@protocol) %>
<% if ff.object.is_image? %>
<%= link_to download_asset_path(ff.object),
class: 'image-preview-link',
id: "modal_link#{ff.object.id}",
data: {no_turbolink: true, id: true, status: "asset-present",
description: "#{step.position + 1}. #{truncate(step.name, length: Constants::FILENAME_TRUNCATION_LENGTH)}"} do %>
<% if ff.object.is_image? %>
<%= image_tag ff.object.url(:medium), data: {'preview-url': large_image_url_asset_path(ff.object)} %>
<p><%= truncate(ff.object.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %></p>
<% else %>
<p>
<%= file_extension_icon(ff.object) %>
<%= ff.object.file_file_name %>
</p>
<% end %>
<% end %>
<% else %>
<%= link_to download_asset_path(ff.object), data: {no_turbolink: true} do %>
<% if ff.object.is_image? %>
<%= image_tag ff.object.url(:medium) %>
<p><%= truncate(ff.object.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %></p>
<% else %>
<p>
<%= file_extension_icon(ff.object) %>
<%= ff.object.file_file_name %>
</p>
<% end %>
<% end %>
<% end %>
2016-02-12 23:52:43 +08:00
<% else %>
<%= image_tag image_tag ff.object.url(:medium) if ff.object.is_image? %>
<p><%= ff.object.file_file_name %></p>
2016-02-12 23:52:43 +08:00
<% end %>
<% else %>
<%= ff.file_field :file %>
2017-03-13 20:20:49 +08:00
<% end %>
2016-02-12 23:52:43 +08:00
</div>
2016-10-02 00:47:05 +08:00
</div>