Corrections in SchedulesController
- Controler file name pluralized - Load and authorization fixed and improved - Consider that save can fail in create action - Eliminate unnecessary if in update action - Ability and tests related to the schedules link in the admin sidebar fixed
This commit is contained in:
parent
2e1cd164a4
commit
29b920d746
9 changed files with 67 additions and 69 deletions
21
app/views/admin/schedules/_day_tab.html.haml
Normal file
21
app/views/admin/schedules/_day_tab.html.haml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
- 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
|
||||
- minutes = (15 * (slot % 4) == 0) ? '00' : 15 * (slot % 4)
|
||||
- time = "#{hour}:#{minutes}"
|
||||
.schedule-room-slot{ id: "schedule-room-#{room.guid}-#{hour}-#{minutes}", |
|
||||
room_id: room.id, |
|
||||
hour: time, |
|
||||
date: date}
|
||||
.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}
|
||||
14
app/views/admin/schedules/_event.html.haml
Normal file
14
app/views/admin/schedules/_event.html.haml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
- 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.id}", |
|
||||
event_id: event.id, |
|
||||
length: cells_length, |
|
||||
event_schedule_id: event_schedule_id }
|
||||
.schedule-event-text{ style: "-webkit-line-clamp: #{lines}; height: #{lines * 23}px;"}
|
||||
%span.schedule-event-delete-button{ onclick: "Schedule.remove(\'event-#{event.id}\');" } X
|
||||
= event.title
|
||||
32
app/views/admin/schedules/index.html.haml
Normal file
32
app/views/admin/schedules/index.html.haml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1 Schedules
|
||||
%p.text-muted
|
||||
The schedules for your conference
|
||||
.row
|
||||
.col-md-12
|
||||
%table.table.table-hover#event_types
|
||||
%thead
|
||||
%th Schedule
|
||||
%th Selected
|
||||
%th Actions
|
||||
%tbody
|
||||
- @schedules.each do |schedule|
|
||||
%tr
|
||||
%td
|
||||
Schedule
|
||||
= schedule.id
|
||||
%td
|
||||
= (schedule == @selected_schedule) ? 'Yes' : 'No'
|
||||
%td
|
||||
.btn-group{role: "group"}
|
||||
= link_to 'Show', admin_conference_schedule_path(@conference.short_title, schedule.id),
|
||||
method: :get, class: 'btn btn-primary'
|
||||
= link_to 'Delete', admin_conference_schedule_path(@conference.short_title, schedule.id),
|
||||
method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete Schedule #{schedule.id}?" }
|
||||
|
||||
.row
|
||||
.col-md-12.text-right
|
||||
= link_to 'Add Schedule', admin_conference_schedules_path(@conference.short_title),
|
||||
method: :post, class: 'btn btn-primary'
|
||||
36
app/views/admin/schedules/show.html.haml
Normal file
36
app/views/admin/schedules/show.html.haml
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1 Schedule
|
||||
%p.text-muted
|
||||
Create the schedules for the conference
|
||||
|
||||
.row
|
||||
.col-md-2
|
||||
Selected schedule
|
||||
= check_box_tag @conference.short_title, @schedule.id, (@schedule.id == @selected_schedule.try(:id)),
|
||||
method: :put, url: (admin_conference_schedule_path(@conference.short_title, @schedule) + '?selected_schedule='),
|
||||
class: 'switch-checkbox', data: { size: 'small',
|
||||
off_color: 'warning',
|
||||
on_text: 'Yes',
|
||||
off_text: 'No' }
|
||||
.h4
|
||||
Unscheduled events
|
||||
.unscheduled-events
|
||||
- @unscheduled_events.each do |e|
|
||||
= render partial: 'event', locals: { event: e, event_schedule_id: nil }
|
||||
.col-md-10
|
||||
%ul.nav.nav-tabs
|
||||
- @dates.each do |date|
|
||||
%li{ class: "#{ (@dates.first == date) ? 'active' : '' }"}
|
||||
%a{ href: "##{date}" }
|
||||
= date
|
||||
.tab-content
|
||||
- @dates.each do |date|
|
||||
.tab-pane{ class: "#{ (@dates.first == date) ? 'active' : '' }", id: "#{date}" }
|
||||
= render partial: 'day_tab', locals: { date: date }
|
||||
|
||||
:javascript
|
||||
$(document).ready( function() {
|
||||
Schedule.initialize("#{admin_conference_event_schedule_index_path(@conference)}", "#{@schedule.id}");
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue