<%= stylesheet_link_tag "school_calendar_events" %>

<%= simple_form_for [@school_calendar, @school_calendar_event], html: { class: "smart-form" } do |f| %>
  <%= f.error_notification %>
  <%= render 'base_errors', f: f %>
  <%= f.input :school_calendar_id, as: :hidden %>
  <%= f.input :unity_id, as: :hidden %>
  <%= f.input :coverage, as: :hidden %>
  <input id="year" type="hidden" name="year" value="<%= @school_calendar.year %>" >

  <fieldset>
    <%case
      when @school_calendar_event.coverage_by_unity?%><%= render 'school_fields', f: f %>
      <% when @school_calendar_event.coverage_by_course?%><%= render 'course_fields', f: f %>
      <% when @school_calendar_event.coverage_by_grade?%><%= render 'grade_fields', f: f %>
      <% when @school_calendar_event.coverage_by_classroom?%><%= render 'classroom_fields', f: f %>
    <%end%>
  </fieldset>

  <footer>
    <%= link_to "Voltar", school_calendar_school_calendar_events_path, class: "btn btn-default" %>

    <% if @school_calendar_event.persisted? %>
      <%= link_to 'Histórico', history_school_calendar_school_calendar_event_path(id: @school_calendar_event, school_calendar: @school_calendar), class: 'btn btn-info' %>
    <% end %>

    <%= link_to "Salvar", nil,  class: "btn btn-primary", id: "new-school-calendar-event-button" %>
    <%= f.submit 'Salvar', class: 'btn btn-primary', id: "submit-school-calendar-event-button", :style => "display: none;"%>

  </footer>
<% end %>

<% content_for :js do %>
  <script type="text/javascript">
    <%= render 'form.js.erb' %>
  </script>
<% end %>
