date_book 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -1
- data/.rubocop_todo.yml +2 -1
- data/.travis.yml +3 -0
- data/Gemfile +16 -4
- data/Gemfile.lock +14 -2
- data/VERSION +1 -1
- data/app/assets/javascripts/date_book/calendar_events.js +3 -3
- data/app/assets/stylesheets/date_book.css.scss +31 -2
- data/app/controllers/date_book/calendars_controller.rb +30 -19
- data/app/controllers/date_book/date_book_controller.rb +1 -1
- data/app/controllers/date_book/events_controller.rb +60 -62
- data/app/controllers/date_book/graphql_controller.rb +10 -11
- data/app/graphql/date_book_schema.rb +4 -4
- data/app/graphql/types/calendar_type.rb +4 -2
- data/app/graphql/types/date_time_type.rb +9 -5
- data/app/graphql/types/event_occurrence_type.rb +4 -2
- data/app/graphql/types/event_type.rb +4 -2
- data/app/graphql/types/mutation_type.rb +3 -1
- data/app/graphql/types/query_type.rb +12 -26
- data/app/helpers/date_book/application_helper.rb +4 -7
- data/app/helpers/date_book/events_helper.rb +43 -23
- data/app/views/date_book/application/_date_range.html.haml +3 -3
- data/app/views/date_book/calendars/index.html.haml +19 -3
- data/app/views/date_book/calendars/show.html.haml +29 -4
- data/app/views/date_book/events/_event.json.jbuilder +3 -1
- data/app/views/date_book/events/_form.html.haml +4 -4
- data/app/views/date_book/events/_occurrence_dates.html.haml +3 -3
- data/app/views/date_book/events/fields/_date.html.haml +1 -1
- data/app/views/date_book/events/fields/_day.html.haml +1 -1
- data/app/views/date_book/events/fields/_day_of_week.html.haml +3 -3
- data/app/views/date_book/events/fields/_duration.html.haml +3 -3
- data/app/views/date_book/events/fields/_interval.html.haml +1 -1
- data/app/views/date_book/events/fields/_time.html.haml +1 -1
- data/app/views/date_book/events/index.html.haml +1 -1
- data/app/views/date_book/events/rules/_daily.html.haml +3 -3
- data/app/views/date_book/events/rules/_monthly.html.haml +4 -4
- data/app/views/date_book/events/rules/_singular.html.haml +3 -3
- data/app/views/date_book/events/rules/_weekly.html.haml +4 -4
- data/app/views/date_book/events/show.html.haml +1 -1
- data/app/views/layouts/_date_book_scripts.html.haml +2 -4
- data/config/locales/en.yml +2 -0
- data/config/routes.rb +1 -1
- data/date_book.gemspec +25 -22
- data/db/migrate/20170807133845_create_calendars.rb +3 -0
- data/db/migrate/20170807133846_create_events.rb +3 -0
- data/db/migrate/20170807133847_create_schedules.rb +9 -6
- data/db/migrate/20170807133848_add_fields_to_schedule.rb +3 -0
- data/db/migrate/20170807133849_create_event_occurrences.rb +4 -3
- data/db/migrate/20170807133850_add_fields_to_event_occurrences.rb +3 -0
- data/lib/date_book.rb +11 -2
- data/lib/date_book/concerns/ability.rb +9 -12
- data/lib/date_book/concerns/acts_as_calendar.rb +5 -6
- data/lib/date_book/concerns/acts_as_event.rb +30 -9
- data/lib/date_book/concerns/acts_as_event_occurrence.rb +21 -9
- data/lib/date_book/concerns/acts_as_ownable.rb +9 -3
- data/lib/date_book/concerns/acts_as_owner.rb +5 -6
- data/lib/date_book/concerns/acts_as_schedule.rb +14 -7
- data/lib/date_book/configuration.rb +14 -11
- data/lib/date_book/engine.rb +7 -5
- data/lib/date_book/version.rb +2 -0
- data/lib/generators/date_book/install/install_generator.rb +27 -29
- data/lib/generators/date_book/install/templates/app/models/calendar.rb +4 -1
- data/lib/generators/date_book/install/templates/app/models/event.rb +4 -1
- data/lib/generators/date_book/install/templates/app/models/event_occurrence.rb +4 -1
- data/lib/generators/date_book/install/templates/app/models/schedule.rb +4 -1
- data/spec/abilities/event_spec.rb +1 -1
- data/spec/controllers/date_book/calendars_controller_spec.rb +48 -20
- data/spec/controllers/date_book/events_controller_spec.rb +145 -39
- data/spec/dummy/app/models/calendar.rb +3 -1
- data/spec/dummy/app/models/event.rb +3 -1
- data/spec/dummy/app/models/event_occurrence.rb +3 -1
- data/spec/dummy/app/models/role.rb +7 -5
- data/spec/dummy/app/models/schedule.rb +3 -1
- data/spec/dummy/app/models/user.rb +3 -3
- data/spec/dummy/config/initializers/devise.rb +61 -40
- data/spec/dummy/config/initializers/high_voltage.rb +2 -0
- data/spec/dummy/config/initializers/rolify.rb +5 -2
- data/spec/dummy/config/routes.rb +6 -9
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20170728171103_create_users_table.rb +2 -0
- data/spec/dummy/db/migrate/20170807134122_add_devise_to_users.rb +4 -3
- data/spec/dummy/db/migrate/20170807134128_rolify_create_roles.rb +6 -4
- data/spec/dummy/db/migrate/{20170808150915_create_calendars.date_book.rb → 20170808200808_create_calendars.date_book.rb} +3 -0
- data/spec/dummy/db/migrate/{20170808150916_create_events.date_book.rb → 20170808200809_create_events.date_book.rb} +3 -0
- data/spec/dummy/db/migrate/{20170808150917_create_schedules.date_book.rb → 20170808200810_create_schedules.date_book.rb} +9 -6
- data/spec/dummy/db/migrate/{20170808150918_add_fields_to_schedule.date_book.rb → 20170808200811_add_fields_to_schedule.date_book.rb} +3 -0
- data/spec/dummy/db/migrate/{20170808150919_create_event_occurrences.date_book.rb → 20170808200812_create_event_occurrences.date_book.rb} +4 -3
- data/spec/dummy/db/migrate/{20170808150920_add_fields_to_event_occurrences.date_book.rb → 20170808200813_add_fields_to_event_occurrences.date_book.rb} +3 -0
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/dummy/db/seeds/calendars.seeds.rb +2 -1
- data/spec/dummy/db/seeds/events.seeds.rb +5 -5
- data/spec/dummy/db/seeds/users.seeds.rb +3 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/basic_benchmark.rb +2 -0
- data/spec/factories/calendars.rb +2 -0
- data/spec/factories/events.rb +2 -0
- data/spec/factories/roles.rb +2 -1
- data/spec/factories/users.rb +2 -0
- data/spec/features/calendars_spec.rb +47 -5
- data/spec/features/events_spec.rb +35 -9
- data/spec/helpers/date_book/application_helper_spec.rb +32 -0
- data/spec/helpers/date_book/events_helper_spec.rb +181 -13
- data/spec/models/calendar_spec.rb +3 -1
- data/spec/models/event_spec.rb +3 -1
- data/spec/models/role_spec.rb +1 -0
- data/spec/rails_helper.rb +6 -1
- data/spec/requests/date_book/api_spec.rb +76 -0
- data/spec/routing/date_book/calendars_routing_spec.rb +4 -2
- data/spec/routing/date_book/events_routing_spec.rb +48 -11
- data/spec/support/controller_behaviors.rb +2 -0
- data/spec/support/controller_macros.rb +3 -1
- data/spec/support/factory_girl.rb +2 -0
- data/spec/support/feature_behaviors.rb +9 -9
- data/spec/support/loaded_site.rb +2 -0
- data/spec/support/loaded_site/calendars.rb +2 -0
- data/spec/support/loaded_site/events.rb +3 -1
- data/spec/support/loaded_site/users.rb +2 -0
- data/spec/support/request_behaviors.rb +12 -63
- data/spec/support/shared_connection.rb +2 -0
- data/spec/support/utilities.rb +6 -5
- metadata +79 -42
- data/app/graphql/types/profile_type.rb +0 -7
- data/app/helpers/date_book/calendar_helper.rb +0 -4
- data/app/views/date_book/application/_all_day_checkbox.html.haml +0 -1
- data/bin/rails +0 -15
- data/spec/helpers/date_book/calendar_helper_spec.rb +0 -17
- data/spec/requests/date_book/events_spec.rb +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30d824b967dd697a492168690a853b36cfd8ab7c
|
4
|
+
data.tar.gz: a94fea678e79260b094c8e7380a45731bb97058e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 360b7ebf587e9b749089338d791d3b0724504b2bb1b7735220cf2b33f3337422e70ef650e4d64953ddd4802f90adeaa7287a7a449b4b4f06f1a843f71752edba
|
7
|
+
data.tar.gz: 5fa3b492c6337a37a1447e2f421853846b29b874ce6e71bf312415b18ec15c09dda56b7d14d19cb8378b84967248cc1bd252f0554972744f47fc04194ebb0a5b
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2017-
|
3
|
+
# on 2017-08-08 17:08:12 -0600 using RuboCop version 0.49.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -29,6 +29,9 @@ gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47'
|
|
29
29
|
# Haml because I like it
|
30
30
|
gem 'haml-rails', '>= 1.0', '< 2'
|
31
31
|
|
32
|
+
# Sass for smart CSS
|
33
|
+
gem 'sass-rails', '>= 5.0', '< 6'
|
34
|
+
|
32
35
|
# Jbuilder for easy building of json objects
|
33
36
|
gem 'jbuilder'
|
34
37
|
|
@@ -46,14 +49,23 @@ gem 'friendly_id', '>= 5.2', '< 6'
|
|
46
49
|
|
47
50
|
# Ice Cube and Schedulable for recurrence and scheduling
|
48
51
|
gem 'ice_cube', '>= 0.16', '< 1'
|
49
|
-
|
50
|
-
|
52
|
+
gem(
|
53
|
+
'schedulable',
|
54
|
+
'>= 0.0.10',
|
55
|
+
'< 1',
|
56
|
+
git: 'https://github.com/gemvein/schedulable.git',
|
57
|
+
branch: 'working'
|
58
|
+
)
|
59
|
+
# gem 'schedulable', '>= 0.0.10', '< 1', path: '~/Code/schedulable'
|
51
60
|
# gem 'schedulable', '>= 0.0.10', '< 1'
|
52
61
|
|
53
62
|
# Full Calendar to display what we've got
|
54
63
|
gem 'fullcalendar-rails', '>= 3.4', '< 4'
|
55
64
|
gem 'momentjs-rails', '>= 2.9', '< 3'
|
56
65
|
|
66
|
+
# More icons, like the spinner
|
67
|
+
gem 'font-awesome-rails', '>= 4.7', '< 5'
|
68
|
+
|
57
69
|
# GraphQL for the API
|
58
70
|
gem 'graphql', '>= 1.6', '< 2'
|
59
71
|
|
@@ -64,8 +76,8 @@ group :development do
|
|
64
76
|
gem 'bundler', '~> 1.0'
|
65
77
|
gem 'juwelier', '~> 2.4'
|
66
78
|
# gem 'rspec', '>= 3.5', '< 4'
|
67
|
-
gem 'rubocop', require: false
|
68
79
|
gem 'graphiql-rails', '>= 1.4', '< 2'
|
80
|
+
gem 'rubocop', require: false
|
69
81
|
end
|
70
82
|
|
71
83
|
group :development, :test do
|
@@ -73,11 +85,11 @@ group :development, :test do
|
|
73
85
|
gem 'byebug', '~> 9'
|
74
86
|
gem 'factory_girl_rails', '~> 4.5'
|
75
87
|
gem 'faker', '~> 1.4'
|
88
|
+
gem 'high_voltage', '~> 3'
|
76
89
|
gem 'rspec-its', '>= 1'
|
77
90
|
gem 'rspec-rails', '>= 3.5', '< 4'
|
78
91
|
gem 'seedbank', '~> 0.3'
|
79
92
|
gem 'sqlite3', '~> 1.3'
|
80
|
-
gem 'high_voltage', '~> 3'
|
81
93
|
end
|
82
94
|
|
83
95
|
group :test do
|
data/Gemfile.lock
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
remote:
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/gemvein/schedulable.git
|
3
|
+
revision: 9da6591769c9e488afc537dc3747304125be64ab
|
4
|
+
branch: working
|
3
5
|
specs:
|
4
6
|
schedulable (0.0.10)
|
5
7
|
ice_cube
|
@@ -110,6 +112,8 @@ GEM
|
|
110
112
|
faraday (0.9.2)
|
111
113
|
multipart-post (>= 1.2, < 3)
|
112
114
|
ffi (1.9.18)
|
115
|
+
font-awesome-rails (4.7.0.2)
|
116
|
+
railties (>= 3.2, < 5.2)
|
113
117
|
friendly_id (5.2.1)
|
114
118
|
activerecord (>= 4.0.0)
|
115
119
|
fullcalendar-rails (3.4.0.0)
|
@@ -297,6 +301,12 @@ GEM
|
|
297
301
|
sass-listen (4.0.0)
|
298
302
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
299
303
|
rb-inotify (~> 0.9, >= 0.9.7)
|
304
|
+
sass-rails (5.0.6)
|
305
|
+
railties (>= 4.0.0, < 6)
|
306
|
+
sass (~> 3.1)
|
307
|
+
sprockets (>= 2.8, < 4.0)
|
308
|
+
sprockets-rails (>= 2.0, < 4.0)
|
309
|
+
tilt (>= 1.1, < 3)
|
300
310
|
seedbank (0.4.0)
|
301
311
|
semver2 (3.4.2)
|
302
312
|
sexp_processor (4.10.0)
|
@@ -352,6 +362,7 @@ DEPENDENCIES
|
|
352
362
|
devise (>= 4.3, < 5)
|
353
363
|
factory_girl_rails (~> 4.5)
|
354
364
|
faker (~> 1.4)
|
365
|
+
font-awesome-rails (>= 4.7, < 5)
|
355
366
|
friendly_id (>= 5.2, < 6)
|
356
367
|
fullcalendar-rails (>= 3.4, < 4)
|
357
368
|
graphiql-rails (>= 1.4, < 2)
|
@@ -376,6 +387,7 @@ DEPENDENCIES
|
|
376
387
|
rspec-its (>= 1)
|
377
388
|
rspec-rails (>= 3.5, < 4)
|
378
389
|
rubocop
|
390
|
+
sass-rails (>= 5.0, < 6)
|
379
391
|
schedulable (>= 0.0.10, < 1)!
|
380
392
|
seedbank (~> 0.3)
|
381
393
|
shoulda-matchers (>= 2.8, < 3.2)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
@@ -1,11 +1,11 @@
|
|
1
1
|
function calendarBySlugQuery(slug) {
|
2
2
|
// GraphQL requires double-quoted strings in the query:
|
3
|
-
return(' { calendar(slug: "' + slug + '") { event_occurrences { url, popover_url, start, end, event {id, name,
|
3
|
+
return(' { calendar(slug: "' + slug + '") { event_occurrences { url, popover_url, start, end, event {id, name, css_class, text_color, background_color, border_color, all_day} } } } ');
|
4
4
|
}
|
5
5
|
|
6
6
|
function calendarEventsQuery(slug) {
|
7
7
|
// GraphQL requires double-quoted strings in the query:
|
8
|
-
return(' { event_occurrences { url, popover_url, start, end, event {id, name,
|
8
|
+
return(' { event_occurrences { url, popover_url, start, end, event {id, name, css_class, text_color, background_color, border_color, all_day} } } ');
|
9
9
|
}
|
10
10
|
|
11
11
|
function formatEventOccurrence(occurrence) {
|
@@ -43,7 +43,7 @@ function calendarEventRender(event, element) {
|
|
43
43
|
element.popover({
|
44
44
|
html: true,
|
45
45
|
placement: 'auto',
|
46
|
-
viewport: '
|
46
|
+
viewport: '.date-book--calendar',
|
47
47
|
container: 'body',
|
48
48
|
title: '<a href="' + event.url + '">' + event.title + '</a><span onclick="hideParentPopover(this);" class="float-right glyphicon glyphicon-remove"></span>',
|
49
49
|
content: ajax_data
|
@@ -1,6 +1,7 @@
|
|
1
1
|
@import 'fullcalendar.css';
|
2
2
|
@import 'bootstrap-wysihtml5/bootstrap3-wysihtml5.css';
|
3
3
|
@import 'bootstrap-datetimepicker.css';
|
4
|
+
@import 'font-awesome';
|
4
5
|
|
5
6
|
.all-day {
|
6
7
|
background-image: url('date_book/all-day-bg.png');
|
@@ -39,6 +40,34 @@
|
|
39
40
|
max-width: 20em;
|
40
41
|
}
|
41
42
|
|
42
|
-
.
|
43
|
-
|
43
|
+
.glyphicon-spinning {
|
44
|
+
animation: spin 3s infinite linear;
|
45
|
+
-webkit-animation: spin2 3s infinite linear;
|
46
|
+
}
|
47
|
+
|
48
|
+
@keyframes spin {
|
49
|
+
from { transform: scale(1) rotate(0deg); }
|
50
|
+
to { transform: scale(1) rotate(360deg); }
|
51
|
+
}
|
52
|
+
|
53
|
+
@-webkit-keyframes spin2 {
|
54
|
+
from { -webkit-transform: rotate(0deg); }
|
55
|
+
to { -webkit-transform: rotate(360deg); }
|
56
|
+
}
|
57
|
+
|
58
|
+
.date-book--spinner {
|
59
|
+
font-size: 300px;
|
60
|
+
color: #999;
|
61
|
+
}
|
62
|
+
|
63
|
+
.date-book--wrapper {
|
64
|
+
position: relative;
|
65
|
+
|
66
|
+
.date-book--spinner {
|
67
|
+
position: absolute;
|
68
|
+
margin: auto;
|
69
|
+
z-index: 1000;
|
70
|
+
left: 50%;
|
71
|
+
transform: translate(-50%, 0);
|
72
|
+
}
|
44
73
|
}
|
@@ -1,48 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module DateBook
|
4
|
+
# Allows viewing and maintaining Calendars
|
2
5
|
class CalendarsController < DateBookController
|
3
6
|
load_and_authorize_resource find_by: :slug
|
4
7
|
|
5
8
|
# GET /calendars
|
6
|
-
def index
|
7
|
-
end
|
9
|
+
def index; end
|
8
10
|
|
9
11
|
# GET /calendars/slug
|
10
|
-
def show
|
11
|
-
end
|
12
|
+
def show; end
|
12
13
|
|
13
14
|
# GET /calendars/new
|
14
|
-
def new
|
15
|
-
end
|
15
|
+
def new; end
|
16
16
|
|
17
17
|
# GET /calendars/slug/edit
|
18
|
-
def edit
|
19
|
-
end
|
18
|
+
def edit; end
|
20
19
|
|
21
20
|
# POST /calendars
|
22
21
|
def create
|
23
22
|
@calendar.owners = [current_user]
|
24
|
-
|
25
|
-
redirect_to @calendar, notice: :item_acted_on.l(item: Calendar.model_name.human, action: :created.l)
|
26
|
-
else
|
23
|
+
unless @calendar.save
|
27
24
|
flash[:error] = @calendar.errors.full_messages.to_sentence
|
28
25
|
render :new
|
26
|
+
return
|
29
27
|
end
|
28
|
+
redirect_to(@calendar, notice: :item_acted_on.l(
|
29
|
+
item: Calendar.model_name.human,
|
30
|
+
action: :created.l
|
31
|
+
))
|
30
32
|
end
|
31
33
|
|
32
34
|
# PATCH/PUT /calendars/slug
|
33
35
|
def update
|
34
|
-
|
35
|
-
redirect_to @calendar, notice: :item_acted_on.l(item: Calendar.model_name.human, action: :updated.l)
|
36
|
-
else
|
36
|
+
unless @calendar.update(calendar_params)
|
37
37
|
flash[:error] = @calendar.errors.full_messages.to_sentence
|
38
38
|
render :edit
|
39
|
+
return
|
39
40
|
end
|
41
|
+
redirect_to(@calendar, notice: :item_acted_on.l(
|
42
|
+
item: Calendar.model_name.human,
|
43
|
+
action: :updated.l
|
44
|
+
))
|
40
45
|
end
|
41
46
|
|
42
47
|
# DELETE /calendars/slug
|
43
48
|
def destroy
|
44
49
|
@calendar.destroy
|
45
|
-
redirect_to
|
50
|
+
redirect_to(
|
51
|
+
calendars_url,
|
52
|
+
notice: :item_acted_on.l(
|
53
|
+
item: Calendar.model_name.human,
|
54
|
+
action: :destroyed.l
|
55
|
+
)
|
56
|
+
)
|
46
57
|
end
|
47
58
|
|
48
59
|
private
|
@@ -50,10 +61,10 @@ module DateBook
|
|
50
61
|
# Only allow a trusted parameter "white list" through.
|
51
62
|
def calendar_params
|
52
63
|
params.require(:calendar).permit(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
64
|
+
:id,
|
65
|
+
:name,
|
66
|
+
:description,
|
67
|
+
:css_class
|
57
68
|
)
|
58
69
|
end
|
59
70
|
end
|
@@ -1,19 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module DateBook
|
4
|
+
# Allows viewing and maintaining Events within Calendars
|
2
5
|
class EventsController < DateBookController
|
3
6
|
load_and_authorize_resource :calendar, find_by: :slug
|
4
7
|
load_and_authorize_resource :event, find_by: :slug, through: :calendar
|
5
|
-
before_action :set_occurrence, only: [
|
8
|
+
before_action :set_occurrence, only: %i[show popover]
|
6
9
|
|
7
10
|
# GET /events
|
8
11
|
def index
|
9
|
-
start_date = params[:start]&.to_datetime || Time
|
10
|
-
|
12
|
+
start_date = params[:start]&.to_datetime || Time
|
13
|
+
.now
|
14
|
+
.beginning_of_month
|
15
|
+
end_date = params[:end]&.to_datetime || Time
|
16
|
+
.now
|
17
|
+
.beginning_of_month
|
18
|
+
.next_month
|
11
19
|
@events = @events&.ending_after(start_date)&.starting_before(end_date)
|
12
20
|
end
|
13
21
|
|
14
22
|
# GET /events/slug
|
15
|
-
def show
|
16
|
-
end
|
23
|
+
def show; end
|
17
24
|
|
18
25
|
# GET /events/slug/popover
|
19
26
|
def popover
|
@@ -21,88 +28,79 @@ module DateBook
|
|
21
28
|
end
|
22
29
|
|
23
30
|
# GET /events/new
|
24
|
-
def new
|
25
|
-
end
|
31
|
+
def new; end
|
26
32
|
|
27
33
|
# GET /events/slug/edit
|
28
|
-
def edit
|
29
|
-
end
|
34
|
+
def edit; end
|
30
35
|
|
31
36
|
# POST /events
|
32
37
|
def create
|
33
38
|
@event.owners = [current_user]
|
34
|
-
|
35
|
-
redirect_to [@calendar, @event], notice: :item_acted_on.l(item: Event.model_name.human, action: :created.l)
|
36
|
-
else
|
39
|
+
unless @event.save
|
37
40
|
flash[:error] = @event.errors.full_messages.to_sentence
|
38
41
|
render :new
|
42
|
+
return
|
39
43
|
end
|
44
|
+
redirect_to([@calendar, @event], notice: :item_acted_on.l(
|
45
|
+
item: Event.model_name.human,
|
46
|
+
action: :created.l
|
47
|
+
))
|
40
48
|
end
|
41
49
|
|
42
50
|
# PATCH/PUT /events/slug
|
43
51
|
def update
|
44
|
-
|
45
|
-
redirect_to [@calendar, @event], notice: :item_acted_on.l(item: Event.model_name.human, action: :updated.l)
|
46
|
-
else
|
52
|
+
unless @event.update(event_params)
|
47
53
|
flash[:error] = @event.errors.full_messages.to_sentence
|
48
54
|
render :edit
|
55
|
+
return
|
49
56
|
end
|
57
|
+
redirect_to([@calendar, @event], notice: :item_acted_on.l(
|
58
|
+
item: Event.model_name.human,
|
59
|
+
action: :updated.l
|
60
|
+
))
|
50
61
|
end
|
51
62
|
|
52
63
|
# DELETE /events/slug
|
53
64
|
def destroy
|
54
65
|
@event.destroy
|
55
|
-
redirect_to
|
66
|
+
redirect_to(
|
67
|
+
calendar_events_url(@calendar),
|
68
|
+
notice: :item_acted_on.l(
|
69
|
+
item: Event.model_name.human,
|
70
|
+
action: :destroyed.l
|
71
|
+
)
|
72
|
+
)
|
56
73
|
end
|
57
74
|
|
58
75
|
private
|
59
|
-
def set_occurrence
|
60
|
-
if params[:occurrence_id].present?
|
61
|
-
@occurrence = @event.event_occurrences.find(params[:occurrence_id])
|
62
|
-
end
|
63
|
-
end
|
64
76
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
:date,
|
70
|
-
:time,
|
71
|
-
:rule,
|
72
|
-
:until,
|
73
|
-
:count,
|
74
|
-
:interval,
|
75
|
-
:all_day,
|
76
|
-
{
|
77
|
-
day: [],
|
78
|
-
day_of_week: [
|
79
|
-
{
|
80
|
-
monday: [],
|
81
|
-
tuesday: [],
|
82
|
-
wednesday: [],
|
83
|
-
thursday: [],
|
84
|
-
friday: [],
|
85
|
-
saturday: [],
|
86
|
-
sunday: []
|
87
|
-
}
|
88
|
-
],
|
89
|
-
duration_attributes: [
|
90
|
-
:count,
|
91
|
-
:unit
|
92
|
-
]
|
93
|
-
}
|
94
|
-
]
|
77
|
+
def set_occurrence
|
78
|
+
return unless params[:occurrence_id].present?
|
79
|
+
@occurrence = @event.event_occurrences.find(params[:occurrence_id])
|
80
|
+
end
|
95
81
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
:
|
103
|
-
:
|
104
|
-
|
105
|
-
|
106
|
-
|
82
|
+
# Only allow a trusted parameter "white list" through.
|
83
|
+
# rubocop:disable Metrics/MethodLength
|
84
|
+
def event_params
|
85
|
+
schedule_attributes = [
|
86
|
+
:id, :date, :time, :rule, :until, :count, :interval, :all_day,
|
87
|
+
{
|
88
|
+
day: [],
|
89
|
+
day_of_week: [
|
90
|
+
{
|
91
|
+
monday: [], tuesday: [], wednesday: [], thursday: [],
|
92
|
+
friday: [], saturday: [], sunday: []
|
93
|
+
}
|
94
|
+
],
|
95
|
+
duration_attributes: %i[count unit]
|
96
|
+
}
|
97
|
+
]
|
98
|
+
|
99
|
+
params.require(:event).permit(
|
100
|
+
:id, :name, :description, :css_class, :text_color, :background_color,
|
101
|
+
:border_color, schedule_attributes: schedule_attributes
|
102
|
+
)
|
103
|
+
end
|
107
104
|
end
|
105
|
+
# rubocop:enable Metrics/MethodLength
|
108
106
|
end
|