noesya/osuny

View on GitHub
app/views/admin/administration/alumni/cohorts/edit.html.erb

Summary

Maintainability
Test Coverage
<% content_for :title, @alumnus.to_s_in(current_language) %>

<%= simple_form_for [:admin, @alumnus], url: cohorts_admin_administration_alumnus_path(@alumnus) do |f| %>
  <%= f.error_notification %>
  <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

  <%= link_to_add_association t('add'), f, :cohorts,
                              class: button_classes,
                              data: {
                                'association-insertion-method': 'append',
                                'association-insertion-node':   '#cohorts',
                              } %>

  <div id="cohorts" class="mt-3">
    <%= f.simple_fields_for :cohorts, @alumnus.cohorts.sort_by { |c| [c.year ? 0 : 1, c.year] }.reverse, include_id: false do |cohort_f| %>
      <%= render 'admin/administration/alumni/cohorts/cohort_fields', f: cohort_f, include_id: true %>
    <% end %>
  </div>
  
  <% content_for :action_bar_right do %>
    <%= submit f %>
  <% end %>
<% end %>