scinote-web/app/views/steps/attachments/_list.html.erb
2020-10-29 16:42:05 +01:00

51 lines
2.4 KiB
Text

<% assets = step.assets %>
<% current_order = step.current_view_state(current_user).state.dig('assets', 'sort') %>
<div class="col-xs-12">
<hr>
</div>
<div class="col-xs-12 attachments-actions">
<div class="title">
<h4>
<%= t('protocols.steps.files', count: assets.length) %>
</h4>
</div>
<div>
<div class="attachemnts-header pull-right">
<% if !(preview) && (can_manage_protocol_in_module?(@protocol) ||
can_manage_protocol_in_repository?(@protocol)) %>
<%= render partial: '/assets/marvinjs/create_marvin_sketch_button.html.erb',
locals: { element_id: step.id, element_type: 'Step', sketch_container: ".attachments[data-step-id=#{step.id}]" } %>
<%= render partial: '/assets/wopi/create_wopi_file_button.html.erb',
locals: { element_id: step.id, element_type: 'Step' } %>
<% end %>
<div class="dropdown attachments-order" data-step-id="<%= step.id %>" data-state-save-path="<%= update_view_state_step_path(step.id) %>">
<button class="btn btn-light dropdown-toggle" type="button" id="sortMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="selected-order">
<%= t("general.sort.#{current_order}_html") %>
</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="sortMenu" >
<% ['new', 'old', 'atoz', 'ztoa'].each do |sort| %>
<li>
<a data-order="<%= sort %>" class="change-order"><%= t("general.sort.#{sort}_html") %></a>
</li>
<% end %>
</ul>
</div>
<i class="fas fa-desktop attachments-view-mode" data-url="<%= update_asset_view_mode_step_path(step) %>" data-assets-view-mode="inline"></i>
<i class="fas fa-list attachments-view-mode" data-url="<%= update_asset_view_mode_step_path(step) %>" data-assets-view-mode="list"></i>
<i class="fas fa-th-large attachments-view-mode" data-url="<%= update_asset_view_mode_step_path(step) %>" data-assets-view-mode="thumbnail"></i>
</div>
</div>
</div>
<div class="col-xs-12 attachments" data-step-id="<%= step.id %>" data-order="<%= current_order %>">
<% assets.each_with_index do |asset, i| %>
<%= render partial: 'assets/asset.html.erb', locals: { asset: asset, gallery_view_id: step.id } %>
<% end %>
</div>
<hr>