Do not use JS to initialize the schedule
- Only use JS for the drag&drop functionality and to the set/alter the time and rooms of the EventSchedule object. - Introduce has_many :events, through: :event_schedules association to get unscheduled event easily
This commit is contained in:
parent
71dab6b79c
commit
a394293500
12 changed files with 66 additions and 125 deletions
|
|
@ -1,13 +1,20 @@
|
|||
- date_event_schedules = @event_schedules.select{ |e| e.start_time.to_date.eql? date }
|
||||
.row
|
||||
- @rooms.each do |room|
|
||||
.col-md-2.col-xs-6
|
||||
.room-name
|
||||
- room_date_event_schedules = date_event_schedules.select{ |e| e.room == room }
|
||||
= room.name
|
||||
- (9*4..18*4).each do |slot|
|
||||
- hour = slot / 4
|
||||
- time = (15 * (slot % 4) == 0) ? '00' : 15 * (slot % 4)
|
||||
.schedule-room-slot{ id: "schedule-room-#{room.guid}-#{hour}-#{time}", |
|
||||
- minutes = (15 * (slot % 4) == 0) ? '00' : 15 * (slot % 4)
|
||||
- time = "#{hour}:#{minutes}"
|
||||
.schedule-room-slot{ id: "schedule-room-#{room.guid}-#{hour}-#{minutes}", |
|
||||
"room-guid" => room.guid, |
|
||||
hour: "#{hour}:#{time}", |
|
||||
hour: time, |
|
||||
date: date}
|
||||
= "#{hour}:#{time}"
|
||||
.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?
|
||||
= render partial: 'event', locals: { event: event_schedules.first.event }
|
||||
|
|
|
|||
13
app/views/admin/schedule/_event.html.haml
Normal file
13
app/views/admin/schedule/_event.html.haml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
- cells_length = event.event_type.length / EventType::LENGTH_STEP
|
||||
/ this height fits the room cells
|
||||
- height = (cells_length * 58) - 23
|
||||
/ subtracting the padding before calculate the number of lines
|
||||
- lines = (height - 7) / 23
|
||||
- color = event.track.try(:color).present? ? event.track.try(:color) : 'FFFFFF'
|
||||
.schedule-event{ style: "height: #{height}px; background-color: #{color}; color: #{contrast_color(color)}", |
|
||||
id: "event-#{event.guid}", |
|
||||
guid: event.guid, |
|
||||
length: cells_length }
|
||||
.schedule-event-text{ style: "-webkit-line-clamp: #{lines}; height: #{lines * 23}px;"}
|
||||
%span.schedule-event-delete-button{ onclick: "Schedule.remove(\'event-#{event.guid}\');" } X
|
||||
= event.title
|
||||
|
|
@ -17,6 +17,8 @@
|
|||
.h4
|
||||
Unscheduled events
|
||||
.unscheduled-events
|
||||
- @unscheduled_events.each do |e|
|
||||
= render partial: 'event', locals: { event: e }
|
||||
.col-md-10
|
||||
%ul.nav.nav-tabs
|
||||
- @dates.each do |date|
|
||||
|
|
@ -30,5 +32,5 @@
|
|||
|
||||
:javascript
|
||||
$(document).ready( function() {
|
||||
Schedule.loadEvents("#{@conference.short_title}", "#{@schedule_id}");
|
||||
Schedule.initialize("#{@conference.short_title}", "#{@schedule_id}");
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue