UNC-Libraries/hy-c

View on GitHub
app/views/hyrax/base/_show_actions.html.erb

Summary

Maintainability
Test Coverage
<%# Override of https://github.com/samvera/hyrax/blob/v3.4.2/app/views/hyrax/base/_show_actions.html.erb %>
<%# [hyc-override] Change the delete button %>
<%# [hyc-override] Show link to parent record %>
<%# [hyc-override] Hide admin only and speciality form links from non-admins %>
<%# [hyc-override] Add aria attributes %>
<% parent_solr_docs = ParentQueryService.query_parents_for_id(presenter.solr_document.id) %>

<div class="row show-actions button-row-top-two-column">
  <div class="col-sm-6">
    <%# [hyc-override] Changes start here %>
    <% unless parent_solr_docs.blank? %>
      <% parent_solr_docs.first(1).each do |item| %>
        <%= link_to 'Back to Parent Record', url_for_document(SolrDocument.find(item["id"])), class: 'btn btn-success', data: { turbolinks: false } %>
      <% end %>
    <% end %>
    <%# [hyc-override] Changes end here %>
    <% if !workflow_restriction?(presenter) %>
      <% if presenter.show_deposit_for?(collections: @user_collections) %>
        <input type="checkbox" aria-label="Batch Documents" style="display:none" name="batch_document_ids[]" id="batch_document_<%= presenter.id %>" value="<%= presenter.id %>" class="batch_document_selector" checked="checked" />
        <%= button_tag t('hyrax.dashboard.my.action.add_to_collection'),
                      class: 'btn btn-secondary submits-batches submits-batches-add',
                      data: { toggle: "modal", target: "#collection-list-container" } %>
      <% end %>
      <% if presenter.work_featurable? %>
        <%= link_to t('.feature'), hyrax.featured_work_path(presenter, format: :json),
            data: { behavior: 'feature' },
            class: presenter.display_feature_link? ? 'btn btn-secondary' : 'btn btn-secondary collapse' %>

        <%= link_to t('.unfeature'), hyrax.featured_work_path(presenter, format: :json),
            data: { behavior: 'unfeature' },
            class: presenter.display_unfeature_link? ? 'btn btn-secondary' : 'btn btn-secondary collapse' %>
      <% end %>
    <% end %>
    <% if Hyrax.config.analytics? && Hyrax.config.analytics_provider != 'ga4' %>
      <% # turbolinks needs to be turned off or the page will use the cache and the %>
      <% # analytics graph will not show unless the page is refreshed. %>
      <%= link_to t('.analytics'), presenter.stats_path, id: 'stats', class: 'btn btn-default', data: { turbolinks: false } %>
    <% end %>
  </div>

  <div class="col-sm-6 text-right">
    <% if presenter.editor? && !workflow_restriction?(presenter) %>
      <%= link_to t('.edit'), edit_polymorphic_path([main_app, presenter]), class: 'btn btn-secondary' %>
      <% if presenter.member_count > 1 %>
          <%= link_to t("hyrax.file_manager.link_text"), polymorphic_path([main_app, :file_manager, presenter]), class: 'btn btn-secondary' %>
      <% end %>
      <% if presenter.valid_child_concerns.length > 0 %>
        <div class="btn-group">
          <%# [hyc-override] Changes start here %>
          <% if current_user&.admin? || !@presenter.workflow.is_mfa? %>
            <button type="button" class="btn btn-secondary dropdown-toggle" type="button" id="dropdown-menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              <%= t('.attach_child') %></button>
            <ul class="dropdown-menu" role="menu">
              <% presenter.valid_child_concerns.each do |concern| %>
                <%# [hyc-override] Hide admin only and speciality form links from non-admins %>
                <% next if (%w(General Dissertation Artwork).include? concern.model_name) && !current_user.admin?  %>

                <li class="dropdown-item">
                  <%= link_to "Attach #{concern.human_readable_type}", polymorphic_path([main_app, :new, :hyrax, :parent, concern.model_name.singular.to_sym], parent_id: presenter.id) %>
                </li>
              <% end %>
            </ul>
          <% elsif @presenter.workflow.is_mfa_in_review? || current_user&.admin_unit_manager?('art_mfa_manager')  %>
            <%= link_to "Attach Artwork", polymorphic_path([main_app, :new, :hyrax, :parent, 'artwork'.to_sym], parent_id: presenter.id, affiliation: 'Studio Art Program'), class: 'btn btn-default' %>
          <% end %>
          <%# [hyc-override] Changes end here %>
        </div>
      <% end %>
      <%# [hyc-override] Changes start here %>
      <% if current_user.admin? %>
        <%= link_to t('.delete'), [main_app, presenter], class: 'btn btn-danger', data: { confirm: t('.confirm_delete', work_type: presenter.human_readable_type) }, method: :delete %>
        <% if @presenter.workflow.actions.present? &&
            !@presenter.workflow.actions.select{|action| action[0] == 'withdraw'}.blank? %>
          <%= form_tag main_app.hyrax_workflow_action_path(presenter), method: :put do %>
            <%= hidden_field :workflow_action, :name, value: 'withdraw' %>
            <input class="btn btn-danger" type="submit" value="Withdraw">
          <% end %>
        <% end %>
      <% end %>
      <% if @presenter.workflow.actions.present? &&
          !@presenter.workflow.actions.select{|action| action[0] == 'request_deletion'}.blank? %>
        <button class="btn btn-danger" data-toggle="modal" data-target="#deletion-request-modal">Request Deletion</button>
      <% end %>
      <%# [hyc-override] Changes end here %>
    <% end %>
  </div>
</div>

<!-- COinS hook for Zotero -->
  <span class="Z3988" title="<%= export_as_openurl_ctx_kev(presenter) %>"></span>
<!-- Render Modals -->
  <%= render 'hyrax/dashboard/collections/form_for_select_collection', user_collections: @user_collections %>