<% content_for :js do %>
  <%= javascript_include_tag 'views/roles/form' %>
<% end %>
<%= simple_form_for @role, html: { class: "smart-form" } do |f| %>
  <%= f.error_notification %>

  <ul class="nav nav-tabs bordered">
    <li id='li-general' class="<%= 'active' if @active_permissions_tab %>">
      <a id='a-general' href="#general" data-toggle="tab">Dados gerais</a>
    </li>

    <% if @role.teacher? || @role.employee? || @role.administrator? %>
      <li id='li-users' class="<%= 'active' if @active_users_tab %>">
        <a id='a-users' href="#users" data-toggle="tab">Usuários</a>
      </li>
    <% end %>
  </ul>

  <div class="tab-content">
    <div class="tab-pane <%= 'active' if @active_permissions_tab %>" id="general">
      <%= render 'general', f: f %>
    </div>

    <% if @role.teacher? || @role.employee? || @role.administrator? %>
      <div class="tab-pane <%= 'active' if @active_users_tab %>" id="users">
        <%= render 'users', f: f %>
      </div>
    <% end %>
  </div>

  <footer>
    <%= link_to roles_path, class: "btn btn-default" do %>
      Voltar
    <% end %>

    <% if @role.persisted? %>
      <%= link_to 'Histórico', history_role_path(@role), class: 'btn btn-info' %>
    <% end %>

    <button type="submit" class="btn btn-primary">
      Salvar
    </button>
  </footer>
<% end %>
