= javascript_include_tag 'events'

-# cache(course_events_path(@course.id)) do

- last_date = nil

.cmd
  = action_icon 'add', 'Adicionar evento', new_course_event_url

%h4.title= h(@course.full_name)
%h1.title Calendário

.box.div_calendario
  - if !@events.empty?
    %table
      - @events.each do |event|

        - event.revert_to(params[:version]) if (event.id == params[:id].to_i) and (params[:version])

        %tr[event]
          %td.top.aright{:width => '1%'}
            = event.time.strftime("%d&nbsp;de&nbsp;%B") #unless event.time == last_date
          %td.top{:width => '1%'}
            = event.time.strftime("%H:%M")
          %td.top
            .title=link_to h(event.title), course_event_url(@course, event)
            .description{:style => (event.id == params[:id].to_i ? '' : 'display: none')}
              %div.cmd
                = action_icon 'edit', 'Editar', edit_course_event_url(@course, event, :version => event.version)
                = action_icon 'trash', 'Excluir', course_event_url(@course, event), :confirm => 'Tem certeza que deseja excluir?', :method => :delete
              = formatted(event.description)
              = "Sem descrição" if event.description.empty?

        - last_date = event.time
  - else
    .box
      %ul
        %li.no_itens Nenhum evento

%br
