From f6e71c0c8a968c73d126feb828a82d4a73a0125f Mon Sep 17 00:00:00 2001 From: Godwin Date: Sun, 20 Aug 2017 17:48:39 -0700 Subject: [PATCH] Fixed error loading select workshop table --- .../conference_administration_controller.rb | 2 +- app/helpers/admin_helper.rb | 12 ++- .../_select_workshop_table.html.haml | 86 +++++++++---------- 3 files changed, 54 insertions(+), 46 deletions(-) diff --git a/app/controllers/conference_administration_controller.rb b/app/controllers/conference_administration_controller.rb index 3814dc6..3801034 100644 --- a/app/controllers/conference_administration_controller.rb +++ b/app/controllers/conference_administration_controller.rb @@ -1794,7 +1794,7 @@ class ConferenceAdministrationController < ApplicationController @schedule[@day][@division][:times][@time] ||= {} @schedule[@day][@division][:times][@time][:item] ||= {} @schedule[@day][@division][:times][@time][:item][:workshops] || {} - @invalid_locations = @schedule[@day][@division.to_i][:times][@time][:item][:workshops].keys + @invalid_locations = @schedule[@day][@division][:times][@time][:item][:workshops].keys @workshops.sort { |a, b| a.title.downcase <=> b.title.downcase }.each do |workshop| @ordered_workshops[workshop.id] = workshop diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index dfbe138..b3d1507 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -130,7 +130,7 @@ module AdminHelper return :bad_match end - def get_workshop_match(workshop, day, block, location) + def get_workshop_match(workshop, day, division, time, 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 @@ -152,7 +152,15 @@ module AdminHelper end end - (((((@schedule[@day] || {})[:times] || {})[@time] || {})[:item] || {})[:workshops] || {}).each do |l, w| + @schedule ||= {} + @schedule[day] ||= {} + @schedule[day][division] ||= [] + @schedule[day][division][:times] ||= {} + @schedule[day][division][:times][time] ||= {} + @schedule[day][division][:times][time][:item] ||= {} + @schedule[day][division][:times][time][:item][:workshops] || {} + + @schedule[day][division][: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 } diff --git a/app/views/conference_administration/_select_workshop_table.html.haml b/app/views/conference_administration/_select_workshop_table.html.haml index bda683d..9ebc237 100644 --- a/app/views/conference_administration/_select_workshop_table.html.haml +++ b/app/views/conference_administration/_select_workshop_table.html.haml @@ -1,50 +1,50 @@ .host-field - %h4.inline=_'forms.labels.generic.event_location' - - if @event_location.present? - %span.plain-value - = @event_location.title - = hidden_field_tag :event_location, @location - - else - = location_select(nil, inline_label: true, small: true, invalid_locations: @invalid_locations, label: false) + %h4.inline=_'forms.labels.generic.event_location' + - if @event_location.present? + %span.plain-value + = @event_location.title + = hidden_field_tag :event_location, @location + - else + = location_select(nil, inline_label: true, small: true, invalid_locations: @invalid_locations, 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=_'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 - = date(@day, :weekday) + %h4.inline=_'forms.labels.generic.day' + %span.plain-value + = date(@day, :weekday) .host-field - %h4.inline=_'forms.labels.generic.time' - %span.plain-value - = time(@workshop_blocks[@block]['time'].to_f) + %h4.inline=_'forms.labels.generic.time' + %span.plain-value + = time(@workshop_blocks[@block]['time'].to_f) %table.workshops.admin-edit - %tr - %th.corner - %th=_'articles.workshops.headings.theme' - %th=_'articles.workshops.headings.space' - %th=_'articles.workshops.headings.needs' - %th=_'articles.workshops.headings.facilitators' - %th=_'articles.workshops.headings.interested_count' - %th=_'articles.workshops.headings.notes' - - @ordered_workshops.each do | id, workshop | - %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}") : '' - - needs = JSON.parse(workshop.needs || '[]') - %td=_!((needs.map { |x| _"workshop.options.needs.#{x}" }).join(', ').to_s.html_safe) - %td=(workshop.active_facilitators.map { |x| x.named_email }).join(', ') - %td=workshop.interested_count - %td - .text=strip_tags(workshop.notes) + %tr + %th.corner + %th=_'articles.workshops.headings.theme' + %th=_'articles.workshops.headings.space' + %th=_'articles.workshops.headings.needs' + %th=_'articles.workshops.headings.facilitators' + %th=_'articles.workshops.headings.interested_count' + %th=_'articles.workshops.headings.notes' + - @ordered_workshops.each do |id, workshop| + %tr.selectable{ class: get_workshop_match(workshop, @day, @division, @time, @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}") : '' + - needs = JSON.parse(workshop.needs || '[]') + %td=_!((needs.map { |x| _"workshop.options.needs.#{x}" }).join(', ').to_s.html_safe) + %td=(workshop.active_facilitators.map { |x| x.named_email }).join(', ') + %td=workshop.interested_count + %td + .text=strip_tags(workshop.notes) .legend - %h4 Legend - %ul - %li.good-match Good Match - %li.bad-match Poor Match - %li.selected-space Also at this time - %li.other-space Also in this space - %li.other-host Already scheduled + %h4 Legend + %ul + %li.good-match Good Match + %li.bad-match Poor Match + %li.selected-space Also at this time + %li.other-space Also in this space + %li.other-host Already scheduled