diff --git a/app/assets/javascripts/home_schedule.js b/app/assets/javascripts/home_schedule.js new file mode 100644 index 0000000..5dbe76f --- /dev/null +++ b/app/assets/javascripts/home_schedule.js @@ -0,0 +1,30 @@ +(function() { + var body = document.querySelector('body'); + var primaryContent = document.getElementById('primary-content'); + var eventDlg = document.getElementById('event-dlg'); + + forEachElement('.event-detail-link', function(link) { + var eventDetails = link.parentElement.querySelector('.event-details'); + var moreDetails = eventDlg.querySelector('.more-details'); + + link.addEventListener('click', function(event) { + event.preventDefault(); + eventDlg.querySelector('.event-details').innerHTML = eventDetails.innerHTML; + var href = eventDetails.getAttribute('data-href'); + if (href) { + moreDetails.setAttribute('href', href); + moreDetails.classList.remove('hidden'); + } else { + moreDetails.classList.add('hidden'); + } + window.openOverlay(eventDlg, primaryContent, body); + + var closeDlg = function(event) { + event.preventDefault(); + window.closeOverlay(eventDlg, primaryContent, body); + }; + eventDlg.querySelector('.close-btn').onclick = closeDlg; + document.getElementById('overlay').onclick = closeDlg; + }); + }); +})(); diff --git a/app/assets/stylesheets/_application.scss b/app/assets/stylesheets/_application.scss index dee5f6e..954f25d 100644 --- a/app/assets/stylesheets/_application.scss +++ b/app/assets/stylesheets/_application.scss @@ -3573,7 +3573,6 @@ html[data-lingua-franca-example="html"] { } p { - margin: 0; font-size: 1em; } @@ -3602,7 +3601,7 @@ html[data-lingua-franca-example="html"] { button { font-size: 0.9em; margin: 1em; - background-color: $colour-1; + background-color: $colour-5; vertical-align: middle; &.delete { diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 50ceda4..18a636e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -568,8 +568,6 @@ class ApplicationController < LinguaFrancaApplicationController @schedule = @schedule.sort.to_h - # return unless do_analyze - @schedule.each do | day, data | @schedule[day][:times] = data[:times].sort.to_h if do_analyze || @schedule[day][:locations].empty? diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 3436cef..a191ca7 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -1127,6 +1127,7 @@ class ConferencesController < ApplicationController @time = @workshop_blocks[@block]['time'].to_f @day = (Date.parse params[:day]) @location = params[:location] + @event_location = @location.present? && @location.to_i > 0 ? EventLocation.find(@location.to_i) : nil @workshops.sort { |a, b| a.title.downcase <=> b.title.downcase }.each do | workshop | @ordered_workshops[workshop.id] = workshop diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bb89c67..85b2c3c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1091,6 +1091,57 @@ module ApplicationHelper return :bad_match end + def get_workshop_match(workshop, day, block, location) + if workshop.event_location_id.present? && workshop.present? + if (Date.parse params[:day]).wday == workshop.block['day'] && block == workshop.block['block'].to_i + return :selected_space + end + + if location.present? && location.id == workshop.event_location_id + return :other_space + end + + # xxx + return :other_host + end + + if location.present? + needs = JSON.parse(workshop.needs || '[]').map &:to_sym + amenities = JSON.parse(location.amenities || '[]').map &:to_sym + + if (needs & amenities).length < needs.length + return :bad_match + end + end + + (((((@schedule[@day] || {})[:times] || {})[@time] || {})[:item] || {})[:workshops] || {}).each do | l, w | + if w[:workshop].id != workshop.id + f_a = w[:workshop].active_facilitators.map { | f | f.id } + f_b = workshop.active_facilitators.map { | f | f.id } + if (f_a & f_b).present? + return :bad_match + end + end + end + + # housing_data = guest.housing_data || [] + + # if housing_data['host'].present? + # if housing_data['host'] == host.id + # return space == housing_data['space'] ? :selected_space : :other_space + # end + + # return :other_host + # end + + # if space_matches?(space, guest.housing) && available_dates_match?(host, guest) + # return :good_match + # end + + # return :bad_match + return :good_match + end + def space_matches?(host_space, guest_space) return false unless host_space.present? && guest_space.present? diff --git a/app/views/application/home.html.haml b/app/views/application/home.html.haml index 98bcd85..f1705f9 100644 --- a/app/views/application/home.html.haml +++ b/app/views/application/home.html.haml @@ -5,9 +5,10 @@ = row do = columns(medium: 10, push: {medium: 1}) do %h2=_!@conference.title - = @conference.info.html_safe + = richtext @conference.info - if @conference.registration_status == :open - if @conference.workshop_schedule_published + - add_inline_script :home_schedule %h3=_'articles.workshops.headings.Schedule' = render 'conferences/admin/schedule' - else diff --git a/app/views/conferences/admin/_select_workshop_table.html.haml b/app/views/conferences/admin/_select_workshop_table.html.haml index 0038ef3..dce4b45 100644 --- a/app/views/conferences/admin/_select_workshop_table.html.haml +++ b/app/views/conferences/admin/_select_workshop_table.html.haml @@ -1,11 +1,16 @@ .host-field %h4.inline=_'forms.labels.generic.event_location' - - if @location.present? && @location.to_i > 0 + - if @event_location.present? %span.plain-value - = EventLocation.find(@location.to_i).title + = @event_location.title = hidden_field_tag :event_location, @location - else = location_select(nil, inline_label: true, small: true, invalid_locations: (((((@schedule[@day] || {})[:times] || {})[@time] || {})[:item] || {})[:workshops] || {}).keys, label: false) +- if @event_location.present? + .host-field + %h4.inline=_'articles.admin.locations.headings.amenities' + %span.plain-value + = (JSON.parse(@event_location.amenities || '[]').map { |a| _"workshop.options.needs.#{a}" }).join(', ') .host-field %h4.inline=_'forms.labels.generic.day' %span.plain-value @@ -24,7 +29,7 @@ %th=_'articles.workshops.headings.interested_count' %th=_'articles.workshops.headings.notes' - @ordered_workshops.each do | id, workshop | - %tr.selectable{data: {workshop: id}} + %tr.selectable{class: get_workshop_match(workshop, @day, @block, @event_location).to_s.gsub('_', '-'), data: {workshop: id}} %th=workshop.title %td=Workshop.all_themes.include?((workshop.theme || '').to_sym) ? (_"workshop.options.theme.#{workshop.theme}") : workshop.theme %td=workshop.space.present? ? (_"workshop.options.space.#{workshop.space}") : '' diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 5357f42..6ec68b7 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -8,4 +8,4 @@ Rails.application.config.assets.version = '1.0' # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -Rails.application.config.assets.precompile += %w( user-mailer.css map.js pen.js time.js editor.js markdown.js html2canvas.js main.js registrations.js housing.js schedule.js favicon.ico ) +Rails.application.config.assets.precompile += %w( user-mailer.css map.js pen.js time.js editor.js markdown.js html2canvas.js main.js registrations.js housing.js schedule.js home_schedule.js favicon.ico )