Skip to content

Commit 573fe45

Browse files
JeremyRudmancbaudouinjrpeterkos
authored
feat: Adds event calendar support (#259)
* build(deps): Upgrade yarn * build(deps): Upgrade gems * build(deps): Remove obsolete gems * v0.0.0 * build(deps): Update semantic-release * feat(events): add upcoming events page made a page to to view upcoming events in the management tools * feat(events): added page to make new events * added gem.lock * functionally complete calendar calendar has all the features needed need to make it less janky and possible add/remove features based on feedback * feat(events):page to view and make upcoming events created a page to view, make, and delete events. These events contain a title, description, location, owner(s), if it is a public and/or all day event and when it starts and stops. * fix: corrected formating errors and removed all day option made the code comply with houndci-bot requests and removed the all day bool for a event * fix: removed left over allDay refernce * fix: corrected houndci format suggestion * feat(event): added owners as a list of admins only implemented owners in a similar way to message recipients it will only allow for the selection of admin user as the owner(s) of a event. No owners it also allowed. * fix(events): refactored to work with latest 2.0 altered new manage sidebar to include events and fixed bug in event model testing * Fixed issue on desktop * feat(event): removed unneeded form options removed owner and public options from event creation form since they are no longer relevent for the intended purpose of this schedule * Map overflow scroll Signed-off-by: Peter Kos <[email protected]> * Fix scroll issue Signed-off-by: Peter Kos <[email protected]> * Fixed toggle button; fits screen, sidebar width Sidebar width is better Toggle button fills height of navbar Signed-off-by: Peter Kos <[email protected]> * fix: Allows optional assets to be unset * fix(events):added basic testing added the basic tests and renamed "end" to "finish" in event * Fixes test * fix(event): tweak test in attempt to get working * fix(event): got testing to work for some reason there is a flow for how redirects works for a controller. The index goes to the correct redirect but the create does not. * fix(event): fix hound errors and db password error accidently pushed local db password and corrected hound errors * fix(event): fix houndci error i missed * feat: Redesigns OAuth2 portal (#404) * feat: Redesigns OAuth2 portal * fix: Some Hound issues * Changes application verbiage * Fixes ID issue * Fixes table link and sign out button * Peter's wishes * Adds Redis dump files to .gitignore * fix(event): fixed some of the pull request suggestions * Shorten form :) Signed-off-by: Peter Kos <[email protected]> * fix(forms): change size of all forms without textbox changed the style of all forms that don't have a large text area or other aspects of the form that make a full length form perferable. With the exception of those forms all forms are now more narrow * fix(event): implemented pull request changes fixed cancel button and removed blue dot in list. decided to use simple form datetime picker instead of html datetime-local input because firefox does not support it. * fix: Fixes MyMLH branding in config (#412) * feat(settings): Simplifies Config (#409) * feat(settings): Simplifies Config * Resolves Hound issues * Update app/views/manage/configs/index.html.haml Co-authored-by: Peter Kos <[email protected]> * design: Increases the font-weight and reorganizes the page * fix: Hound issues Co-authored-by: Peter Kos <[email protected]> * feat: Adds support for digital-only hackathons (#395) * feat: Adds support for digital-only hackathons * fix: Provides clarity for what is removed from digital hackathons Co-authored-by: Peter Kos <[email protected]> * event(fix): renamed events to schedule and reverted forms change event to schedule on the mangage sidebar and undid change to forms * feat: Adds GitHub Action for releases (#426) * feat: Adds GitHub Action CI testing (#423) * feat: Adds GitHub Action CI testing * fix: Adds sudo * refactor: Changes naming * Removes travis.yml * docs: Adds ruby version comment * fix(event): schedule now shows end time do to issues with "end" being a keyword in rails and what fullcalendar uses for events ending end time was previously not showing up * fix(event): fix houndci complaints * bundle install * fixed styling errors and added check for finish and start time * made finish time optional and made css fixes * fix houndci complaint * fix houndci complaint part 2 * removed finish time requirement in test Co-authored-by: Chris Baudouin, Jr <[email protected]> Co-authored-by: Chris Baudouin, Jr <[email protected]> Co-authored-by: Peter Kos <[email protected]>
1 parent ae6ade0 commit 573fe45

38 files changed

+444
-12
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ gem 'jquery-ui-rails'
6565
gem 'selectize-rails'
6666
gem 'highcharts-rails', '~> 6.0'
6767
gem 'bootstrap', '~> 4.3.1'
68+
gem 'fullcalendar-rails'
69+
gem 'momentjs-rails'
6870

6971
# Markdown parsing
7072
gem 'redcarpet'

Gemfile.lock

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ GEM
129129
dotenv (= 2.7.5)
130130
railties (>= 3.2, < 6.1)
131131
errbase (0.2.0)
132-
erubi (1.9.0)
132+
erubi (1.10.0)
133133
erubis (2.7.0)
134134
et-orbi (1.2.4)
135135
tzinfo
@@ -152,6 +152,10 @@ GEM
152152
fugit (1.3.6)
153153
et-orbi (~> 1.1, >= 1.1.8)
154154
raabro (~> 1.3)
155+
fullcalendar-rails (3.9.0.0)
156+
jquery-rails (>= 4.0.5, < 5.0.0)
157+
jquery-ui-rails (>= 5.0.2)
158+
momentjs-rails (>= 2.9.0)
155159
globalid (0.4.2)
156160
activesupport (>= 4.2.0)
157161
groupdate (5.0.0)
@@ -205,7 +209,7 @@ GEM
205209
rb-fsevent (~> 0.9, >= 0.9.4)
206210
rb-inotify (~> 0.9, >= 0.9.7)
207211
ruby_dep (~> 1.2)
208-
loofah (2.7.0)
212+
loofah (2.8.0)
209213
crass (~> 1.0.2)
210214
nokogiri (>= 1.5.9)
211215
lumberjack (1.2.6)
@@ -226,14 +230,16 @@ GEM
226230
builder
227231
minitest (>= 5.0)
228232
ruby-progressbar
233+
momentjs-rails (2.20.1)
234+
railties (>= 3.1)
229235
msgpack (1.3.3)
230236
multi_json (1.15.0)
231237
multi_xml (0.6.0)
232238
multipart-post (2.1.1)
233239
mustache (1.1.1)
234240
mysql2 (0.5.3)
235241
nenv (0.3.0)
236-
nio4r (2.5.3)
242+
nio4r (2.5.4)
237243
nokogiri (1.10.10)
238244
mini_portile2 (~> 2.4.0)
239245
notiffany (0.1.3)
@@ -386,7 +392,7 @@ GEM
386392
sprockets (4.0.2)
387393
concurrent-ruby (~> 1.0)
388394
rack (> 1, < 3)
389-
sprockets-rails (3.2.1)
395+
sprockets-rails (3.2.2)
390396
actionpack (>= 4.0)
391397
activesupport (>= 4.0)
392398
sprockets (>= 3.0.0)
@@ -402,7 +408,7 @@ GEM
402408
turbolinks (5.2.1)
403409
turbolinks-source (~> 5.2)
404410
turbolinks-source (5.2.0)
405-
tzinfo (1.2.7)
411+
tzinfo (1.2.8)
406412
thread_safe (~> 0.1)
407413
uglifier (4.2.0)
408414
execjs (>= 0.3.0, < 3)
@@ -451,6 +457,7 @@ DEPENDENCIES
451457
factory_bot_rails
452458
file_validators
453459
font-awesome-rails (~> 4.0)
460+
fullcalendar-rails
454461
groupdate
455462
guard
456463
guard-minitest
@@ -461,6 +468,7 @@ DEPENDENCIES
461468
jquery-ui-rails
462469
listen (>= 3.0.5, < 3.2)
463470
minitest-reporters
471+
momentjs-rails
464472
mustache (~> 1.0)
465473
mysql2 (>= 0.4.4, < 0.6.0)
466474
omniauth-mlh (~> 0.4.1)

app/assets/javascripts/application.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@
2121
//= require_directory .
2222
//= require_directory ./channels
2323
//= require ./vendor/simplemde.min.js
24+
//= require moment
25+
//= require fullcalendar
26+
//= require fullcalendar/locale-all

app/assets/javascripts/events.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
function eventCalendar() {
2+
return $('#calendar').fullCalendar({
3+
defaultView: 'listYear',
4+
buttonText: {
5+
today: 'Today'
6+
},
7+
eventRender: function (event, element, view) {
8+
var description = event.description ? event.description : '';
9+
var location = event.location ? event.location : '';
10+
element.find('.fc-event-dot').css('display','none');
11+
element.find('.fc-list-item-title').append('<div></div><span style="font-size: 12px">' + description + '</span>');
12+
element.find('.fc-list-item-title').append('<div></div><span style="font-size: 12px">' + location + '</span>');
13+
},
14+
events: {
15+
url: '/manage/events.json',
16+
success: function(response) {
17+
// due to "end" being a keyword in ruby and what fullcalender uses it is stored as finish and than it is
18+
// converted to "end" when sending it to fullcalendar
19+
response = JSON.parse(JSON.stringify(response).split('"finish":').join('"end":'));
20+
return response;
21+
}
22+
},
23+
eventClick: function (info) {
24+
window.location = 'events/' + info.id;
25+
},
26+
height: 'auto',
27+
});
28+
}
29+
30+
function clearCalendar() {
31+
$('#calendar').fullCalendar('delete');
32+
$('#calendar').html('');
33+
}
34+
35+
document.addEventListener('turbolinks:load', function () {
36+
eventCalendar();
37+
});
38+
document.addEventListener('turbolinks:before-cache', clearCalendar);

app/assets/stylesheets/manage.sass

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@import general/variables
77
@import general/css4
88
@import manage/autocomplete
9+
@import manage/events
910

1011
$grey-dark: #555
1112
$grey-med: #999
@@ -15,6 +16,7 @@ $grey-med: #999
1516
@import vendor/datatables.min
1617
@import selectize
1718
@import selectize.default
19+
@import fullcalendar
1820

1921
.icon-space-r
2022
margin-right: 0.5em
@@ -137,6 +139,10 @@ $grey-med: #999
137139
height: calc(100vh - 2.25rem)
138140
overflow: scroll
139141

142+
.calendar-list
143+
width: 100%
144+
min-width: 500px
145+
margin: auto
140146

141147
/*
142148
* Datatable changes
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.fc-list-item
2+
cursor: pointer !important
3+
4+
.event_start select:first-child, .event_finish select:first-child
5+
margin-left: 0 !important
6+
7+
.event_start select:last-child, .event_finish select:last-child
8+
margin-right: 0 !important
9+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
class Manage::EventsController < Manage::ApplicationController
2+
before_action :require_director
3+
respond_to :html, :json
4+
5+
def index
6+
@start_date = HackathonConfig['event_start_date']
7+
respond_to do |format|
8+
format.html
9+
format.json { render json: Event.all }
10+
end
11+
end
12+
13+
def new
14+
@event = ::Event.new
15+
end
16+
17+
def create
18+
@event = ::Event.new(event_params)
19+
if @event.save
20+
redirect_to(manage_events_path)
21+
else
22+
render('new')
23+
end
24+
end
25+
26+
def show
27+
@event = Event.find_by_id(params[:id])
28+
respond_with(:manage, @event)
29+
end
30+
31+
def update
32+
@event = Event.find_by_id(params[:id])
33+
if @event.update(event_params)
34+
redirect_to(manage_events_path)
35+
else
36+
render('show')
37+
end
38+
end
39+
40+
def destroy
41+
@event = Event.find_by_id(params[:id])
42+
if @event.destroy
43+
redirect_to(manage_events_path)
44+
else
45+
render('show')
46+
end
47+
end
48+
49+
def event_params
50+
params.require(:event).permit(
51+
:title, :description, :location, :public, :start, :finish, owner: []
52+
)
53+
end
54+
end

app/models/event.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Event < ApplicationRecord
2+
validates_presence_of :title, :start
3+
4+
validate :finish_before_start
5+
6+
def finish_before_start
7+
return if finish.nil?
8+
unless finish > start
9+
errors.add(:finish, 'time must be after start time')
10+
end
11+
end
12+
end

app/views/layouts/manage/application.html.haml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
= active_link_to manage_checkins_path, class: "nav-link" do
6969
.fa.fa-drivers-license-o.fa-fw.icon-space-r-half
7070
= t(:title, scope: 'pages.manage.check-in')
71+
%li.nav-item
72+
= active_link_to manage_events_path, class: "nav-link" do
73+
.fa.fa-calendar.fa-fw.icon-space-r-half
74+
= t(:title, scope: 'pages.manage.events')
7175
%li.nav-item
7276
= active_link_to manage_stats_path, class: "nav-link" do
7377
.fa.fa-table.fa-fw.icon-space-r-half
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
.form-container
22
= bs_horizontal_simple_form_for @data_export, url: url_for(action: @data_export.new_record? ? "create" : "update", controller: "data_exports") do |f|
33
= f.error_notification
4-
5-
.form-inputs
6-
= f.input :export_type, as: :select, collection: DataExport::POSSIBLE_TYPES.map { |x| [x.titleize, x] }, include_blank: false
7-
8-
.form-actions.mb-3.mt-3
9-
= f.button :submit, class: 'btn-primary'
4+
.form-inputs
5+
= f.input :export_type, as: :select, collection: DataExport::POSSIBLE_TYPES.map { |x| [x.titleize, x] }, include_blank: false
6+
.form-actions.mb-3.mt-3
7+
= f.button :submit, class: 'btn-primary'
108

119
.mb-4

0 commit comments

Comments
 (0)