noesya/osuny

View on GitHub
app/views/admin/university/people/show/_roles.html.erb

Summary

Maintainability
Test Coverage
<% if involvements.total_count > 0 %>
  <%= osuny_panel t('university.person.administrator_roles'),
            subtitle: "#{involvements.total_count} #{t('university.person.administrator_roles').downcase}" do %>
    <div class="table-responsive">
      <table class="<%= table_classes %>">
        <thead>
          <tr>
            <th><%= University::Role.model_name.human %></th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          <% involvements.each do |involvement| %>
            <%
            role = involvement.target
            role_l10n = role.best_localization_for(current_language)
            role_target = role.target
            %>
            <tr>
              <td>
                <%= role.to_s_in(current_language) %>
                <% if role_target.present? %>
                  <br>
                  <small>
                    <%= role_target.class.model_name.human %> :
                    <%= osuny_link_localized role_target, [:admin, role_target] %>
                  </small>
                <% end %>
              </td>
              <td class="text-end">
                <%= link_to t('remove'),
                            [:admin, role_target, :role_person, { role_id: role.id, id: involvement.id }],
                            method: :delete,
                            data: { confirm: t('please_confirm') },
                            class: button_classes_danger if can?(:destroy, involvement) %>
              </td>
            </tr>
          <% end %>
        </tbody>
      </table>
    </div>
    <%= paginate involvements, param_name: :roles_page %>
  <% end %>
<% end %>