openSUSE/osem

View on GitHub
app/views/admin/schedules/_day_tab.html.haml

Summary

Maintainability
Test Coverage
- compact_grid = @program.schedule_interval < 15
- cells_per_hour = 60 / @program.schedule_interval
/ use smaller cell heights for more compact grids
- cell_height = compact_grid ? 32 : 58
- date_event_schedules = @event_schedules.select{ |e| e.start_time.to_date.eql? date }
.row
  - @rooms.each do |room|
    - non_schedulable = room.tracks.self_organized.confirmed.any? do |track|
      - !track.schedules.include?(@schedule) && (track.start_date..track.end_date).include?(date)
    .col-md-2.col-xs-6{ class: ('non_schedulable' if non_schedulable) }
      .room-name
        - room_date_event_schedules = date_event_schedules.select{ |e| e.room == room }
        = room.name
      - (@conference.start_hour * cells_per_hour..@conference.end_hour * cells_per_hour).each do |slot|
        - hour = slot / cells_per_hour
        - minutes = (@program.schedule_interval * (slot % cells_per_hour)).to_s.rjust(2, '0')
        - time = "#{hour}:#{minutes}"
        .schedule-room-slot{ id: "schedule-room-#{room.guid}-#{hour}-#{minutes}", |
                             room_id: room.id, |
                             hour: time, |
                             date: date, |
                             style: "height: #{cell_height}px"}
          .div
            = time
          - event_schedules = room_date_event_schedules.select{ |e| (e.start_time.hour.to_s + e.start_time.strftime(':%M')).eql? time }
          - if event_schedules.any?
            - event_schedule = event_schedules.first
            = render partial: 'event', locals: { event: event_schedule.event, event_schedule_id: event_schedule.id}