From 22375e73e0f24d73aa3aea03bc12f7c9d5ea7367 Mon Sep 17 00:00:00 2001 From: Godwin Date: Tue, 16 Aug 2016 17:57:04 -0700 Subject: [PATCH] Fixed companions heading, time_select bug, and emails on comments --- app/assets/javascripts/schedule.js | 13 ++++++++++-- app/assets/stylesheets/_application.scss | 21 +++++++++++++------ app/controllers/application_controller.rb | 1 + app/controllers/conferences_controller.rb | 12 +++++++---- app/helpers/application_helper.rb | 2 +- app/views/conferences/admin/_events.html.haml | 2 +- app/views/conferences/admin/_meals.html.haml | 2 +- .../conferences/admin/_schedule.html.haml | 7 ++++--- .../admin/_select_guest_table.html.haml | 2 +- .../admin/_workshop_times.html.haml | 2 +- 10 files changed, 44 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/schedule.js b/app/assets/javascripts/schedule.js index 5dbe76f..16b6ceb 100644 --- a/app/assets/javascripts/schedule.js +++ b/app/assets/javascripts/schedule.js @@ -1,5 +1,14 @@ (function() { - var body = document.querySelector('body'); + function initSchedule() { + forEachElement('table.schedule td.workshop.empty', function(block) { + block.addEventListener('click', function(event) { + console.log('clicked'); + }); + }); + } + initSchedule(); + + /*var body = document.querySelector('body'); var primaryContent = document.getElementById('primary-content'); var eventDlg = document.getElementById('event-dlg'); @@ -26,5 +35,5 @@ 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 09c56fc..625e6a4 100644 --- a/app/assets/stylesheets/_application.scss +++ b/app/assets/stylesheets/_application.scss @@ -1913,27 +1913,27 @@ table.schedule { width: 100%; margin: 0 0 1em; - &.locations-1 td.workshop { + &.locations-1 td.workshop.filled { width: 100%; } - &.locations-2 td.workshop { + &.locations-2 td.workshop.filled { width: 50%; } - &.locations-3 td.workshop { + &.locations-3 td.workshop.filled { width: 33.333%; } - &.locations-4 td.workshop { + &.locations-4 td.workshop.filled { width: 25%; } - &.locations-5 td.workshop { + &.locations-5 td.workshop.filled { width: 20%; } - &.locations-6 td.workshop { + &.locations-6 td.workshop.filled { width: 16.66667%; } @@ -1953,6 +1953,15 @@ table.schedule { &.filled { background-color: lighten($colour-1, 25%); } + + &.open { + cursor: pointer; + white-space: nowrap; + + &:hover { + background-color: lighten($colour-1, 25%); + } + } } &.event { diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1f475e2..4f9c04f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -547,6 +547,7 @@ class ApplicationController < LinguaFrancaApplicationController end last_event = time end + @schedule[day][:num_locations] = data[:locations].size end @schedule.deep_dup.each do | day, data | diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 2565ce0..0a607ed 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -1281,15 +1281,19 @@ class ConferencesController < ApplicationController comment = Comment.find_by!(id: params[:comment_id].to_i, model_type: :workshops, model_id: workshop.id) new_comment = comment.add_comment(current_user, params[:reply]) - UserMailer.send_mail :workshop_comment, comment.user.locale do - [ workshop, new_comment, comment.user ] + unless comment.user.id == current_user.id + UserMailer.send_mail :workshop_comment, comment.user.locale do + [ workshop, new_comment, comment.user ] + end end elsif params[:button] = 'add_comment' new_comment = workshop.add_comment(current_user, params[:comment]) workshop.active_facilitators.each do | u | - UserMailer.send_mail :workshop_comment, u.locale do - [ workshop, new_comment, u ] + unless u.id == current_user.id + UserMailer.send_mail :workshop_comment, u.locale do + [ workshop, new_comment, u ] + end end end else diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3c69c33..1ce03fe 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -777,7 +777,7 @@ module ApplicationHelper selectfield :day, value, conference_days_options_list(:during, nil, args[:format]), args end - def time_select(value = nil, args = {}, start_time = 8, end_time = 23.5, step = 0.5) + def hour_select(value = nil, args = {}, start_time = 8, end_time = 23.5, step = 0.5) time = start_time times = [] while time <= end_time diff --git a/app/views/conferences/admin/_events.html.haml b/app/views/conferences/admin/_events.html.haml index 3b56457..4ca747d 100644 --- a/app/views/conferences/admin/_events.html.haml +++ b/app/views/conferences/admin/_events.html.haml @@ -31,7 +31,7 @@ .flex-inputs = location_select @event.event_location_id, small: true, stretch: true = day_select @day, small: true, format: :weekday - = time_select @time, small: true + = hour_select @time, small: true = length_select @length, small: true - I18n.backend.enabled_locales.each do | locale | - if locale.to_s != @event.locale.to_s diff --git a/app/views/conferences/admin/_meals.html.haml b/app/views/conferences/admin/_meals.html.haml index 34f74dc..4684867 100644 --- a/app/views/conferences/admin/_meals.html.haml +++ b/app/views/conferences/admin/_meals.html.haml @@ -25,7 +25,7 @@ .flex-inputs = location_select nil, small: true, stretch: true = day_select nil, small: true, format: :weekday - = time_select nil, small: true + = hour_select nil, small: true = textfield :title, nil, required: true, big: true, help: 'articles.admin.locations.paragraphs.meal_title' = textfield :info, nil, help: 'articles.admin.locations.paragraphs.meal_info' .actions.next-prev diff --git a/app/views/conferences/admin/_schedule.html.haml b/app/views/conferences/admin/_schedule.html.haml index a078ba3..9908e51 100644 --- a/app/views/conferences/admin/_schedule.html.haml +++ b/app/views/conferences/admin/_schedule.html.haml @@ -1,3 +1,4 @@ +- add_inline_script :schedule - conference = @this_conference || @conference - if conference.event_locations.blank? && @entire_page .warning-info=_'articles.admin.schedule.no_locations_warning' @@ -14,7 +15,7 @@ #schedule-preview - @schedule.each do | day, data | %h4=date(day, :weekday) - %table.schedule{class: [data[:locations].present? ? 'has-locations' : 'no-locations', "locations-#{data[:locations].size}"]} + %table.schedule{class: [data[:locations].present? ? 'has-locations' : 'no-locations', "locations-#{data[:num_locations]}"]} - if data[:locations].present? %thead %tr @@ -35,7 +36,7 @@ - status = time_data[:item][:workshops][id][:status] - else - workshop = status = nil - %td{class: [time_data[:type], workshop.present? ? :filled : nil], rowspan: rowspan} + %td{class: [time_data[:type], workshop.present? ? :filled : :open], rowspan: rowspan, data: workshop.present? ? nil : { block: (time_data[:item][:block] + 1), day: day }} - if workshop.present? && workshop.event_location.present? = link_to off_screen(workshop.title), view_workshop_path(@conference.slug, workshop.id), class: 'event-detail-link' %template.event-details{data: { href: view_workshop_path(@conference.slug, workshop.id) }} @@ -60,7 +61,7 @@ - elsif @can_edit .title="Block #{time_data[:item][:block] + 1}" - else - %td{class: time_data[:type], rowspan: rowspan, colspan: data[:locations].present? ? data[:locations].size : 1} + %td{class: [time_data[:type], :open], rowspan: rowspan, colspan: data[:locations].present? ? data[:locations].size : 1, data: { block: (time_data[:item][:block] + 1), day: day }} - if @can_edit .title="Block #{time_data[:item][:block] + 1}" %td.status{rowspan: rowspan} diff --git a/app/views/conferences/admin/_select_guest_table.html.haml b/app/views/conferences/admin/_select_guest_table.html.haml index adc8097..45dd1b7 100644 --- a/app/views/conferences/admin/_select_guest_table.html.haml +++ b/app/views/conferences/admin/_select_guest_table.html.haml @@ -19,7 +19,7 @@ %th=_'forms.labels.generic.city' %th=_'forms.labels.generic.housing' %th=_'articles.admin.housing.headings.arrival_departure' - %th=_'forms.labels.generic.companion' + %th=_'articles.conference_registration.headings.companion' %th=_'forms.labels.generic.food' %th=_'forms.labels.generic.allergies' %th=_'forms.labels.generic.other' diff --git a/app/views/conferences/admin/_workshop_times.html.haml b/app/views/conferences/admin/_workshop_times.html.haml index ea185ab..d4f440b 100644 --- a/app/views/conferences/admin/_workshop_times.html.haml +++ b/app/views/conferences/admin/_workshop_times.html.haml @@ -9,7 +9,7 @@ - is_new = info['time'].blank? = form_tag administration_update_path(@this_conference.slug, :workshop_times), class: ['table-tr', is_new ? 'new' : 'saved'] do .table-th.center.big= is_new ? '' : (block + 1) - .table-td=time_select info['time'], small: true, label: false + .table-td=hour_select info['time'], small: true, label: false .table-td=length_select info['length'], {small: true, label: false}, 0.5, 2 .table-td=checkboxes :days, @block_days, info['days'].map(&:to_i), 'date.day_names', vertical: true, small: true .table-td.form