Skip to content
Permalink
Browse files

improve template readability

  • Loading branch information...
zvkemp committed Apr 11, 2018
1 parent 55aa37b commit 0d68fb912dfee7b61560528abd3a43bda0b9b229
Showing with 15 additions and 11 deletions.
  1. +4 −3 app/controllers/schedules_controller.rb
  2. +1 −0 app/models/program.rb
  3. +10 −8 app/views/schedules/_carousel.html.haml
@@ -7,18 +7,18 @@ class SchedulesController < ApplicationController
before_action :load_withdrawn_event_schedules, only: [:show, :events]

def show
@event_schedules = @program.selected_event_schedules(
event_schedules = @program.selected_event_schedules(
includes: [{ event: %i[event_type speakers submitter] }]
)

unless @event_schedules
unless event_schedules
redirect_to events_conference_schedule_path(@conference.short_title)
return
end

respond_to do |format|
format.xml do
@events_xml = @event_schedules.map(&:event).group_by{ |event| event.time.to_date } if @event_schedules
@events_xml = event_schedules.map(&:event).group_by{ |event| event.time.to_date } if event_schedules
end

format.html do
@@ -41,6 +41,7 @@ def show
@selected_schedules_ids << track.selected_schedule_id
end
@selected_schedules_ids.compact!
@event_schedules_by_room_id = event_schedules.select { |s| @selected_schedules_ids.include?(s.schedule_id) }.group_by(&:room_id)
end
end
end
@@ -170,6 +170,7 @@ def languages_list
# * +True+ -> If there is any event for the given date
# * +False+ -> If there is not any event for the given date
def any_event_for_this_date?(date)
return false unless selected_schedule.present?
parsed_date = DateTime.parse("#{date} 00:00").utc
range = parsed_date..(parsed_date + 1.day)
selected_schedule.event_schedules.any? { |es| range.cover?(es.start_time) }
@@ -1,5 +1,5 @@
- intervals = hrs_per_slide * 60 / @conference.program.schedule_interval + 1
- width = 85 / intervals
- interval_count = hrs_per_slide * 60 / @conference.program.schedule_interval + 1
- width = 85 / interval_count
- carousel_number = (@conf_period / hrs_per_slide.to_f).ceil
.carousel.slide{ id: "carousel-#{ date }-#{ hrs_per_slide }", |
"data-ride" => "carousel", |
@@ -14,7 +14,7 @@
%tr
%th
- td_start_time = start_time
- (1..intervals).each do |i|
- interval_count.times do
%th.date
%span
= (td_start_time).strftime("%H:")
@@ -29,8 +29,10 @@
%td.room{ style: "height: #{ td_height(@rooms) }px;" }
.room.elipsis.break-words{ style: "-webkit-line-clamp: #{ room_lines(@rooms) }; height: #{ room_height(@rooms) }px;" }
= room.name
- event_schedules = @event_schedules.select{ |e| e.room_id == room.id && @selected_schedules_ids.include?(e.schedule_id) && (e.end_time > start_time) && (e.start_time <= (start_time + hrs_per_slide.hour)) }
- (1..intervals).each do |i|

- event_schedules = (@event_schedules_by_room_id[room.id] || []).select{ |e| (e.end_time > start_time) && (e.start_time <= (start_time + hrs_per_slide.hour)) }

- interval_count.times do |offset|
- if span > 1
- span -= 1
- else
@@ -40,12 +42,12 @@
- event_schedule = (replacement_event.start_time <= start_room_time && replacement_event.end_time > start_room_time) ? replacement_event : nil

- if event_schedule
/ There is an event, calculate the span and show it
-# There is an event, calculate the span and show it
- event_span = (event_schedule.end_time.to_i - start_room_time.to_i) / 60 / @conference.program.schedule_interval
- span = ((event_span + i - 1 ) > intervals ? intervals + 1 - i : event_span)
- span = ((event_span + offset) > interval_count ? interval_count - offset : event_span)
= render partial: 'schedule_item', locals: {event: event_schedule.event, event_schedule: event_schedule, span: span, width: width}
- else
/ if span equals 1 show an empty td
-# if span equals 1 show an empty td
%td.no-padding{ width: "#{ width }%"}
- start_room_time += @step_minutes
- start_time = start_room_time - @step_minutes

0 comments on commit 0d68fb9

Please sign in to comment.
You can’t perform that action at this time.