From 6b186c074d29a9b37047d53e61dcf0cfbfcb8edc Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Mon, 19 Apr 2021 21:52:42 -0700 Subject: [PATCH 01/36] Add FullCalendar module --- .gitignore | 3 +++ package.json | 5 ++++ yarn.lock | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 package.json create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore index c65dc0b1..fcdf9332 100644 --- a/.gitignore +++ b/.gitignore @@ -121,3 +121,6 @@ build-iPhoneSimulator/ # Used by RuboCop. Remote config files pulled in from inherit_from directive. .rubocop-https?--* + +# Ignore Javascript package binaries +/node_modules diff --git a/package.json b/package.json new file mode 100644 index 00000000..7a1501b9 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@fullcalendar/resource-timegrid": "^5.6.0" + } +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 00000000..500a76fc --- /dev/null +++ b/yarn.lock @@ -0,0 +1,72 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@fullcalendar/common@~5.6.0": + version "5.6.0" + resolved "https://registry.yarnpkg.com/@fullcalendar/common/-/common-5.6.0.tgz#27206084df07fbab33a67478b0d9b05542b09b79" + integrity sha512-4i4kZDVpRvfdKoJHRljDHsoYu466Odor9FhekP+67dIUoNnXSDTnQRmGfURwiF4RwaTsdWKe2+B7gors9G7zZA== + dependencies: + tslib "^2.0.3" + +"@fullcalendar/daygrid@~5.6.0": + version "5.6.0" + resolved "https://registry.yarnpkg.com/@fullcalendar/daygrid/-/daygrid-5.6.0.tgz#705508a7e7c5d560d01877485283f370c3c70780" + integrity sha512-UaNn6/vKQ3zI4/sDhrMACkIHOSZb/MA0JGlvvw3OTYFULqE5TISuYYnDbo9S1Wdz3AbTBvCzYy5Qk1vZQFsGwg== + dependencies: + "@fullcalendar/common" "~5.6.0" + tslib "^2.0.3" + +"@fullcalendar/premium-common@~5.6.0": + version "5.6.0" + resolved "https://registry.yarnpkg.com/@fullcalendar/premium-common/-/premium-common-5.6.0.tgz#d8dba80dbf09a664184d061928d1ad9ace079238" + integrity sha512-AtcoKphdGasBHNlN9DD7Kxc/7EmCUpIRu7JVRJYnrm4cR8rM3gCUCMMoPt8pyEfy4P/GN/4wGko54kgPkLzUTg== + dependencies: + "@fullcalendar/common" "~5.6.0" + tslib "^2.0.3" + +"@fullcalendar/resource-common@~5.6.0": + version "5.6.0" + resolved "https://registry.yarnpkg.com/@fullcalendar/resource-common/-/resource-common-5.6.0.tgz#e9f5688f366ea4ec10e7756485a2ab25d957513c" + integrity sha512-9FTGQcUO+ER6U44Tj32c+pSvsJ+5CrGs1RDxRyei8UIvUwY6SxQySgdAozW3yxwozEoc5TZ7xLrlLw7vKAwN6w== + dependencies: + "@fullcalendar/common" "~5.6.0" + "@fullcalendar/premium-common" "~5.6.0" + tslib "^2.0.3" + +"@fullcalendar/resource-daygrid@~5.6.0": + version "5.6.0" + resolved "https://registry.yarnpkg.com/@fullcalendar/resource-daygrid/-/resource-daygrid-5.6.0.tgz#537468cdc3910557586fa0d335bcd1bd7b5bdc77" + integrity sha512-KWV61gxtgFoaFTPi6b/MP/FaROMtu8c2ijzznMY5VPjQzjU5CSaWLpPht1T2ZOije3QTiDZ8Gx4M4yLFKMHCAg== + dependencies: + "@fullcalendar/common" "~5.6.0" + "@fullcalendar/daygrid" "~5.6.0" + "@fullcalendar/premium-common" "~5.6.0" + "@fullcalendar/resource-common" "~5.6.0" + tslib "^2.0.3" + +"@fullcalendar/resource-timegrid@^5.6.0": + version "5.6.0" + resolved "https://registry.yarnpkg.com/@fullcalendar/resource-timegrid/-/resource-timegrid-5.6.0.tgz#5461026d085f64297d7507980a7ed069c29002a7" + integrity sha512-BAiSTeuL8P0YwG2o6roavDP2dlA5cXFrxcYhx4qvEyqxscmGunI5NnxhmXafpnWO60PgvwHO++EoJvAsR3WSSg== + dependencies: + "@fullcalendar/common" "~5.6.0" + "@fullcalendar/premium-common" "~5.6.0" + "@fullcalendar/resource-common" "~5.6.0" + "@fullcalendar/resource-daygrid" "~5.6.0" + "@fullcalendar/timegrid" "~5.6.0" + tslib "^2.0.3" + +"@fullcalendar/timegrid@~5.6.0": + version "5.6.0" + resolved "https://registry.yarnpkg.com/@fullcalendar/timegrid/-/timegrid-5.6.0.tgz#0e489d60f224042211e688d3273154964aab6b54" + integrity sha512-NG55pzPvrzZEuVq+/Vn1ZbyKARVjsE6PzhiOHvJuyt3gzVPeWjXGUWjDN3BSDZ8p/4dthbF6H9mCPia977aV1g== + dependencies: + "@fullcalendar/common" "~5.6.0" + "@fullcalendar/daygrid" "~5.6.0" + tslib "^2.0.3" + +tslib@^2.0.3: + version "2.2.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c" + integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w== From 82ac50786cba2b2e98d402ac42053c96796dc76c Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sat, 24 Apr 2021 18:54:58 -0700 Subject: [PATCH 02/36] Create route for vertical schedule and test confirming it works --- config/routes.rb | 1 + spec/features/conference_schedule.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 spec/features/conference_schedule.rb diff --git a/config/routes.rb b/config/routes.rb index e2332ce2..740542c8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -201,6 +201,7 @@ Osem::Application.routes.draw do member do get :events get :happening_now + get :vertical_schedule end end end diff --git a/spec/features/conference_schedule.rb b/spec/features/conference_schedule.rb new file mode 100644 index 00000000..da682839 --- /dev/null +++ b/spec/features/conference_schedule.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +feature Schedule do + let!(:conference) { create(:conference) } + let!(:program) { conference.program } + + context 'as a conference participant' do + scenario 'who visits the schedule page' do + before(:each) do + visit vertical_schedule_conference_schedule_path + end + end + end +end \ No newline at end of file From 147b7f49398e187657267d442a98cf3278ebeb12 Mon Sep 17 00:00:00 2001 From: Ziyi Date: Sat, 24 Apr 2021 19:21:07 -0700 Subject: [PATCH 03/36] FullCalendar controller init, FullCalendarFormatter service --- app/controllers/schedules_controller.rb | 32 +++++++++++++++++++ app/services/full_calendar_formatter.rb | 0 ...chedule.rb => conference_schedule_spec.rb} | 0 3 files changed, 32 insertions(+) create mode 100644 app/services/full_calendar_formatter.rb rename spec/features/{conference_schedule.rb => conference_schedule_spec.rb} (100%) diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb index bdefb939..1671fb8f 100644 --- a/app/controllers/schedules_controller.rb +++ b/app/controllers/schedules_controller.rb @@ -75,9 +75,41 @@ class SchedulesController < ApplicationController respond_to do |format| format.html format.json { render json: @events_schedules.to_json(root: false, include: :event) } + end end + def vertical_schedule + @event_schedules = @program.selected_event_schedules( + includes: [{ event: %i[event_id title speaker] }] + ) + + respond_to do |format| + format.xml do + @events_xml = event_schedules.map(&:event).group_by{ |event| event.time.to_date } if event_schedules + end + + format.ics do + cal = Icalendar::Calendar.new + cal = icalendar_proposals(cal, event_schedules.map(&:event), @conference) + cal.publish + render inline: cal.to_ical + end + + format.html do + @rooms = @conference.venue.rooms if @conference.venue + @dates = @conference.start_date..@conference.end_date + + # Ids of the @event_schedules of confrmed self_organized tracks along with the selected_schedule_id + @selected_schedules_ids = [@conference.program.selected_schedule_id] + @conference.program.tracks.self_organized.confirmed.each do |track| + @selected_schedules_ids << track.selected_schedule_id + end + @selected_schedules_ids.compact! + @event_schedules_by_room_id = event_schedules.select { |s| @selected_schedules_ids.include?(s.schedule_id) }.group_by(&:room_id) + end + end + def app @qr_code = RQRCode::QRCode.new(conference_schedule_url).as_svg(offset: 20, color: '000', shape_rendering: 'crispEdges', module_size: 11) end diff --git a/app/services/full_calendar_formatter.rb b/app/services/full_calendar_formatter.rb new file mode 100644 index 00000000..e69de29b diff --git a/spec/features/conference_schedule.rb b/spec/features/conference_schedule_spec.rb similarity index 100% rename from spec/features/conference_schedule.rb rename to spec/features/conference_schedule_spec.rb From 54d7c31caced498f8345d8015e5c4453047279d8 Mon Sep 17 00:00:00 2001 From: Ziyi Date: Sat, 24 Apr 2021 19:30:52 -0700 Subject: [PATCH 04/36] FullCalendarFormatter spec init --- app/services/full_calendar_formatter.rb | 3 +++ spec/features/conference_schedule_spec.rb | 4 ++-- spec/services/full_calendar_formatter_spec.rb | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 spec/services/full_calendar_formatter_spec.rb diff --git a/app/services/full_calendar_formatter.rb b/app/services/full_calendar_formatter.rb index e69de29b..91cd3b25 100644 --- a/app/services/full_calendar_formatter.rb +++ b/app/services/full_calendar_formatter.rb @@ -0,0 +1,3 @@ +class FullCalendarFormatter + def rooms_to_resources(rooms); end +end diff --git a/spec/features/conference_schedule_spec.rb b/spec/features/conference_schedule_spec.rb index da682839..fae6fbeb 100644 --- a/spec/features/conference_schedule_spec.rb +++ b/spec/features/conference_schedule_spec.rb @@ -5,10 +5,10 @@ feature Schedule do let!(:program) { conference.program } context 'as a conference participant' do - scenario 'who visits the schedule page' do + context 'who visits the schedule page' do before(:each) do visit vertical_schedule_conference_schedule_path end end end -end \ No newline at end of file +end diff --git a/spec/services/full_calendar_formatter_spec.rb b/spec/services/full_calendar_formatter_spec.rb new file mode 100644 index 00000000..2cf607e9 --- /dev/null +++ b/spec/services/full_calendar_formatter_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe FullCalendarFormatter do + let!(:room0) { create(:room) } + let!(:room1) { create(:room) } + + describe 'JSON formatting for FullCalendar' do + it 'translates rooms to resources' do + room_list = [room1, room2] # TODO + end + end +end From e1918fbf7ea98c87c2b0b70f4c72fce85ff14b3e Mon Sep 17 00:00:00 2001 From: Jimmy Date: Mon, 26 Apr 2021 09:48:16 +0800 Subject: [PATCH 05/36] [feat]Implement FullCalendar#rooms_to_resources and add tests --- app/controllers/schedules_controller.rb | 53 ++++++++++--------- app/services/full_calendar_formatter.rb | 15 +++++- spec/features/conference_schedule_spec.rb | 4 ++ spec/services/full_calendar_formatter_spec.rb | 16 +++++- 4 files changed, 59 insertions(+), 29 deletions(-) diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb index 1671fb8f..f23dbec9 100644 --- a/app/controllers/schedules_controller.rb +++ b/app/controllers/schedules_controller.rb @@ -80,34 +80,35 @@ class SchedulesController < ApplicationController end def vertical_schedule - @event_schedules = @program.selected_event_schedules( - includes: [{ event: %i[event_id title speaker] }] - ) + @event_schedules = @program.selected_event_schedules( + includes: [{ event: %i[event_id title speaker] }] + ) - respond_to do |format| - format.xml do - @events_xml = event_schedules.map(&:event).group_by{ |event| event.time.to_date } if event_schedules - end - - format.ics do - cal = Icalendar::Calendar.new - cal = icalendar_proposals(cal, event_schedules.map(&:event), @conference) - cal.publish - render inline: cal.to_ical - end - - format.html do - @rooms = @conference.venue.rooms if @conference.venue - @dates = @conference.start_date..@conference.end_date - - # Ids of the @event_schedules of confrmed self_organized tracks along with the selected_schedule_id - @selected_schedules_ids = [@conference.program.selected_schedule_id] - @conference.program.tracks.self_organized.confirmed.each do |track| - @selected_schedules_ids << track.selected_schedule_id - end - @selected_schedules_ids.compact! - @event_schedules_by_room_id = event_schedules.select { |s| @selected_schedules_ids.include?(s.schedule_id) }.group_by(&:room_id) + respond_to do |format| + format.xml do + @events_xml = event_schedules.map(&:event).group_by{ |event| event.time.to_date } if event_schedules + end + + format.ics do + cal = Icalendar::Calendar.new + cal = icalendar_proposals(cal, event_schedules.map(&:event), @conference) + cal.publish + render inline: cal.to_ical + end + + format.html do + @rooms = @conference.venue.rooms if @conference.venue + @dates = @conference.start_date..@conference.end_date + + # Ids of the @event_schedules of confrmed self_organized tracks along with the selected_schedule_id + @selected_schedules_ids = [@conference.program.selected_schedule_id] + @conference.program.tracks.self_organized.confirmed.each do |track| + @selected_schedules_ids << track.selected_schedule_id end + @selected_schedules_ids.compact! + @event_schedules_by_room_id = event_schedules.select { |s| @selected_schedules_ids.include?(s.schedule_id) }.group_by(&:room_id) + end + end end def app diff --git a/app/services/full_calendar_formatter.rb b/app/services/full_calendar_formatter.rb index 91cd3b25..94e0b09d 100644 --- a/app/services/full_calendar_formatter.rb +++ b/app/services/full_calendar_formatter.rb @@ -1,3 +1,16 @@ class FullCalendarFormatter - def rooms_to_resources(rooms); end + def self.rooms_to_resources(rooms) + rooms.map { |room| room_to_resource(room) }.to_json + end + + def self.event_schedules_to_resources(event_schedules); end + + private_class_method + + def self.room_to_resource(room) + { + id: room.guid, + title: room.name + } + end end diff --git a/spec/features/conference_schedule_spec.rb b/spec/features/conference_schedule_spec.rb index fae6fbeb..2fc6b03e 100644 --- a/spec/features/conference_schedule_spec.rb +++ b/spec/features/conference_schedule_spec.rb @@ -9,6 +9,10 @@ feature Schedule do before(:each) do visit vertical_schedule_conference_schedule_path end + + it 'returns a successful response' do + expect(response.status).to eq(200) + end end end end diff --git a/spec/services/full_calendar_formatter_spec.rb b/spec/services/full_calendar_formatter_spec.rb index 2cf607e9..2c931b90 100644 --- a/spec/services/full_calendar_formatter_spec.rb +++ b/spec/services/full_calendar_formatter_spec.rb @@ -3,12 +3,24 @@ require 'spec_helper' describe FullCalendarFormatter do - let!(:room0) { create(:room) } let!(:room1) { create(:room) } + let!(:room2) { create(:room) } describe 'JSON formatting for FullCalendar' do it 'translates rooms to resources' do - room_list = [room1, room2] # TODO + rooms = [room1, room2] + resources = described_class.rooms_to_resources(rooms) + expected_json = [ + { + id: room1.guid, + title: room1.name + }, + { + id: room2.guid, + title: room2.name + } + ].to_json + expect(resources).to eq(expected_json) end end end From adb6eb8526cca0c2130fb7aed6bd0979e3fca37d Mon Sep 17 00:00:00 2001 From: Jimmy Date: Mon, 26 Apr 2021 10:34:14 +0800 Subject: [PATCH 06/36] [feat]Implement FullCalendarFormatter#event_schedules_to_resources; Add tests --- app/services/full_calendar_formatter.rb | 28 ++++++++++++++----- spec/services/full_calendar_formatter_spec.rb | 26 ++++++++++++++++- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/app/services/full_calendar_formatter.rb b/app/services/full_calendar_formatter.rb index 94e0b09d..208eba2e 100644 --- a/app/services/full_calendar_formatter.rb +++ b/app/services/full_calendar_formatter.rb @@ -3,14 +3,28 @@ class FullCalendarFormatter rooms.map { |room| room_to_resource(room) }.to_json end - def self.event_schedules_to_resources(event_schedules); end + def self.event_schedules_to_resources(event_schedules) + event_schedules.map { |event_schedule| event_schedule_to_resource(event_schedule) }.to_json + end - private_class_method + class << self + private - def self.room_to_resource(room) - { - id: room.guid, - title: room.name - } + def room_to_resource(room) + { + id: room.guid, + title: room.name + } + end + + def event_schedule_to_resource(event_schedule) + { + id: event_schedule.event.guid, + title: event_schedule.event.title, + start: event_schedule.start_time, + end: event_schedule.end_time, + source: event_schedule.room.guid + } + end end end diff --git a/spec/services/full_calendar_formatter_spec.rb b/spec/services/full_calendar_formatter_spec.rb index 2c931b90..5ef763b1 100644 --- a/spec/services/full_calendar_formatter_spec.rb +++ b/spec/services/full_calendar_formatter_spec.rb @@ -5,10 +5,13 @@ require 'spec_helper' describe FullCalendarFormatter do let!(:room1) { create(:room) } let!(:room2) { create(:room) } + let!(:rooms) { [room1, room2] } + let!(:event_schedule1) { create(:event_schedule, room: room1) } + let!(:event_schedule2) { create(:event_schedule, room: room2) } + let!(:event_schedules) { [event_schedule1, event_schedule2] } describe 'JSON formatting for FullCalendar' do it 'translates rooms to resources' do - rooms = [room1, room2] resources = described_class.rooms_to_resources(rooms) expected_json = [ { @@ -22,5 +25,26 @@ describe FullCalendarFormatter do ].to_json expect(resources).to eq(expected_json) end + + it 'translates event schedules to resources' do + resources = described_class.event_schedules_to_resources(event_schedules) + expected_json = [ + { + id: event_schedule1.event.guid, + title: event_schedule1.event.title, + start: event_schedule1.start_time, + end: event_schedule1.end_time, + source: room1.guid + }, + { + id: event_schedule2.event.guid, + title: event_schedule2.event.title, + start: event_schedule2.start_time, + end: event_schedule2.end_time, + source: room2.guid + } + ].to_json + expect(resources).to eq(expected_json) + end end end From 4f2abd7e256ae3734f854ccc225d066324fb763d Mon Sep 17 00:00:00 2001 From: Jimmy Date: Mon, 26 Apr 2021 10:41:54 +0800 Subject: [PATCH 07/36] [feat]Add vertical schedule tab in Schedule --- app/controllers/schedules_controller.rb | 30 ++------------------ app/views/schedules/_schedule_tabs.html.haml | 2 ++ app/views/schedules/vertical_schedule.haml | 6 ++++ 3 files changed, 11 insertions(+), 27 deletions(-) create mode 100644 app/views/schedules/vertical_schedule.haml diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb index f23dbec9..7b70657f 100644 --- a/app/controllers/schedules_controller.rb +++ b/app/controllers/schedules_controller.rb @@ -75,40 +75,16 @@ class SchedulesController < ApplicationController respond_to do |format| format.html format.json { render json: @events_schedules.to_json(root: false, include: :event) } - end end def vertical_schedule @event_schedules = @program.selected_event_schedules( - includes: [{ event: %i[event_id title speaker] }] + includes: [{ event: %i[event_type speakers submitter] }] ) - respond_to do |format| - format.xml do - @events_xml = event_schedules.map(&:event).group_by{ |event| event.time.to_date } if event_schedules - end - - format.ics do - cal = Icalendar::Calendar.new - cal = icalendar_proposals(cal, event_schedules.map(&:event), @conference) - cal.publish - render inline: cal.to_ical - end - - format.html do - @rooms = @conference.venue.rooms if @conference.venue - @dates = @conference.start_date..@conference.end_date - - # Ids of the @event_schedules of confrmed self_organized tracks along with the selected_schedule_id - @selected_schedules_ids = [@conference.program.selected_schedule_id] - @conference.program.tracks.self_organized.confirmed.each do |track| - @selected_schedules_ids << track.selected_schedule_id - end - @selected_schedules_ids.compact! - @event_schedules_by_room_id = event_schedules.select { |s| @selected_schedules_ids.include?(s.schedule_id) }.group_by(&:room_id) - end - end + @rooms = @conference.venue.rooms if @conference.venue + @dates = @conference.start_date..@conference.end_date end def app diff --git a/app/views/schedules/_schedule_tabs.html.haml b/app/views/schedules/_schedule_tabs.html.haml index 33ba7f37..531433e4 100644 --- a/app/views/schedules/_schedule_tabs.html.haml +++ b/app/views/schedules/_schedule_tabs.html.haml @@ -7,3 +7,5 @@ = link_to('Happening Now', happening_now_conference_schedule_path(@conference.short_title)) %li{ class: "schedule #{ 'active' if active == 'schedule' }", role: "presentation" } = link_to('Schedule', conference_schedule_path(@conference.short_title)) + %li{ class: "vertical_schedule #{ 'active' if active == 'vertical_schedule' }", role: "presentation" } + = link_to('Vertical Schedule', vertical_schedule_conference_schedule_path(@conference.short_title)) diff --git a/app/views/schedules/vertical_schedule.haml b/app/views/schedules/vertical_schedule.haml new file mode 100644 index 00000000..728d47df --- /dev/null +++ b/app/views/schedules/vertical_schedule.haml @@ -0,0 +1,6 @@ +.container#program + = render 'schedule_tabs', active: 'vertical_schedule' + + %h1.text-center + Vertical Schedule for + = @conference.title \ No newline at end of file From 49cf115844124baebf8278aca337c4f86b7d1b68 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Mon, 26 Apr 2021 11:07:20 +0800 Subject: [PATCH 08/36] Fullcalendar integration in progress --- app/controllers/schedules_controller.rb | 11 ++++++++--- app/views/schedules/vertical_schedule.haml | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb index 7b70657f..28e20549 100644 --- a/app/controllers/schedules_controller.rb +++ b/app/controllers/schedules_controller.rb @@ -79,12 +79,17 @@ class SchedulesController < ApplicationController end def vertical_schedule - @event_schedules = @program.selected_event_schedules( + event_schedules = @program.selected_event_schedules( includes: [{ event: %i[event_type speakers submitter] }] ) - @rooms = @conference.venue.rooms if @conference.venue - @dates = @conference.start_date..@conference.end_date + unless event_schedules + redirect_to events_conference_schedule_path(@conference.short_title) + return + end + + @rooms = FullCalendarFormatter.rooms_to_resources(@conference.venue.rooms) if @conference.venue + @event_schedules = FullCalendarFormatter.event_schedules_to_resources(event_schedules) end def app diff --git a/app/views/schedules/vertical_schedule.haml b/app/views/schedules/vertical_schedule.haml index 728d47df..c3ff7534 100644 --- a/app/views/schedules/vertical_schedule.haml +++ b/app/views/schedules/vertical_schedule.haml @@ -3,4 +3,20 @@ %h1.text-center Vertical Schedule for - = @conference.title \ No newline at end of file + = @conference.title + + #calendar + +:javascript + document.addEventListener('DOMContentLoaded', function() { + var calendarEl = document.getElementById('calendar'); + + var calendar = new FullCalendar.Calendar(calendarEl, { + timeZone: 'UTC', + initialView: 'resourceTimeGridDay', + resources: "<%= @rooms >", + events: "<%= @event_schedules >" + }); + + calendar.render(); + }); From df729b7dde752cff2017ddf709e1145ad28299bc Mon Sep 17 00:00:00 2001 From: Jimmy Date: Mon, 26 Apr 2021 17:33:31 +0800 Subject: [PATCH 09/36] [feat]Fullcalendar integration done --- app/assets/javascripts/application.js | 1 + app/assets/stylesheets/application.css | 2 + app/services/full_calendar_formatter.rb | 10 +-- app/views/schedules/vertical_schedule.haml | 4 +- config/application.rb | 2 + package-lock.json | 87 +++++++++++++++++++ package.json | 3 +- spec/services/full_calendar_formatter_spec.rb | 20 ++--- yarn.lock | 5 ++ 9 files changed, 116 insertions(+), 18 deletions(-) create mode 100644 package-lock.json diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 6548a3fe..18c5d6f6 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -55,6 +55,7 @@ //= require bootstrap-select //= require osem-survey //= require pagy +//= require fullcalendar-scheduler/main.js $(document).ready(function() { $('a[disabled=disabled]').click(function(event){ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f5c58982..520eedbe 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -26,4 +26,6 @@ *= require osem-navbar *= require mastodon *= require conferences + + *= require fullcalendar-scheduler/main.css */ diff --git a/app/services/full_calendar_formatter.rb b/app/services/full_calendar_formatter.rb index 208eba2e..4deaa126 100644 --- a/app/services/full_calendar_formatter.rb +++ b/app/services/full_calendar_formatter.rb @@ -19,11 +19,11 @@ class FullCalendarFormatter def event_schedule_to_resource(event_schedule) { - id: event_schedule.event.guid, - title: event_schedule.event.title, - start: event_schedule.start_time, - end: event_schedule.end_time, - source: event_schedule.room.guid + id: event_schedule.event.guid, + title: event_schedule.event.title, + start: event_schedule.start_time, + end: event_schedule.end_time, + resourceId: event_schedule.room.guid } end end diff --git a/app/views/schedules/vertical_schedule.haml b/app/views/schedules/vertical_schedule.haml index c3ff7534..a494bfd5 100644 --- a/app/views/schedules/vertical_schedule.haml +++ b/app/views/schedules/vertical_schedule.haml @@ -14,8 +14,8 @@ var calendar = new FullCalendar.Calendar(calendarEl, { timeZone: 'UTC', initialView: 'resourceTimeGridDay', - resources: "<%= @rooms >", - events: "<%= @event_schedules >" + resources: #{@rooms.html_safe}, + events: #{@event_schedules.html_safe} }); calendar.render(); diff --git a/config/application.rb b/config/application.rb index 4e5e9b87..4d52dc2c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -80,5 +80,7 @@ module Osem end end end + + config.assets.paths << Rails.root.join('node_modules') end end diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..25f236f4 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,87 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "@fullcalendar/common": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@fullcalendar/common/-/common-5.6.0.tgz", + "integrity": "sha512-4i4kZDVpRvfdKoJHRljDHsoYu466Odor9FhekP+67dIUoNnXSDTnQRmGfURwiF4RwaTsdWKe2+B7gors9G7zZA==", + "requires": { + "tslib": "^2.0.3" + } + }, + "@fullcalendar/daygrid": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@fullcalendar/daygrid/-/daygrid-5.6.0.tgz", + "integrity": "sha512-UaNn6/vKQ3zI4/sDhrMACkIHOSZb/MA0JGlvvw3OTYFULqE5TISuYYnDbo9S1Wdz3AbTBvCzYy5Qk1vZQFsGwg==", + "requires": { + "@fullcalendar/common": "~5.6.0", + "tslib": "^2.0.3" + } + }, + "@fullcalendar/premium-common": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@fullcalendar/premium-common/-/premium-common-5.6.0.tgz", + "integrity": "sha512-AtcoKphdGasBHNlN9DD7Kxc/7EmCUpIRu7JVRJYnrm4cR8rM3gCUCMMoPt8pyEfy4P/GN/4wGko54kgPkLzUTg==", + "requires": { + "@fullcalendar/common": "~5.6.0", + "tslib": "^2.0.3" + } + }, + "@fullcalendar/resource-common": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@fullcalendar/resource-common/-/resource-common-5.6.0.tgz", + "integrity": "sha512-9FTGQcUO+ER6U44Tj32c+pSvsJ+5CrGs1RDxRyei8UIvUwY6SxQySgdAozW3yxwozEoc5TZ7xLrlLw7vKAwN6w==", + "requires": { + "@fullcalendar/common": "~5.6.0", + "@fullcalendar/premium-common": "~5.6.0", + "tslib": "^2.0.3" + } + }, + "@fullcalendar/resource-daygrid": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@fullcalendar/resource-daygrid/-/resource-daygrid-5.6.0.tgz", + "integrity": "sha512-KWV61gxtgFoaFTPi6b/MP/FaROMtu8c2ijzznMY5VPjQzjU5CSaWLpPht1T2ZOije3QTiDZ8Gx4M4yLFKMHCAg==", + "requires": { + "@fullcalendar/common": "~5.6.0", + "@fullcalendar/daygrid": "~5.6.0", + "@fullcalendar/premium-common": "~5.6.0", + "@fullcalendar/resource-common": "~5.6.0", + "tslib": "^2.0.3" + } + }, + "@fullcalendar/resource-timegrid": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@fullcalendar/resource-timegrid/-/resource-timegrid-5.6.0.tgz", + "integrity": "sha512-BAiSTeuL8P0YwG2o6roavDP2dlA5cXFrxcYhx4qvEyqxscmGunI5NnxhmXafpnWO60PgvwHO++EoJvAsR3WSSg==", + "requires": { + "@fullcalendar/common": "~5.6.0", + "@fullcalendar/premium-common": "~5.6.0", + "@fullcalendar/resource-common": "~5.6.0", + "@fullcalendar/resource-daygrid": "~5.6.0", + "@fullcalendar/timegrid": "~5.6.0", + "tslib": "^2.0.3" + } + }, + "@fullcalendar/timegrid": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@fullcalendar/timegrid/-/timegrid-5.6.0.tgz", + "integrity": "sha512-NG55pzPvrzZEuVq+/Vn1ZbyKARVjsE6PzhiOHvJuyt3gzVPeWjXGUWjDN3BSDZ8p/4dthbF6H9mCPia977aV1g==", + "requires": { + "@fullcalendar/common": "~5.6.0", + "@fullcalendar/daygrid": "~5.6.0", + "tslib": "^2.0.3" + } + }, + "fullcalendar-scheduler": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/fullcalendar-scheduler/-/fullcalendar-scheduler-5.6.0.tgz", + "integrity": "sha512-0jx/Q+6QqzvIGWU/52OE27UVjVAiM9E0o/qRwRcEhyuKlL54ypTF/yXP/wo0ctUtui5dDsilGNsSsba1xmARJA==" + }, + "tslib": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.2.0.tgz", + "integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==" + } + } +} diff --git a/package.json b/package.json index 7a1501b9..211ced7b 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "dependencies": { - "@fullcalendar/resource-timegrid": "^5.6.0" + "@fullcalendar/resource-timegrid": "^5.6.0", + "fullcalendar-scheduler": "^5.6.0" } } diff --git a/spec/services/full_calendar_formatter_spec.rb b/spec/services/full_calendar_formatter_spec.rb index 5ef763b1..a3dd418d 100644 --- a/spec/services/full_calendar_formatter_spec.rb +++ b/spec/services/full_calendar_formatter_spec.rb @@ -30,18 +30,18 @@ describe FullCalendarFormatter do resources = described_class.event_schedules_to_resources(event_schedules) expected_json = [ { - id: event_schedule1.event.guid, - title: event_schedule1.event.title, - start: event_schedule1.start_time, - end: event_schedule1.end_time, - source: room1.guid + id: event_schedule1.event.guid, + title: event_schedule1.event.title, + start: event_schedule1.start_time, + end: event_schedule1.end_time, + resourceId: room1.guid }, { - id: event_schedule2.event.guid, - title: event_schedule2.event.title, - start: event_schedule2.start_time, - end: event_schedule2.end_time, - source: room2.guid + id: event_schedule2.event.guid, + title: event_schedule2.event.title, + start: event_schedule2.start_time, + end: event_schedule2.end_time, + resourceId: room2.guid } ].to_json expect(resources).to eq(expected_json) diff --git a/yarn.lock b/yarn.lock index 500a76fc..d72f1a29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -66,6 +66,11 @@ "@fullcalendar/daygrid" "~5.6.0" tslib "^2.0.3" +fullcalendar-scheduler@^5.6.0: + version "5.6.0" + resolved "https://registry.yarnpkg.com/fullcalendar-scheduler/-/fullcalendar-scheduler-5.6.0.tgz#8328318d3d5901188a4ccb8c3cd4b756d2c76e16" + integrity sha512-0jx/Q+6QqzvIGWU/52OE27UVjVAiM9E0o/qRwRcEhyuKlL54ypTF/yXP/wo0ctUtui5dDsilGNsSsba1xmARJA== + tslib@^2.0.3: version "2.2.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c" From dd6a2600e7da1fef21e1c228ce55c62b7e61c6a6 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 28 Apr 2021 21:42:16 -0700 Subject: [PATCH 10/36] Commit to using Yarn over NPM --- app/assets/javascripts/application.js | 2 +- app/assets/stylesheets/application.css | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 18c5d6f6..075f9c11 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -55,7 +55,7 @@ //= require bootstrap-select //= require osem-survey //= require pagy -//= require fullcalendar-scheduler/main.js +//= require @fullcalendar/common/main.js $(document).ready(function() { $('a[disabled=disabled]').click(function(event){ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 520eedbe..f5c58982 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -26,6 +26,4 @@ *= require osem-navbar *= require mastodon *= require conferences - - *= require fullcalendar-scheduler/main.css */ From a81519ce688ec693fd2f2d0d4cb8198ad33395b8 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 28 Apr 2021 21:44:00 -0700 Subject: [PATCH 11/36] Allow users who are not signed-in to view vertical_schedule endpoint --- app/models/ability.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index ec17e14c..68c83066 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -31,7 +31,7 @@ class Ability event.state == 'confirmed' end - can [:show, :events, :happening_now, :app], Schedule do |schedule| + can [:show, :events, :happening_now, :app, :vertical_schedule], Schedule do |schedule| schedule.program.schedule_public end From 22961c4071cc1fe9a49b359933b0c894651be295 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 28 Apr 2021 23:07:13 -0700 Subject: [PATCH 12/36] Revert "Commit to using Yarn over NPM" This reverts commit dd6a2600e7da1fef21e1c228ce55c62b7e61c6a6. --- app/assets/javascripts/application.js | 2 +- app/assets/stylesheets/application.css | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 075f9c11..18c5d6f6 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -55,7 +55,7 @@ //= require bootstrap-select //= require osem-survey //= require pagy -//= require @fullcalendar/common/main.js +//= require fullcalendar-scheduler/main.js $(document).ready(function() { $('a[disabled=disabled]').click(function(event){ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f5c58982..520eedbe 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -26,4 +26,6 @@ *= require osem-navbar *= require mastodon *= require conferences + + *= require fullcalendar-scheduler/main.css */ From 2695aebc07576d87b9fcc853bb7b97697c20309e Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 28 Apr 2021 23:21:53 -0700 Subject: [PATCH 13/36] Remove Vertical Schedule tab --- app/views/schedules/_schedule_tabs.html.haml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/views/schedules/_schedule_tabs.html.haml b/app/views/schedules/_schedule_tabs.html.haml index 531433e4..33ba7f37 100644 --- a/app/views/schedules/_schedule_tabs.html.haml +++ b/app/views/schedules/_schedule_tabs.html.haml @@ -7,5 +7,3 @@ = link_to('Happening Now', happening_now_conference_schedule_path(@conference.short_title)) %li{ class: "schedule #{ 'active' if active == 'schedule' }", role: "presentation" } = link_to('Schedule', conference_schedule_path(@conference.short_title)) - %li{ class: "vertical_schedule #{ 'active' if active == 'vertical_schedule' }", role: "presentation" } - = link_to('Vertical Schedule', vertical_schedule_conference_schedule_path(@conference.short_title)) From 1c23033f1da81b2f0494ed683caca839071f8746 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 28 Apr 2021 23:53:55 -0700 Subject: [PATCH 14/36] Move JS out of view and have calendar start on same day as horizontal schedule --- app/assets/javascripts/application.js | 1 + app/assets/javascripts/fullcalendar.js | 15 +++++++++++++++ app/controllers/schedules_controller.rb | 4 ++++ app/views/schedules/vertical_schedule.haml | 17 ++--------------- 4 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 app/assets/javascripts/fullcalendar.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 18c5d6f6..c5b49ae7 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -56,6 +56,7 @@ //= require osem-survey //= require pagy //= require fullcalendar-scheduler/main.js +//= require fullcalendar $(document).ready(function() { $('a[disabled=disabled]').click(function(event){ diff --git a/app/assets/javascripts/fullcalendar.js b/app/assets/javascripts/fullcalendar.js new file mode 100644 index 00000000..e29a3d27 --- /dev/null +++ b/app/assets/javascripts/fullcalendar.js @@ -0,0 +1,15 @@ +$( document ).ready(function() { + let calendarEl = document.getElementById('vert-schedule-full-calendar'); + if (!calendarEl) return; //check that we need a vertical schedule + let fullcalData = $('#fullcalendar'); + + var calendar = new FullCalendar.Calendar(calendarEl, { + timeZone: 'UTC', + initialDate: fullcalData.data('day'), + initialView: 'resourceTimeGridDay', + resources: fullcalData.data('rooms'), + events: fullcalData.data('events') + }); + + calendar.render(); +}); diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb index 28e20549..a22ded39 100644 --- a/app/controllers/schedules_controller.rb +++ b/app/controllers/schedules_controller.rb @@ -79,6 +79,10 @@ class SchedulesController < ApplicationController end def vertical_schedule + dates = @conference.start_date..@conference.end_date + # the schedule takes you to today if it is a date of the schedule + current_day = @conference.current_conference_day + @day = current_day.present? ? current_day : dates.first event_schedules = @program.selected_event_schedules( includes: [{ event: %i[event_type speakers submitter] }] ) diff --git a/app/views/schedules/vertical_schedule.haml b/app/views/schedules/vertical_schedule.haml index a494bfd5..ee6c49c5 100644 --- a/app/views/schedules/vertical_schedule.haml +++ b/app/views/schedules/vertical_schedule.haml @@ -5,18 +5,5 @@ Vertical Schedule for = @conference.title - #calendar - -:javascript - document.addEventListener('DOMContentLoaded', function() { - var calendarEl = document.getElementById('calendar'); - - var calendar = new FullCalendar.Calendar(calendarEl, { - timeZone: 'UTC', - initialView: 'resourceTimeGridDay', - resources: #{@rooms.html_safe}, - events: #{@event_schedules.html_safe} - }); - - calendar.render(); - }); + #vert-schedule-full-calendar + #fullcalendar{ data: { rooms: @rooms, events: @event_schedules, day: @day } } From b754d686922cb218475700f629b4f7a6d4513e8c Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 15:14:46 +0800 Subject: [PATCH 15/36] [feat]Add url, background color, text color to events in vertical schedule --- app/services/full_calendar_formatter.rb | 25 ++++++++--- spec/services/full_calendar_formatter_spec.rb | 43 +++++++++++++------ spec/spec_helper.rb | 3 ++ 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/app/services/full_calendar_formatter.rb b/app/services/full_calendar_formatter.rb index 4deaa126..1452cb59 100644 --- a/app/services/full_calendar_formatter.rb +++ b/app/services/full_calendar_formatter.rb @@ -4,10 +4,15 @@ class FullCalendarFormatter end def self.event_schedules_to_resources(event_schedules) - event_schedules.map { |event_schedule| event_schedule_to_resource(event_schedule) }.to_json + return '[]' if event_schedules.empty? + + conference = event_schedules.first.schedule.program.conference + event_schedules.map { |event_schedule| event_schedule_to_resource(conference, event_schedule) }.to_json end class << self + include FormatHelper + private def room_to_resource(room) @@ -17,13 +22,19 @@ class FullCalendarFormatter } end - def event_schedule_to_resource(event_schedule) + def event_schedule_to_resource(conference, event_schedule) + event_type_color = event_schedule.event.event_type.color + url = Rails.application.routes.url_helpers.conference_program_proposal_path(conference.short_title, event_schedule.event.id) + { - id: event_schedule.event.guid, - title: event_schedule.event.title, - start: event_schedule.start_time, - end: event_schedule.end_time, - resourceId: event_schedule.room.guid + id: event_schedule.event.guid, + title: event_schedule.event.title, + start: event_schedule.start_time, + end: event_schedule.end_time, + resourceId: event_schedule.room.guid, + url: url, + backgroundColor: event_type_color, + textColor: contrast_color(event_type_color) } end end diff --git a/spec/services/full_calendar_formatter_spec.rb b/spec/services/full_calendar_formatter_spec.rb index a3dd418d..45f34c2b 100644 --- a/spec/services/full_calendar_formatter_spec.rb +++ b/spec/services/full_calendar_formatter_spec.rb @@ -6,8 +6,21 @@ describe FullCalendarFormatter do let!(:room1) { create(:room) } let!(:room2) { create(:room) } let!(:rooms) { [room1, room2] } - let!(:event_schedule1) { create(:event_schedule, room: room1) } - let!(:event_schedule2) { create(:event_schedule, room: room2) } + let!(:conference) { create(:full_conference) } + let!(:program) { conference.program } + let!(:selected_schedule) { create(:schedule, program: program) } + let!(:event_type1) { create(:event_type, color: '#ffffff') } + let!(:event1) do + program.update_attributes!(selected_schedule: selected_schedule) + create(:event, program: program, event_type: event_type1) + end + let!(:event_schedule1) { create(:event_schedule, event: event1, schedule: selected_schedule, room: room1) } + let!(:event_type2) { create(:event_type, color: '#000000') } + let!(:event2) do + program.update_attributes!(selected_schedule: selected_schedule) + create(:event, program: program, room: room2, event_type: event_type2) + end + let!(:event_schedule2) { create(:event_schedule, event: event2, schedule: selected_schedule, room: room2) } let!(:event_schedules) { [event_schedule1, event_schedule2] } describe 'JSON formatting for FullCalendar' do @@ -30,18 +43,24 @@ describe FullCalendarFormatter do resources = described_class.event_schedules_to_resources(event_schedules) expected_json = [ { - id: event_schedule1.event.guid, - title: event_schedule1.event.title, - start: event_schedule1.start_time, - end: event_schedule1.end_time, - resourceId: room1.guid + id: event_schedule1.event.guid, + title: event_schedule1.event.title, + start: event_schedule1.start_time, + end: event_schedule1.end_time, + resourceId: room1.guid, + url: conference_program_proposal_path(conference.short_title, event1.id), + backgroundColor: event1.event_type.color, + textColor: 'black' }, { - id: event_schedule2.event.guid, - title: event_schedule2.event.title, - start: event_schedule2.start_time, - end: event_schedule2.end_time, - resourceId: room2.guid + id: event_schedule2.event.guid, + title: event_schedule2.event.title, + start: event_schedule2.start_time, + end: event_schedule2.end_time, + resourceId: room2.guid, + url: conference_program_proposal_path(conference.short_title, event2.id), + backgroundColor: event2.event_type.color, + textColor: 'white' } ].to_json expect(resources).to eq(expected_json) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2d680fb2..e45bfb38 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -123,6 +123,9 @@ RSpec.configure do |config| # enable debugging with --only-failures config.example_status_persistence_file_path = 'tmp/spec_failures.txt' + + # include path helpers + config.include Rails.application.routes.url_helpers end OmniAuth.config.test_mode = true From b8f0db4a005fc1c6ea92884857b996992015743e Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 15:39:14 +0800 Subject: [PATCH 16/36] [chore]Clean up package.json and remove yarn.lock --- package-lock.json | 76 ---------------------------------------------- package.json | 1 - yarn.lock | 77 ----------------------------------------------- 3 files changed, 154 deletions(-) delete mode 100644 yarn.lock diff --git a/package-lock.json b/package-lock.json index 25f236f4..88e0e172 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2,86 +2,10 @@ "requires": true, "lockfileVersion": 1, "dependencies": { - "@fullcalendar/common": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/@fullcalendar/common/-/common-5.6.0.tgz", - "integrity": "sha512-4i4kZDVpRvfdKoJHRljDHsoYu466Odor9FhekP+67dIUoNnXSDTnQRmGfURwiF4RwaTsdWKe2+B7gors9G7zZA==", - "requires": { - "tslib": "^2.0.3" - } - }, - "@fullcalendar/daygrid": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/@fullcalendar/daygrid/-/daygrid-5.6.0.tgz", - "integrity": "sha512-UaNn6/vKQ3zI4/sDhrMACkIHOSZb/MA0JGlvvw3OTYFULqE5TISuYYnDbo9S1Wdz3AbTBvCzYy5Qk1vZQFsGwg==", - "requires": { - "@fullcalendar/common": "~5.6.0", - "tslib": "^2.0.3" - } - }, - "@fullcalendar/premium-common": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/@fullcalendar/premium-common/-/premium-common-5.6.0.tgz", - "integrity": "sha512-AtcoKphdGasBHNlN9DD7Kxc/7EmCUpIRu7JVRJYnrm4cR8rM3gCUCMMoPt8pyEfy4P/GN/4wGko54kgPkLzUTg==", - "requires": { - "@fullcalendar/common": "~5.6.0", - "tslib": "^2.0.3" - } - }, - "@fullcalendar/resource-common": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/@fullcalendar/resource-common/-/resource-common-5.6.0.tgz", - "integrity": "sha512-9FTGQcUO+ER6U44Tj32c+pSvsJ+5CrGs1RDxRyei8UIvUwY6SxQySgdAozW3yxwozEoc5TZ7xLrlLw7vKAwN6w==", - "requires": { - "@fullcalendar/common": "~5.6.0", - "@fullcalendar/premium-common": "~5.6.0", - "tslib": "^2.0.3" - } - }, - "@fullcalendar/resource-daygrid": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/@fullcalendar/resource-daygrid/-/resource-daygrid-5.6.0.tgz", - "integrity": "sha512-KWV61gxtgFoaFTPi6b/MP/FaROMtu8c2ijzznMY5VPjQzjU5CSaWLpPht1T2ZOije3QTiDZ8Gx4M4yLFKMHCAg==", - "requires": { - "@fullcalendar/common": "~5.6.0", - "@fullcalendar/daygrid": "~5.6.0", - "@fullcalendar/premium-common": "~5.6.0", - "@fullcalendar/resource-common": "~5.6.0", - "tslib": "^2.0.3" - } - }, - "@fullcalendar/resource-timegrid": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/@fullcalendar/resource-timegrid/-/resource-timegrid-5.6.0.tgz", - "integrity": "sha512-BAiSTeuL8P0YwG2o6roavDP2dlA5cXFrxcYhx4qvEyqxscmGunI5NnxhmXafpnWO60PgvwHO++EoJvAsR3WSSg==", - "requires": { - "@fullcalendar/common": "~5.6.0", - "@fullcalendar/premium-common": "~5.6.0", - "@fullcalendar/resource-common": "~5.6.0", - "@fullcalendar/resource-daygrid": "~5.6.0", - "@fullcalendar/timegrid": "~5.6.0", - "tslib": "^2.0.3" - } - }, - "@fullcalendar/timegrid": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/@fullcalendar/timegrid/-/timegrid-5.6.0.tgz", - "integrity": "sha512-NG55pzPvrzZEuVq+/Vn1ZbyKARVjsE6PzhiOHvJuyt3gzVPeWjXGUWjDN3BSDZ8p/4dthbF6H9mCPia977aV1g==", - "requires": { - "@fullcalendar/common": "~5.6.0", - "@fullcalendar/daygrid": "~5.6.0", - "tslib": "^2.0.3" - } - }, "fullcalendar-scheduler": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/fullcalendar-scheduler/-/fullcalendar-scheduler-5.6.0.tgz", "integrity": "sha512-0jx/Q+6QqzvIGWU/52OE27UVjVAiM9E0o/qRwRcEhyuKlL54ypTF/yXP/wo0ctUtui5dDsilGNsSsba1xmARJA==" - }, - "tslib": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.2.0.tgz", - "integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==" } } } diff --git a/package.json b/package.json index 211ced7b..d8f5ba1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,5 @@ { "dependencies": { - "@fullcalendar/resource-timegrid": "^5.6.0", "fullcalendar-scheduler": "^5.6.0" } } diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index d72f1a29..00000000 --- a/yarn.lock +++ /dev/null @@ -1,77 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@fullcalendar/common@~5.6.0": - version "5.6.0" - resolved "https://registry.yarnpkg.com/@fullcalendar/common/-/common-5.6.0.tgz#27206084df07fbab33a67478b0d9b05542b09b79" - integrity sha512-4i4kZDVpRvfdKoJHRljDHsoYu466Odor9FhekP+67dIUoNnXSDTnQRmGfURwiF4RwaTsdWKe2+B7gors9G7zZA== - dependencies: - tslib "^2.0.3" - -"@fullcalendar/daygrid@~5.6.0": - version "5.6.0" - resolved "https://registry.yarnpkg.com/@fullcalendar/daygrid/-/daygrid-5.6.0.tgz#705508a7e7c5d560d01877485283f370c3c70780" - integrity sha512-UaNn6/vKQ3zI4/sDhrMACkIHOSZb/MA0JGlvvw3OTYFULqE5TISuYYnDbo9S1Wdz3AbTBvCzYy5Qk1vZQFsGwg== - dependencies: - "@fullcalendar/common" "~5.6.0" - tslib "^2.0.3" - -"@fullcalendar/premium-common@~5.6.0": - version "5.6.0" - resolved "https://registry.yarnpkg.com/@fullcalendar/premium-common/-/premium-common-5.6.0.tgz#d8dba80dbf09a664184d061928d1ad9ace079238" - integrity sha512-AtcoKphdGasBHNlN9DD7Kxc/7EmCUpIRu7JVRJYnrm4cR8rM3gCUCMMoPt8pyEfy4P/GN/4wGko54kgPkLzUTg== - dependencies: - "@fullcalendar/common" "~5.6.0" - tslib "^2.0.3" - -"@fullcalendar/resource-common@~5.6.0": - version "5.6.0" - resolved "https://registry.yarnpkg.com/@fullcalendar/resource-common/-/resource-common-5.6.0.tgz#e9f5688f366ea4ec10e7756485a2ab25d957513c" - integrity sha512-9FTGQcUO+ER6U44Tj32c+pSvsJ+5CrGs1RDxRyei8UIvUwY6SxQySgdAozW3yxwozEoc5TZ7xLrlLw7vKAwN6w== - dependencies: - "@fullcalendar/common" "~5.6.0" - "@fullcalendar/premium-common" "~5.6.0" - tslib "^2.0.3" - -"@fullcalendar/resource-daygrid@~5.6.0": - version "5.6.0" - resolved "https://registry.yarnpkg.com/@fullcalendar/resource-daygrid/-/resource-daygrid-5.6.0.tgz#537468cdc3910557586fa0d335bcd1bd7b5bdc77" - integrity sha512-KWV61gxtgFoaFTPi6b/MP/FaROMtu8c2ijzznMY5VPjQzjU5CSaWLpPht1T2ZOije3QTiDZ8Gx4M4yLFKMHCAg== - dependencies: - "@fullcalendar/common" "~5.6.0" - "@fullcalendar/daygrid" "~5.6.0" - "@fullcalendar/premium-common" "~5.6.0" - "@fullcalendar/resource-common" "~5.6.0" - tslib "^2.0.3" - -"@fullcalendar/resource-timegrid@^5.6.0": - version "5.6.0" - resolved "https://registry.yarnpkg.com/@fullcalendar/resource-timegrid/-/resource-timegrid-5.6.0.tgz#5461026d085f64297d7507980a7ed069c29002a7" - integrity sha512-BAiSTeuL8P0YwG2o6roavDP2dlA5cXFrxcYhx4qvEyqxscmGunI5NnxhmXafpnWO60PgvwHO++EoJvAsR3WSSg== - dependencies: - "@fullcalendar/common" "~5.6.0" - "@fullcalendar/premium-common" "~5.6.0" - "@fullcalendar/resource-common" "~5.6.0" - "@fullcalendar/resource-daygrid" "~5.6.0" - "@fullcalendar/timegrid" "~5.6.0" - tslib "^2.0.3" - -"@fullcalendar/timegrid@~5.6.0": - version "5.6.0" - resolved "https://registry.yarnpkg.com/@fullcalendar/timegrid/-/timegrid-5.6.0.tgz#0e489d60f224042211e688d3273154964aab6b54" - integrity sha512-NG55pzPvrzZEuVq+/Vn1ZbyKARVjsE6PzhiOHvJuyt3gzVPeWjXGUWjDN3BSDZ8p/4dthbF6H9mCPia977aV1g== - dependencies: - "@fullcalendar/common" "~5.6.0" - "@fullcalendar/daygrid" "~5.6.0" - tslib "^2.0.3" - -fullcalendar-scheduler@^5.6.0: - version "5.6.0" - resolved "https://registry.yarnpkg.com/fullcalendar-scheduler/-/fullcalendar-scheduler-5.6.0.tgz#8328318d3d5901188a4ccb8c3cd4b756d2c76e16" - integrity sha512-0jx/Q+6QqzvIGWU/52OE27UVjVAiM9E0o/qRwRcEhyuKlL54ypTF/yXP/wo0ctUtui5dDsilGNsSsba1xmARJA== - -tslib@^2.0.3: - version "2.2.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c" - integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w== From 96944f704f204d676a2aaaf3e9878397ebb13638 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 15:41:06 +0800 Subject: [PATCH 17/36] [style]Fix rubocop --- app/services/full_calendar_formatter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/full_calendar_formatter.rb b/app/services/full_calendar_formatter.rb index 1452cb59..512bb35f 100644 --- a/app/services/full_calendar_formatter.rb +++ b/app/services/full_calendar_formatter.rb @@ -12,7 +12,7 @@ class FullCalendarFormatter class << self include FormatHelper - + private def room_to_resource(room) From de43982b4460e963ad9586fea0ebd3511818b795 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 15:49:32 +0800 Subject: [PATCH 18/36] [CI]Try fixing github workflow by adding npm install --- .github/workflows/spec.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/spec.yml b/.github/workflows/spec.yml index b2e7d847..73375a39 100644 --- a/.github/workflows/spec.yml +++ b/.github/workflows/spec.yml @@ -38,6 +38,12 @@ jobs: with: ruby-version: 2.6.6 bundler-cache: true + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: '12.x' + - name: Install dependencies + run: npm install - name: Prepare spec run: | rm -f osem_test osem_development From 96f9cf1c4ee0ab15f9c51eaaa1c67d880ba8ac98 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 15:55:25 +0800 Subject: [PATCH 19/36] [CI]Try fixing travis by running npm install --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b35784c6..00d5b582 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,7 @@ jobs: - gem install bundler -v $(tail -n 1 Gemfile.lock) - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $CCTR - chmod +x $CCTR + - npm install before_script: - RAILS_ENV=test bundle exec rake db:bootstrap --trace - RAILS_ENV=test bundle exec bin/rails webdrivers:chromedriver:update From c2981eab7ba2168f7ae0acad1ecd41b1122a737d Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 15:56:06 +0800 Subject: [PATCH 20/36] [CI]Add more description to npm install --- .github/workflows/spec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spec.yml b/.github/workflows/spec.yml index 73375a39..6875c7b8 100644 --- a/.github/workflows/spec.yml +++ b/.github/workflows/spec.yml @@ -42,7 +42,7 @@ jobs: uses: actions/setup-node@v1 with: node-version: '12.x' - - name: Install dependencies + - name: Install JavaScript libraries via npm run: npm install - name: Prepare spec run: | From e4abc009e27bd68da23c1535566627a3a2c9db5e Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 16:17:39 +0800 Subject: [PATCH 21/36] [test]Move conference_schedule_spec to schedules_controller_spec --- spec/controllers/schedules_controller_spec.rb | 16 ++++++++++++++++ spec/features/conference_schedule_spec.rb | 18 ------------------ 2 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 spec/features/conference_schedule_spec.rb diff --git a/spec/controllers/schedules_controller_spec.rb b/spec/controllers/schedules_controller_spec.rb index 22cb7c1a..dbf9e38b 100644 --- a/spec/controllers/schedules_controller_spec.rb +++ b/spec/controllers/schedules_controller_spec.rb @@ -72,4 +72,20 @@ describe SchedulesController do end end end + + describe 'GET #vertical_schedule' do + let!(:program) { conference.program } + + context 'as a conference participant' do + context 'who visits the schedule page' do + before(:each) do + get :vertical_schedule, params: { conference_id: conference.short_title } + end + + it 'returns a successful response' do + expect(response.status).to eq(200) + end + end + end + end end diff --git a/spec/features/conference_schedule_spec.rb b/spec/features/conference_schedule_spec.rb deleted file mode 100644 index 2fc6b03e..00000000 --- a/spec/features/conference_schedule_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -feature Schedule do - let!(:conference) { create(:conference) } - let!(:program) { conference.program } - - context 'as a conference participant' do - context 'who visits the schedule page' do - before(:each) do - visit vertical_schedule_conference_schedule_path - end - - it 'returns a successful response' do - expect(response.status).to eq(200) - end - end - end -end From 38bac34583bae0780003a7c95554edc96848a8d9 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 16:20:49 +0800 Subject: [PATCH 22/36] [fix]Fix route helpers in tests --- spec/services/full_calendar_formatter_spec.rb | 4 ++-- spec/spec_helper.rb | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/spec/services/full_calendar_formatter_spec.rb b/spec/services/full_calendar_formatter_spec.rb index 45f34c2b..525af045 100644 --- a/spec/services/full_calendar_formatter_spec.rb +++ b/spec/services/full_calendar_formatter_spec.rb @@ -48,7 +48,7 @@ describe FullCalendarFormatter do start: event_schedule1.start_time, end: event_schedule1.end_time, resourceId: room1.guid, - url: conference_program_proposal_path(conference.short_title, event1.id), + url: Rails.application.routes.url_helpers.conference_program_proposal_path(conference.short_title, event1.id), backgroundColor: event1.event_type.color, textColor: 'black' }, @@ -58,7 +58,7 @@ describe FullCalendarFormatter do start: event_schedule2.start_time, end: event_schedule2.end_time, resourceId: room2.guid, - url: conference_program_proposal_path(conference.short_title, event2.id), + url: Rails.application.routes.url_helpers.conference_program_proposal_path(conference.short_title, event2.id), backgroundColor: event2.event_type.color, textColor: 'white' } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e45bfb38..2d680fb2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -123,9 +123,6 @@ RSpec.configure do |config| # enable debugging with --only-failures config.example_status_persistence_file_path = 'tmp/spec_failures.txt' - - # include path helpers - config.include Rails.application.routes.url_helpers end OmniAuth.config.test_mode = true From 92d6365f713d931ff93094af17701fa727c61841 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 16:31:02 +0800 Subject: [PATCH 23/36] [chore]Update rexml in Gemfile.lock for security reasons --- Gemfile.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 52965d29..d0f78ee9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -496,7 +496,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.2.4) + rexml (3.2.5) rolify (5.2.0) rqrcode (0.10.1) chunky_png (~> 1.0) @@ -719,7 +719,7 @@ DEPENDENCIES leaflet-rails letter_opener letter_opener_web (~> 1.0) - mimemagic (~> 0.3.6) + mimemagic mina mini_magick money-rails @@ -762,6 +762,7 @@ DEPENDENCIES recaptcha redcarpet responders (~> 2.0) + rexml (~> 3.2) rolify rqrcode rspec-activemodel-mocks From 1de29c4df15ba56333bc4ec2e7efaf849532b7b3 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 16:32:06 +0800 Subject: [PATCH 24/36] [doc]Add comment in fullcalendar.js so that if events are added to database with timezone info explicitly, the fullcalendar can be fixed --- app/assets/javascripts/fullcalendar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/fullcalendar.js b/app/assets/javascripts/fullcalendar.js index e29a3d27..77e02e2e 100644 --- a/app/assets/javascripts/fullcalendar.js +++ b/app/assets/javascripts/fullcalendar.js @@ -4,7 +4,7 @@ $( document ).ready(function() { let fullcalData = $('#fullcalendar'); var calendar = new FullCalendar.Calendar(calendarEl, { - timeZone: 'UTC', + timeZone: 'UTC', // TODO: Events are stored in conference's timezone implicitly (UTC+0) in the database initialDate: fullcalData.data('day'), initialView: 'resourceTimeGridDay', resources: fullcalData.data('rooms'), From d54f6c540c070a86a44d6773877f5bf1f15051e1 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 16:38:35 +0800 Subject: [PATCH 25/36] [fix]Fix Gemfile --- Gemfile | 2 +- Gemfile.lock | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 8627c685..7c1eb7f1 100644 --- a/Gemfile +++ b/Gemfile @@ -27,7 +27,7 @@ gem 'paper_trail' # for upload management gem 'carrierwave' gem 'carrierwave-bombshelter' -gem 'mimemagic', '~> 0.3.6' +gem 'mimemagic' gem 'mini_magick' # for internationalizing diff --git a/Gemfile.lock b/Gemfile.lock index d0f78ee9..d024ba78 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -762,7 +762,6 @@ DEPENDENCIES recaptcha redcarpet responders (~> 2.0) - rexml (~> 3.2) rolify rqrcode rspec-activemodel-mocks From fdfa540a658b1a9abb6acc8310aa723353e6039b Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 16:48:15 +0800 Subject: [PATCH 26/36] [style]Fix style --- spec/services/full_calendar_formatter_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/services/full_calendar_formatter_spec.rb b/spec/services/full_calendar_formatter_spec.rb index 525af045..065527b6 100644 --- a/spec/services/full_calendar_formatter_spec.rb +++ b/spec/services/full_calendar_formatter_spec.rb @@ -63,6 +63,7 @@ describe FullCalendarFormatter do textColor: 'white' } ].to_json + expect(resources).to eq(expected_json) end end From a0e3770dc38ca748d31a875558b8a747bfa42486 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 16:50:18 +0800 Subject: [PATCH 27/36] [feat]Remove All Day in fullcalendar view --- app/assets/javascripts/fullcalendar.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/fullcalendar.js b/app/assets/javascripts/fullcalendar.js index 77e02e2e..c743d342 100644 --- a/app/assets/javascripts/fullcalendar.js +++ b/app/assets/javascripts/fullcalendar.js @@ -4,6 +4,7 @@ $( document ).ready(function() { let fullcalData = $('#fullcalendar'); var calendar = new FullCalendar.Calendar(calendarEl, { + allDaySlot: false, timeZone: 'UTC', // TODO: Events are stored in conference's timezone implicitly (UTC+0) in the database initialDate: fullcalData.data('day'), initialView: 'resourceTimeGridDay', From a35badb2ca463f787b2c2f062f90d430b223079c Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 17:33:16 +0800 Subject: [PATCH 28/36] [feat]Restrict fullcalendar to display time from the start hour to end hour of a conference --- app/assets/javascripts/fullcalendar.js | 3 +++ app/views/schedules/vertical_schedule.haml | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/fullcalendar.js b/app/assets/javascripts/fullcalendar.js index c743d342..1e3b20b3 100644 --- a/app/assets/javascripts/fullcalendar.js +++ b/app/assets/javascripts/fullcalendar.js @@ -4,7 +4,10 @@ $( document ).ready(function() { let fullcalData = $('#fullcalendar'); var calendar = new FullCalendar.Calendar(calendarEl, { + expandRows: true, allDaySlot: false, + slotMinTime: fullcalData.data('startHour') + ':00:00', + slotMaxTime: fullcalData.data('endHour') + ':00:00', timeZone: 'UTC', // TODO: Events are stored in conference's timezone implicitly (UTC+0) in the database initialDate: fullcalData.data('day'), initialView: 'resourceTimeGridDay', diff --git a/app/views/schedules/vertical_schedule.haml b/app/views/schedules/vertical_schedule.haml index ee6c49c5..23747f35 100644 --- a/app/views/schedules/vertical_schedule.haml +++ b/app/views/schedules/vertical_schedule.haml @@ -6,4 +6,5 @@ = @conference.title #vert-schedule-full-calendar - #fullcalendar{ data: { rooms: @rooms, events: @event_schedules, day: @day } } + #fullcalendar{ data: { rooms: @rooms, events: @event_schedules, day: @day, | + 'start-hour': @conference.start_hour, 'end-hour': @conference.end_hour } } From c223959ffbe5a8e9b0b2e241192394a751054c38 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 17:58:52 +0800 Subject: [PATCH 29/36] [feat]Read fullcalendar license key from ENV --- app/assets/javascripts/fullcalendar.js | 1 + app/controllers/schedules_controller.rb | 1 + app/views/schedules/vertical_schedule.haml | 3 ++- config/application.rb | 4 ++++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/fullcalendar.js b/app/assets/javascripts/fullcalendar.js index 1e3b20b3..1bcfc688 100644 --- a/app/assets/javascripts/fullcalendar.js +++ b/app/assets/javascripts/fullcalendar.js @@ -4,6 +4,7 @@ $( document ).ready(function() { let fullcalData = $('#fullcalendar'); var calendar = new FullCalendar.Calendar(calendarEl, { + schedulerLicenseKey: fullcalData.data('schedulerLicenseKey'), expandRows: true, allDaySlot: false, slotMinTime: fullcalData.data('startHour') + ':00:00', diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb index a22ded39..757ac9ad 100644 --- a/app/controllers/schedules_controller.rb +++ b/app/controllers/schedules_controller.rb @@ -94,6 +94,7 @@ class SchedulesController < ApplicationController @rooms = FullCalendarFormatter.rooms_to_resources(@conference.venue.rooms) if @conference.venue @event_schedules = FullCalendarFormatter.event_schedules_to_resources(event_schedules) + @scheduler_license_key = Rails.configuration.fullcalendar[:license_key] end def app diff --git a/app/views/schedules/vertical_schedule.haml b/app/views/schedules/vertical_schedule.haml index 23747f35..11003f85 100644 --- a/app/views/schedules/vertical_schedule.haml +++ b/app/views/schedules/vertical_schedule.haml @@ -7,4 +7,5 @@ #vert-schedule-full-calendar #fullcalendar{ data: { rooms: @rooms, events: @event_schedules, day: @day, | - 'start-hour': @conference.start_hour, 'end-hour': @conference.end_hour } } + 'start-hour': @conference.start_hour, 'end-hour': @conference.end_hour, | + 'scheduler-license-key': @scheduler_license_key } } diff --git a/config/application.rb b/config/application.rb index 4d52dc2c..320e4fd3 100644 --- a/config/application.rb +++ b/config/application.rb @@ -82,5 +82,9 @@ module Osem end config.assets.paths << Rails.root.join('node_modules') + + config.fullcalendar = { + license_key: ENV['FULL_CALENDAR_LICENSE_KEY'] + } end end From ccbc2ed0d59788166776e13e979f1b4e041650c0 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 18:01:33 +0800 Subject: [PATCH 30/36] [style]Fix haml-lint --- app/views/schedules/vertical_schedule.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/schedules/vertical_schedule.haml b/app/views/schedules/vertical_schedule.haml index 11003f85..ac538c0b 100644 --- a/app/views/schedules/vertical_schedule.haml +++ b/app/views/schedules/vertical_schedule.haml @@ -6,6 +6,6 @@ = @conference.title #vert-schedule-full-calendar - #fullcalendar{ data: { rooms: @rooms, events: @event_schedules, day: @day, | - 'start-hour': @conference.start_hour, 'end-hour': @conference.end_hour, | - 'scheduler-license-key': @scheduler_license_key } } + #fullcalendar{ data: { rooms: @rooms, events: @event_schedules, day: @day, + 'start-hour': @conference.start_hour, 'end-hour': @conference.end_hour, + 'scheduler-license-key': @scheduler_license_key } } From 5197ddbe246370ec4954c85db58fab5ade44809a Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 18:59:21 +0800 Subject: [PATCH 31/36] [feat]Add now indicator to fullcalendar --- app/assets/javascripts/fullcalendar.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/fullcalendar.js b/app/assets/javascripts/fullcalendar.js index 1bcfc688..75b64dbf 100644 --- a/app/assets/javascripts/fullcalendar.js +++ b/app/assets/javascripts/fullcalendar.js @@ -5,6 +5,7 @@ $( document ).ready(function() { var calendar = new FullCalendar.Calendar(calendarEl, { schedulerLicenseKey: fullcalData.data('schedulerLicenseKey'), + nowIndicator: true, expandRows: true, allDaySlot: false, slotMinTime: fullcalData.data('startHour') + ':00:00', From 8aaabe4435485d623d62d049af23944eb6d25196 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 19:06:50 +0800 Subject: [PATCH 32/36] [feat]Add valid date range to fullcalendar --- app/assets/javascripts/fullcalendar.js | 4 ++++ app/views/schedules/vertical_schedule.haml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/app/assets/javascripts/fullcalendar.js b/app/assets/javascripts/fullcalendar.js index 75b64dbf..ad054c3f 100644 --- a/app/assets/javascripts/fullcalendar.js +++ b/app/assets/javascripts/fullcalendar.js @@ -10,6 +10,10 @@ $( document ).ready(function() { allDaySlot: false, slotMinTime: fullcalData.data('startHour') + ':00:00', slotMaxTime: fullcalData.data('endHour') + ':00:00', + validRange: { + start: fullcalData.data('startDate'), + end: fullcalData.data('endDate') + }, timeZone: 'UTC', // TODO: Events are stored in conference's timezone implicitly (UTC+0) in the database initialDate: fullcalData.data('day'), initialView: 'resourceTimeGridDay', diff --git a/app/views/schedules/vertical_schedule.haml b/app/views/schedules/vertical_schedule.haml index ac538c0b..b238b1a6 100644 --- a/app/views/schedules/vertical_schedule.haml +++ b/app/views/schedules/vertical_schedule.haml @@ -8,4 +8,6 @@ #vert-schedule-full-calendar #fullcalendar{ data: { rooms: @rooms, events: @event_schedules, day: @day, 'start-hour': @conference.start_hour, 'end-hour': @conference.end_hour, + 'start-date': @conference.start_date, + 'end-date': @conference.end_date + 1.day, 'scheduler-license-key': @scheduler_license_key } } From 66767c33a29fa900a94d32c5ae0fa2c376bf3c93 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 30 Apr 2021 19:19:30 +0800 Subject: [PATCH 33/36] [feat]Change border color of event --- app/services/full_calendar_formatter.rb | 1 + spec/services/full_calendar_formatter_spec.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/services/full_calendar_formatter.rb b/app/services/full_calendar_formatter.rb index 512bb35f..30f504f4 100644 --- a/app/services/full_calendar_formatter.rb +++ b/app/services/full_calendar_formatter.rb @@ -33,6 +33,7 @@ class FullCalendarFormatter end: event_schedule.end_time, resourceId: event_schedule.room.guid, url: url, + borderColor: event_type_color, backgroundColor: event_type_color, textColor: contrast_color(event_type_color) } diff --git a/spec/services/full_calendar_formatter_spec.rb b/spec/services/full_calendar_formatter_spec.rb index 065527b6..0fb1c649 100644 --- a/spec/services/full_calendar_formatter_spec.rb +++ b/spec/services/full_calendar_formatter_spec.rb @@ -49,6 +49,7 @@ describe FullCalendarFormatter do end: event_schedule1.end_time, resourceId: room1.guid, url: Rails.application.routes.url_helpers.conference_program_proposal_path(conference.short_title, event1.id), + borderColor: event1.event_type.color, backgroundColor: event1.event_type.color, textColor: 'black' }, @@ -59,6 +60,7 @@ describe FullCalendarFormatter do end: event_schedule2.end_time, resourceId: room2.guid, url: Rails.application.routes.url_helpers.conference_program_proposal_path(conference.short_title, event2.id), + borderColor: event2.event_type.color, backgroundColor: event2.event_type.color, textColor: 'white' } From 5b06b4d8bb4fe354891a516a3a412d82add60ac8 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 30 Apr 2021 09:56:15 -0700 Subject: [PATCH 34/36] [feat] Prevent license key from being embedded in view --- .../javascripts/{fullcalendar.js => fullcalendar.js.erb} | 4 +++- app/views/schedules/vertical_schedule.haml | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) rename app/assets/javascripts/{fullcalendar.js => fullcalendar.js.erb} (88%) diff --git a/app/assets/javascripts/fullcalendar.js b/app/assets/javascripts/fullcalendar.js.erb similarity index 88% rename from app/assets/javascripts/fullcalendar.js rename to app/assets/javascripts/fullcalendar.js.erb index ad054c3f..8c3af528 100644 --- a/app/assets/javascripts/fullcalendar.js +++ b/app/assets/javascripts/fullcalendar.js.erb @@ -3,8 +3,10 @@ $( document ).ready(function() { if (!calendarEl) return; //check that we need a vertical schedule let fullcalData = $('#fullcalendar'); + let license_key = "<%= Rails.configuration.fullcalendar[:license_key] %>"; + var calendar = new FullCalendar.Calendar(calendarEl, { - schedulerLicenseKey: fullcalData.data('schedulerLicenseKey'), + schedulerLicenseKey: license_key, nowIndicator: true, expandRows: true, allDaySlot: false, diff --git a/app/views/schedules/vertical_schedule.haml b/app/views/schedules/vertical_schedule.haml index b238b1a6..e2ccb27a 100644 --- a/app/views/schedules/vertical_schedule.haml +++ b/app/views/schedules/vertical_schedule.haml @@ -9,5 +9,4 @@ #fullcalendar{ data: { rooms: @rooms, events: @event_schedules, day: @day, 'start-hour': @conference.start_hour, 'end-hour': @conference.end_hour, 'start-date': @conference.start_date, - 'end-date': @conference.end_date + 1.day, - 'scheduler-license-key': @scheduler_license_key } } + 'end-date': @conference.end_date + 1.day } } From bc115d6f902b827c2a812a2aab498a27ccc0cf38 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sat, 1 May 2021 01:37:52 +0800 Subject: [PATCH 35/36] [feat]Properly add timezone to events starttime and endtime; set now to be the time in conference timezone instead of the user s time zone in fullcalendar --- app/assets/javascripts/fullcalendar.js | 3 ++- app/controllers/schedules_controller.rb | 1 + app/models/event_schedule.rb | 14 ++++++++++++++ app/services/full_calendar_formatter.rb | 4 ++-- app/views/schedules/vertical_schedule.haml | 4 ++-- spec/services/full_calendar_formatter_spec.rb | 8 ++++---- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/fullcalendar.js b/app/assets/javascripts/fullcalendar.js index ad054c3f..3a0d88ac 100644 --- a/app/assets/javascripts/fullcalendar.js +++ b/app/assets/javascripts/fullcalendar.js @@ -6,6 +6,7 @@ $( document ).ready(function() { var calendar = new FullCalendar.Calendar(calendarEl, { schedulerLicenseKey: fullcalData.data('schedulerLicenseKey'), nowIndicator: true, + now: fullcalData.data('now'), expandRows: true, allDaySlot: false, slotMinTime: fullcalData.data('startHour') + ':00:00', @@ -14,7 +15,7 @@ $( document ).ready(function() { start: fullcalData.data('startDate'), end: fullcalData.data('endDate') }, - timeZone: 'UTC', // TODO: Events are stored in conference's timezone implicitly (UTC+0) in the database + timeZone: fullcalData.data('timezone'), initialDate: fullcalData.data('day'), initialView: 'resourceTimeGridDay', resources: fullcalData.data('rooms'), diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb index 757ac9ad..3ada7d70 100644 --- a/app/controllers/schedules_controller.rb +++ b/app/controllers/schedules_controller.rb @@ -94,6 +94,7 @@ class SchedulesController < ApplicationController @rooms = FullCalendarFormatter.rooms_to_resources(@conference.venue.rooms) if @conference.venue @event_schedules = FullCalendarFormatter.event_schedules_to_resources(event_schedules) + @now = Time.now.in_time_zone(@conference.timezone).strftime('%FT%T%:z') @scheduler_license_key = Rails.configuration.fullcalendar[:license_key] end diff --git a/app/models/event_schedule.rb b/app/models/event_schedule.rb index f8a41d64..7be7a7d2 100644 --- a/app/models/event_schedule.rb +++ b/app/models/event_schedule.rb @@ -133,6 +133,14 @@ class EventSchedule < ApplicationRecord other.schedule_id == schedule_id end + def start_time_in_conference_timezone + time_in_conference_timezone(start_time) + end + + def end_time_in_conference_timezone + time_in_conference_timezone(end_time) + end + private def replaced_event_schedules @@ -187,4 +195,10 @@ class EventSchedule < ApplicationRecord errors.add(:schedule, "must be one of #{event.track.name} track's schedules") unless event.track.schedules.include?(schedule) end + + def time_in_conference_timezone(time) + time_in_tz = time.in_time_zone(timezone) + time_in_tz -= time_in_tz.utc_offset + time_in_tz + end end diff --git a/app/services/full_calendar_formatter.rb b/app/services/full_calendar_formatter.rb index 30f504f4..499b8e04 100644 --- a/app/services/full_calendar_formatter.rb +++ b/app/services/full_calendar_formatter.rb @@ -29,8 +29,8 @@ class FullCalendarFormatter { id: event_schedule.event.guid, title: event_schedule.event.title, - start: event_schedule.start_time, - end: event_schedule.end_time, + start: event_schedule.start_time_in_conference_timezone, + end: event_schedule.end_time_in_conference_timezone, resourceId: event_schedule.room.guid, url: url, borderColor: event_type_color, diff --git a/app/views/schedules/vertical_schedule.haml b/app/views/schedules/vertical_schedule.haml index b238b1a6..6e8be368 100644 --- a/app/views/schedules/vertical_schedule.haml +++ b/app/views/schedules/vertical_schedule.haml @@ -8,6 +8,6 @@ #vert-schedule-full-calendar #fullcalendar{ data: { rooms: @rooms, events: @event_schedules, day: @day, 'start-hour': @conference.start_hour, 'end-hour': @conference.end_hour, - 'start-date': @conference.start_date, - 'end-date': @conference.end_date + 1.day, + 'start-date': @conference.start_date, 'end-date': @conference.end_date + 1.day, + 'timezone': @conference.timezone, 'now': @now, 'scheduler-license-key': @scheduler_license_key } } diff --git a/spec/services/full_calendar_formatter_spec.rb b/spec/services/full_calendar_formatter_spec.rb index 0fb1c649..63af2d08 100644 --- a/spec/services/full_calendar_formatter_spec.rb +++ b/spec/services/full_calendar_formatter_spec.rb @@ -45,8 +45,8 @@ describe FullCalendarFormatter do { id: event_schedule1.event.guid, title: event_schedule1.event.title, - start: event_schedule1.start_time, - end: event_schedule1.end_time, + start: event_schedule1.start_time_in_conference_timezone, + end: event_schedule1.end_time_in_conference_timezone, resourceId: room1.guid, url: Rails.application.routes.url_helpers.conference_program_proposal_path(conference.short_title, event1.id), borderColor: event1.event_type.color, @@ -56,8 +56,8 @@ describe FullCalendarFormatter do { id: event_schedule2.event.guid, title: event_schedule2.event.title, - start: event_schedule2.start_time, - end: event_schedule2.end_time, + start: event_schedule2.start_time_in_conference_timezone, + end: event_schedule2.end_time_in_conference_timezone, resourceId: room2.guid, url: Rails.application.routes.url_helpers.conference_program_proposal_path(conference.short_title, event2.id), borderColor: event2.event_type.color, From 3a3619cb521384249938a43a50adffe25d701277 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sat, 1 May 2021 01:46:06 +0800 Subject: [PATCH 36/36] [fix]Remove license key in schedules_controller --- app/controllers/schedules_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb index 3ada7d70..e0c5f911 100644 --- a/app/controllers/schedules_controller.rb +++ b/app/controllers/schedules_controller.rb @@ -95,7 +95,6 @@ class SchedulesController < ApplicationController @rooms = FullCalendarFormatter.rooms_to_resources(@conference.venue.rooms) if @conference.venue @event_schedules = FullCalendarFormatter.event_schedules_to_resources(event_schedules) @now = Time.now.in_time_zone(@conference.timezone).strftime('%FT%T%:z') - @scheduler_license_key = Rails.configuration.fullcalendar[:license_key] end def app