= javascript_include_tag 'events'

- cache 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|
          %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)
                  = action_icon 'trash', 'Excluir', course_event_url(@course, event), :confirm => 'Tem certeza que deseja excluir?', :method => :delete
                = h(event.description)
                = "Sem descrição" if event.description.empty?

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

  %br
