UNC-Libraries/hy-c

View on GitHub
app/views/hyrax/file_sets/_actions.html.erb

Summary

Maintainability
Test Coverage
<%# [hyc-override] https://github.com/samvera/hyrax/tree/hyrax-v4.0.0/app/views/hyrax/file_sets/_actions.html.erb %>
<% if (can?(:download, file_set.id) || can?(:destroy, file_set.id) || can?(:edit, file_set.id)) && !workflow_restriction?(@parent) %>
  <% if can?(:download, file_set.id) && !(can?(:edit, file_set.id) || can?(:destroy, file_set.id)) %>
  <%= link_to t('.download'),
              hyrax.download_path(file_set),
              class: 'btn btn-secondary btn-sm',
              title: t('.download_title', file_set: file_set),
              target: "_blank",
              id: "file_download",
              data: { label: file_set.id, work_id: @presenter.id, collection_ids: @presenter.member_of_collection_ids } %>
  <% else %>
  <div class="btn-group">
    <button class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button" id="dropdownMenu_<%= file_set.id %>" aria-haspopup="true" aria-expanded="false">
      <span class="sr-only"><%= t('.press_to') %> </span>
      <%= t('.header') %>
    </button>

    <ul role="menu" class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenu_<%= file_set.id %>">
    <% if can?(:edit, file_set.id) %>
      <li class="dropdown-item" role="menuitem" tabindex="-1">
        <%= link_to t('.edit'), edit_polymorphic_path([main_app, file_set]),
          { title: t('.edit_title', file_set: file_set) } %>
      </li>

      <li class="dropdown-item" role="menuitem" tabindex="-1">
        <%= link_to t('.versions'),  edit_polymorphic_path([main_app, file_set], anchor: 'versioning_display'),
          { title: t('.versions_title') } %>
      </li>
    <% end %>

    <%# [hyc-override] only admins may delete filesets %>
    <% if current_ability.admin? %>
      <li class="dropdown-item" role="menuitem" tabindex="-1">
        <%= link_to t('.delete'), polymorphic_path([main_app, file_set]),
          method: :delete, title: t('.delete_title', file_set: file_set),
          data: { confirm: t('.delete_confirm', file_set: file_set, application_name: application_name) } %>
      </li>
    <% end %>

    <% if can?(:download, file_set.id) %>
      <li class="dropdown-item" role="menuitem" tabindex="-1">
        <%= link_to t('.download'),
                    hyrax.download_path(file_set),
                    title: t('.download_title', file_set: file_set),
                    target: "_blank",
                    id: "file_download",
                    class: "download",
                    data: { label: file_set.id, work_id: @presenter.id, collection_ids: @presenter.member_of_collection_ids } %>
      </li>
    <% end %>

    </ul>
  </div>
  <% end %>
<% end %>