UNC-Libraries/hy-c

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

Summary

Maintainability
Test Coverage
<%# [hyc-override] https://github.com/samvera/hyrax/tree/hyrax-v4.0.0/app/views/hyrax/base/_form_progress.html.erb %>
<%# [hyc-override] Overriding partial in hyrax gem in order to auto-select an admin set %>
<% if Flipflop.assign_admin_set? %>
  <% if f.object.model.title.blank? %>
    <% admin_set_id = AdminSetSelectService.select(f.object.model.class.to_s,
                                                   params[:affiliation],
                                                   admin_set_options)
    %>
  <% else %>
    <% if f.object.model.admin_set_id.blank? %>
      <% admin_set_id = (AdminSet.where(title: ENV['DEFAULT_ADMIN_SET']).first || AdminSet.first).id %>
    <% else %>
      <% admin_set_id = f.object.model.admin_set_id %>
    <% end %>
  <% end %>

  <% if current_user.admin? %>
    <%= f.input :admin_set_id, as: :select,
                selected: admin_set_id,
                include_blank: true,
                collection: admin_set_options,
                input_html: { class: 'form-control' } %>
  <% else %>
    <%= f.input :admin_set_id, as: :select,
                selected: admin_set_id,
                include_blank: true,
                collection: admin_set_options,
                input_html: { class: 'form-control d-none' },
                readonly: true,
                label: false %>
  <% end%>
<% end %>

<%= render 'form_in_works', f: f %>
<%= render 'form_member_of_collections', f: f %>

<% if f.object.persisted? %>
  <h2 class="h3 mt-4"><%= t("hyrax.works.form.in_this_work") %></h2>
  <%= render 'form_child_work_relationships', f: f %>
<% end %>