Better design for room URLs

This commit is contained in:
Michael Ball 2020-07-17 10:03:07 -07:00
parent ae6581826d
commit 31dfd62fbd
4 changed files with 25 additions and 6 deletions

View file

@ -173,6 +173,24 @@ module EventsHelper
) )
end end
def join_event_link(event, current_user)
return unless event.url.present? && current_user
conference = event.conference
is_today = event.time&.today?
if current_user.roles.where(id: conference.roles).any?
# Show Pre-Event links for any memeber of the conference team.
link_to("Join Live Event #{'(Pre-Event)' unless is_today}",
event.url, target: '_blank')
elsif current_user.registered_to_event?(conference)
if is_today
link_to('Join Live Event', event.url, target: '_blank')
else
link_to('Live Event Link Coming Soon', '#')
end
end
end
private private
def active_dropdown(selection, options) def active_dropdown(selection, options)

View file

@ -31,6 +31,8 @@ class Event < ApplicationRecord
belongs_to :track belongs_to :track
belongs_to :difficulty_level belongs_to :difficulty_level
belongs_to :program belongs_to :program
belongs_to :room
delegate :url, to: :room, allow_nil: true
accepts_nested_attributes_for :event_users, allow_destroy: true accepts_nested_attributes_for :event_users, allow_destroy: true
accepts_nested_attributes_for :speakers, allow_destroy: true accepts_nested_attributes_for :speakers, allow_destroy: true

View file

@ -16,9 +16,8 @@
%br %br
%small %small
= @event.subtitle = @event.subtitle
- if @event.room&.url && @conference.user_registered?(current_user) %h3
%h3 = join_event_link(@event, current_user)
= link_to('Join Event', @event.room.url, target: '_blank')
.col-md-2 .col-md-2
%p{style: "margin-top: 20px"} %p{style: "margin-top: 20px"}
- if can?(:update, @event) && @event.require_registration? - if can?(:update, @event) && @event.require_registration?

View file

@ -17,11 +17,11 @@
%h4 %h4
- if(event.speakers.any?) - if(event.speakers.any?)
presented by #{event.speaker_names} presented by #{event.speaker_names}
- if event.room&.url && @conference.user_registered?(current_user) %h5
%p = join_event_link(event, current_user)
= link_to('Join Event', event.room.url, target: '_blank')
%p %p
= markdown(truncate(event.abstract, length: 400)) = markdown(truncate(event.abstract, length: 400))
-# TODO: More informative text or aria-label.
= link_to 'more', conference_program_proposal_path(@conference.short_title, event.id) if event.abstract.length > 400 = link_to 'more', conference_program_proposal_path(@conference.short_title, event.id) if event.abstract.length > 400
- if event_schedule.present? - if event_schedule.present?
%span.track %span.track