Skip to content

Commit ecd1fb4

Browse files
JeremyRudmancbaudouinjrpeterkos
authored
feat(schedule): add category field to schedule (#546)
* feat(schedule): add category field to schedule * moved event catorgory addition to a seprate migration * add category and location label for schedule display * made label more semantically nice * more code cleanup for events * Update app/assets/javascripts/events.js Co-authored-by: Peter Kos <[email protected]> Co-authored-by: Chris Baudouin, Jr <[email protected]> Co-authored-by: Peter Kos <[email protected]>
1 parent 493813f commit ecd1fb4

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

app/assets/javascripts/events.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@ function eventCalendar() {
55
today: 'Today'
66
},
77
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>');
8+
element.find('.fc-event-dot').css('display', 'none');
9+
if(event.description) {
10+
element.find('.fc-list-item-title').append('<div></div><span style="font-size: 12px">' + event.description + '</span>');
11+
}
12+
if (event.location) {
13+
element.find('.fc-list-item-title').append('<div></div><span style="font-size: 12px"><b>Location: </b>' + event.location + '</span>');
14+
}
15+
if (event.category) {
16+
element.find('.fc-list-item-title').append('<div></div><span style="font-size: 12px"><b>Category: </b>' + event.category + '</span>');
17+
}
1318
},
1419
events: {
1520
url: '/manage/events.json',
16-
success: function(response) {
21+
success: function (response) {
1722
// due to "end" being a keyword in ruby and what fullcalender uses it is stored as finish and than it is
1823
// converted to "end" when sending it to fullcalendar
1924
response = JSON.parse(JSON.stringify(response).split('"finish":').join('"end":'));

app/controllers/manage/events_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def destroy
4848

4949
def event_params
5050
params.require(:event).permit(
51-
:title, :description, :location, :public, :start, :finish, owner: []
51+
:title, :description, :location, :category, :start, :finish
5252
)
5353
end
5454
end

app/views/manage/events/_form.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
= f.input :title
55
= f.input :description
66
= f.input :location
7+
= f.input :category
78
= f.input :start
89
= f.input :finish, include_blank: true
910
.center
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddCategoryToEvents < ActiveRecord::Migration[5.2]
2+
def change
3+
add_column :events, :category, :string
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2020_12_18_010133) do
13+
ActiveRecord::Schema.define(version: 2021_01_28_025749) do
1414

1515
create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
1616
t.string "name", null: false
@@ -148,6 +148,7 @@
148148
t.datetime "finish"
149149
t.datetime "created_at", null: false
150150
t.datetime "updated_at", null: false
151+
t.string "category"
151152
end
152153

153154
create_table "fips", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|

0 commit comments

Comments
 (0)