noesya/osuny

View on GitHub
app/views/admin/education/programs/roles/_form.html.erb

Summary

Maintainability
Test Coverage
<%
url = role.new_record?  ? admin_education_program_roles_path(@program)
                        : admin_education_program_role_path(role, { program_id: @program.id })
%>
<%= simple_form_for role, url: url do |f| %>
  <%= f.simple_fields_for :localizations, l10n do |lf| %>
    <%= f.error_notification %>
    <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

    <%= lf.hidden_field :language_id, value: current_language.id %>

    <div class="row">
      <div class="col-lg-6">
        <%= lf.input :description %>
      </div>
      <div class="col-lg-6">
        <%= osuny_label University::Person.model_name.human(count: 2) %><br>
        <%= link_to_add_association t('add'), f, :involvements, class: button_classes, data: {
              'association-insertion-method': 'append',
              'association-insertion-node':   '#involvements'
            } %>

        <div class="mt-3" id="involvements" data-sortable="inputs">
          <%= f.simple_fields_for :involvements, role.involvements.sort_by(&:position), include_id: false do |involvement_f| %>
            <%= render 'admin/education/programs/roles/involvement_fields', f: involvement_f, include_id: true %>
          <% end %>
        </div>
      </div>
    </div>

    <% content_for :action_bar_right do %>
      <%= submit f %>
    <% end %>
  <% end %>
<% end %>