scinote-web/app/views/assets/_asset_context_menu.html.erb
2023-06-21 14:38:32 +02:00

92 lines
4.2 KiB
Text

<% if can_manage_asset?(asset) %>
<div class="dropdown asset-context-menu">
<button class="btn btn-light dropdown-toggle icon-btn" type="button" id="dropdownAssetContextMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="sn-icon sn-icon-more-hori"></i>
</button>
<ul class="dropdown-menu dropdown-menu-right"
aria-labelledby="dropdownAssetContextMenu"
data-asset-id="<%= asset.id %>"
data-toggle-view-url="<%= toggle_view_mode_path(asset) %>">
<% if editable %>
<% if wopi_enabled? && wopi_file?(asset) %>
<li>
<% edit_supported, title = wopi_file_edit_button_status(asset) %>
<%= render partial: 'assets/wopi/file_wopi_controls',
locals: {
asset: asset,
edit_supported: edit_supported,
title: title
} %>
</li>
<li role="separator" class="divider"></li>
<% elsif asset.file.metadata[:asset_type] == 'marvinjs' %>
<li>
<a class="btn btn-light marvinjs-edit-button"
data-sketch-id="<%= asset.id %>"
data-update-url="<%= marvin_js_asset_path(asset) %>"
data-sketch-start-edit-url="<%= start_editing_marvin_js_asset_path(asset) %>"
data-sketch-name="<%= asset.file.metadata[:name] %>"
data-sketch-description="<%= asset.file.metadata[:description] %>"
>
<%= image_tag 'icon_small/marvinjs.svg' %>
<%= t('assets.file_preview.edit_in_marvinjs') %>
</a>
</li>
<li role="separator" class="divider"></li>
<% elsif asset.bio_eddie? && BioEddieService.enabled?(current_user) %>
<li>
<a class="btn btn-light bio-eddie-edit-button"
data-molecule-id="<%= asset.id %>"
data-update-url="<%= bio_eddie_asset_path(asset) %>"
data-edit-url="<%= start_editing_bio_eddie_asset_path(asset) %>"
data-molecule-name="<%= asset.file.metadata[:name] || asset.file_name %>"
data-molecule-description="<%= asset.file.metadata[:description] || asset.file.download %>"
>
<%= image_tag 'icon_small/bio_eddie.png' %>
<%= t('assets.file_preview.edit_in_bio_eddie') %>
</a>
</li>
<li role="separator" class="divider"></li>
<% elsif asset.editable_image? %>
<li>
<a class="btn btn-light image-edit-button"
data-image-id="<%= asset.id %>"
data-image-name="<%= asset.file_name %>"
data-image-url="<%= asset_file_url_path(asset) %>"
data-image-quality="<%= asset.file_image_quality || 80 %>"
data-image-mime-type="<%= asset.file.content_type %>"
data-image-start-edit-url="<%= start_edit_image_path(asset) %>"
>
<span class="sn-icon sn-icon-edit"></span>
<%= t('assets.file_preview.edit_in_scinote') %>
</a>
</li>
<li>
<a class="btn btn-light file-download-link" href="<%= rails_blob_path(asset.file, disposition: 'attachment') %>" data-turbolinks="false">
<span class="sn-icon sn-icon-export"></span>
<%= t('Download') %>
</a>
</li>
<li role="separator" class="divider"></li>
<% end %>
<% end %>
<li class="divider-label"><%= t("assets.context_menu.set_view_size") %></li>
<% ['inline', 'thumbnail', 'list'].each do |view_mode| %>
<li>
<a class="change-preview-type <%= 'selected' if view_mode == asset.view_mode %>" data-preview-type="<%= view_mode %>">
<%= t("assets.context_menu.#{view_mode}_html") %>
</a>
</li>
<% end %>
<% if deletable %>
<li role="separator" class="divider"></li>
<li>
<a class="delete-asset" href="<%= asset_destroy_path(asset) %>" data-file-name="<%= asset.render_file_name %>">
<i class="sn-icon sn-icon-delete"></i>
<%= t("assets.context_menu.delete") %>
</a>
</li>
<% end %>
</ul>
</div>
<% end %>