noesya/osuny

View on GitHub
app/views/admin/education/teachers/edit.html.erb

Summary

Maintainability
Test Coverage
<% content_for :title, t('education.manage_programs') %>

<%= simple_form_for [:admin, @teacher], url: admin_education_teacher_path(@teacher) 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, :involvements,
                              class: button_classes,
                              data: {
                                'association-insertion-method': 'append',
                                'association-insertion-node':   '#involvements',
                              } %>

  <div id="involvements" class="mt-3">
    <% sorted_teacher_involvements = @teacher.involvements.select(&:teacher?).sort_by { |involvement| involvement.created_at || Time.zone.now } %>
    <%= f.simple_fields_for :involvements, sorted_teacher_involvements, include_id: false do |involvement_f| %>
      <%= render 'admin/education/teachers/involvement_fields', f: involvement_f, include_id: true %>
    <% end %>
  </div>

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