Improved scheduler
This commit is contained in:
parent
c8661285c7
commit
77bdf2a7bf
30
app/assets/javascripts/home_schedule.js
Normal file
30
app/assets/javascripts/home_schedule.js
Normal file
@ -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;
|
||||
});
|
||||
});
|
||||
})();
|
@ -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 {
|
||||
|
@ -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?
|
||||
|
@ -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
|
||||
|
@ -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?
|
||||
|
||||
|
@ -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
|
||||
|
@ -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}") : ''
|
||||
|
@ -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 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user