Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schedule flow UI audit (#261) #195

Merged
merged 1 commit into from
Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions app/assets/javascripts/staff/program/time-slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,25 @@
}

function initTimePickers() {
$('#time_slot_start_time, #time_slot_end_time').timepicker({
timeFormat: 'HH:mm',
stepMinute: 5
$('#time_slot_start_time').timepicker({
controlType: 'select',
timeFormat: 'h:mm tt',
stepMinute: 5,
maxTime: $('#time_slot_end_time').val(),
onSelect: function(time) {
$('#time_slot_end_time').timepicker('destroy');
initTimePickers();
}
});
$('#time_slot_end_time').timepicker({
controlType: 'select',
timeFormat: 'h:mm tt',
stepMinute: 5,
minTime: $('#time_slot_start_time').val(),
onSelect: function(time) {
$('#time_slot_start_time').timepicker('destroy');
initTimePickers();
}
});
}

Expand Down
4 changes: 2 additions & 2 deletions app/decorators/staff/time_slot_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ class Staff::TimeSlotDecorator < Draper::Decorator
delegate_all

def start_time
object.start_time.try(:to_s, :time)
object.start_time.try(:to_s, :time_p)
end

def end_time
object.end_time.try(:to_s, :time)
object.end_time.try(:to_s, :time_p)
end

def session_duration
Expand Down
1 change: 1 addition & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Event < ApplicationRecord

has_many :teammates, dependent: :destroy
has_many :staff, through: :teammates, source: :user
has_many :proposals, dependent: :destroy
Expand Down
10 changes: 10 additions & 0 deletions app/models/time_slot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class TimeSlot < ApplicationRecord
scope :scheduled, -> { where.not(title: [nil, ""]).or(where.not(program_session_id: nil)) }
scope :empty, -> { where(program_session: nil, title: [nil, ""]) }

validate :end_time_later_than_start_time

validates :room_id, :conference_day, presence: true

def self.import(file)
raw_json = file.read # maybe open as well
parsed_slots = JSON.parse(raw_json)
Expand Down Expand Up @@ -95,6 +99,12 @@ def session_confirmation_notes
def session_duration
(end_time - start_time).to_i/60
end

def end_time_later_than_start_time
if session_duration <= 0
errors.add(:end_time, 'must be later than start time')
end
end
end

# == Schema Information
Expand Down
1 change: 0 additions & 1 deletion app/views/staff/rooms/destroy.js.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
$('table#organizer-rooms #room_<%= room.id %>').remove();
window.Schedule.TimeSlots.reloadTable(<%=raw time_slots.rows.to_json %>);

<% if has_missing_requirements?(room.event) %>
$('#time-slot-prereqs').removeClass('hidden');
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/time_formats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
Time::DATE_FORMATS[:month_day] = "%b %d"
Time::DATE_FORMATS[:db_just_date] = "%Y-%m-%d"
Time::DATE_FORMATS[:event_day] = "%A, %b %d"
Time::DATE_FORMATS[:time_p] = "%H:%M%p"
Time::DATE_FORMATS[:time_p] = "%l:%M %P"
7 changes: 4 additions & 3 deletions spec/factories/time_slots.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@
factory :time_slot do
conference_day 1
start_time "2014-01-31 10:41:58"
end_time "2014-01-31 10:41:58"
end_time "2014-01-31 11:41:58"
title "MyText"
description "MyText"
presenter "MyText"
event
room

factory :time_slot_with_program_session do
conference_day 1
start_time "2014-01-31 10:41:58"
end_time "2014-01-31 10:41:58"
end_time "2014-01-31 11:41:58"
event
program_session { FactoryGirl.create(:program_session_with_proposal)}
end

factory :time_slot_with_empty_program_session do
conference_day 1
start_time "2014-01-31 10:41:58"
end_time "2014-01-31 10:41:58"
end_time "2014-01-31 11:41:58"
event
program_session
end
Expand Down
12 changes: 6 additions & 6 deletions spec/features/admin/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
visit admin_users_path

within("tr#user-#{admin_user.id}") do
expect(page).to have_content admin_teammate.name
expect(page).to have_content admin_teammate.email
expect(page).to have_content admin_user.name
expect(page).to have_content admin_user.email
expect(page).to have_content admin_teammate.role
end

within("tr#user-#{organizer_user.id}") do
expect(page).to have_content organizer_teammate.name
expect(page).to have_content organizer_teammate.email
expect(page).to have_content organizer_user.name
expect(page).to have_content organizer_user.email
expect(page).to have_content organizer_teammate.role
end

within("tr#user-#{reviewer_user.id}") do
expect(page).to have_content reviewer_teammate.name
expect(page).to have_content reviewer_teammate.email
expect(page).to have_content reviewer_user.name
expect(page).to have_content reviewer_user.email
expect(page).to have_content reviewer_teammate.role
end

Expand Down