tb_events 1.0.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/README.md +17 -5
- data/Rakefile +2 -2
- data/app/assets/javascripts/admin/events/application.js +16 -0
- data/app/assets/javascripts/{calendar_events.js → admin/events/calendar_events.js} +0 -0
- data/app/assets/javascripts/{spud/admin → admin/events}/calendars.js +0 -0
- data/app/assets/stylesheets/admin/events/application.css +4 -0
- data/app/assets/{javascripts/spud/events.js → stylesheets/admin/events/calendar_events.css} +0 -0
- data/app/assets/stylesheets/{spud → admin/events}/calendars.css +23 -28
- data/app/controllers/admin/calendar_events_controller.rb +67 -0
- data/app/controllers/{spud/admin → admin}/calendars_controller.rb +17 -14
- data/app/controllers/calendar_events_controller.rb +12 -6
- data/app/controllers/calendars_controller.rb +18 -18
- data/app/helpers/admin/calendar_events_helper.rb +2 -0
- data/app/helpers/admin/calendars_helper.rb +13 -0
- data/app/helpers/calendars_helper.rb +66 -35
- data/app/models/spud_calendar.rb +28 -3
- data/app/models/spud_calendar_event.rb +1 -20
- data/app/models/spud_events/calendar_event_model.rb +31 -0
- data/app/views/admin/calendar_events/_calendar.html.erb +19 -0
- data/app/views/admin/calendar_events/_form.html.erb +21 -0
- data/app/views/admin/calendar_events/edit.html.erb +1 -0
- data/app/views/admin/calendar_events/index.html.erb +28 -0
- data/app/views/admin/calendar_events/new.html.erb +1 -0
- data/app/views/admin/calendars/_calendar_legend.html.erb +8 -0
- data/app/views/admin/calendars/_form.html.erb +5 -0
- data/app/views/{spud/admin → admin}/calendars/edit.html.erb +0 -0
- data/app/views/{spud/admin → admin}/calendars/new.html.erb +0 -0
- data/app/views/calendar_events/index.html.erb +22 -0
- data/app/views/calendar_events/show.html.erb +7 -5
- data/app/views/calendars/show.html.erb +19 -4
- data/config/locales/en.yml +9 -0
- data/config/routes.rb +9 -15
- data/db/migrate/20120216191833_create_spud_calendars.rb +2 -2
- data/db/migrate/20140723203144_add_identifier_to_spud_calendars.rb +6 -0
- data/db/migrate/20140730182213_remove_color_from_spud_calendars.rb +9 -0
- data/lib/spud_events/calendar_builder.rb +53 -0
- data/lib/spud_events/configuration.rb +6 -0
- data/lib/spud_events/engine.rb +23 -0
- data/lib/spud_events/version.rb +3 -0
- data/lib/tb_events.rb +4 -4
- metadata +83 -131
- data/app/assets/javascripts/calendars.js +0 -2
- data/app/assets/javascripts/spud/admin/calendar_events.js +0 -2
- data/app/assets/javascripts/spud/admin/events.js +0 -51
- data/app/assets/lib/colorpicker/colorpicker.css +0 -164
- data/app/assets/lib/colorpicker/colorpicker.js +0 -484
- data/app/assets/lib/colorpicker/images/blank.gif +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_background.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_hex.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_hsb_b.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_hsb_h.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_hsb_s.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_indic.gif +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_overlay.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_rgb_b.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_rgb_g.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_rgb_r.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_select.gif +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_submit.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_background.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_hex.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_hsb_b.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_hsb_h.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_hsb_s.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_indic.gif +0 -0
- data/app/assets/lib/colorpicker/images/custom_rgb_b.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_rgb_g.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_rgb_r.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_submit.png +0 -0
- data/app/assets/lib/colorpicker/images/select.png +0 -0
- data/app/assets/lib/colorpicker/images/select2.png +0 -0
- data/app/assets/lib/colorpicker/images/slider.png +0 -0
- data/app/assets/stylesheets/spud/admin/events.css +0 -16
- data/app/assets/stylesheets/spud/calendar_events.css +0 -18
- data/app/assets/stylesheets/spud/events.css +0 -4
- data/app/controllers/spud/admin/calendar_events_controller.rb +0 -64
- data/app/helpers/spud/admin/calendar_events_helper.rb +0 -2
- data/app/helpers/spud/admin/calendars_helper.rb +0 -15
- data/app/views/calendars/_calendar.html.erb +0 -26
- data/app/views/calendars/_calendar_options.html.erb +0 -4
- data/app/views/spud/admin/calendar_events/_calendar.html.erb +0 -14
- data/app/views/spud/admin/calendar_events/_form.html.erb +0 -98
- data/app/views/spud/admin/calendar_events/edit.html.erb +0 -1
- data/app/views/spud/admin/calendar_events/index.html.erb +0 -20
- data/app/views/spud/admin/calendar_events/new.html.erb +0 -1
- data/app/views/spud/admin/calendars/_calendar_legend.html.erb +0 -7
- data/app/views/spud/admin/calendars/_form.html.erb +0 -20
- data/config/application.rb +0 -50
- data/config/boot.rb +0 -6
- data/lib/spud/events/calendar.rb +0 -85
- data/lib/spud/events/calendar_builder.rb +0 -58
- data/lib/spud/events/configuration.rb +0 -10
- data/lib/spud/events/engine.rb +0 -26
- data/lib/spud/events/table_builder.rb +0 -88
- data/lib/spud/events/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZDAzOWU5ZDIwNDY1NDVkNWQ0ZDg2MzliYjA0Yjg0NzgxNWIxN2RiNDhlMzI5
|
10
|
-
Y2M2ODk2ODA4Yjg2ODg1OTk3OTc0ZTVjMjIyNTNkNWQ4MzQ1ZTY0YzhhZDNl
|
11
|
-
NmIxNzc4MTdmMTJjOTRlZjYyNzI3YmQ2N2Y3Njk1MzhjOGJjMWE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MzdhZWI5Yzk2NWY3ZmUyOGU5ZjNjMjliMDk3NjlhZGM0ZTU0Njk2YzBlYTA2
|
14
|
-
NGU5ZWYzOTM2ODEzZGM5MGQwYWUxZjZkNjQ0ZTU3NWU3NzVkN2IzNTgwM2Q4
|
15
|
-
NTg1NGM1NTExNDlkY2ZkODUzYTk5OTE0ZGI5Njg0ZDA1ZDg2ZDE=
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d8495699ef036385ff906c76c7d34b616b024c3c167f4e543d929d8cc15c95bf
|
4
|
+
data.tar.gz: c384b0864d671436b70da6aedd9877657f95d588227958fcb73569771ac3fa21
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9473623e16c4e10a2184574bf4c5fc9b5e6bc5bf2c18f725dce12dc6696b97a85761b223446ad2b341be0095cc1f04fb99e005da86bddb1a7b1781fb2cb23a7b
|
7
|
+
data.tar.gz: 441459722f410fc0aff5508b49345c359953ad722a3dabdc75f34799b8afaa7cecc6064dacc6335284dda39c4f4d5312084e4c8c7e5718a25b64ff75f02e6888
|
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
|
1
|
+
TB Events
|
2
2
|
===========
|
3
3
|
|
4
|
-
|
4
|
+
TB Events is an event and calendaring engine for Twice Baked.
|
5
5
|
|
6
6
|
Installation/Usage
|
7
7
|
------------------
|
8
8
|
|
9
9
|
1. Add the following to your Gemfile
|
10
10
|
|
11
|
-
gem '
|
12
|
-
gem '
|
11
|
+
gem 'tb_core'
|
12
|
+
gem 'tb_events'
|
13
13
|
|
14
14
|
2. Run ```bundle install```
|
15
15
|
3. Copy the database migrations in to your rails project
|
@@ -24,7 +24,7 @@ Configruations
|
|
24
24
|
|
25
25
|
* Set the layout for the calendar pages (Defualt is layouts/spud/calendar)
|
26
26
|
|
27
|
-
|
27
|
+
SpudEvents.configure do |config|
|
28
28
|
config.calendar_layout = 'application'
|
29
29
|
end
|
30
30
|
|
@@ -36,6 +36,18 @@ Configruations
|
|
36
36
|
*= require spud/events
|
37
37
|
*/
|
38
38
|
|
39
|
+
## View Helpers
|
40
|
+
|
41
|
+
TB Events comes with a handful of view helpers for generating calendars. See the Rdoc documentation for detailed information.
|
42
|
+
|
43
|
+
Return a calendar as an html table for the given date:
|
44
|
+
|
45
|
+
spud_calendar_for_date(date)
|
46
|
+
|
47
|
+
Return a calendar for the given date, populated with event data:
|
48
|
+
|
49
|
+
spud_calendar_for_events(events, date, opts)
|
50
|
+
|
39
51
|
Testing
|
40
52
|
-----------------
|
41
53
|
|
data/Rakefile
CHANGED
@@ -20,9 +20,9 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
20
20
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
21
|
end
|
22
22
|
|
23
|
-
APP_RAKEFILE = File.expand_path(
|
23
|
+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
24
24
|
load 'rails/tasks/engine.rake'
|
25
25
|
|
26
26
|
Bundler::GemHelper.install_tasks
|
27
27
|
|
28
|
-
require 'rake'
|
28
|
+
require 'rake'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
//= require_self
|
2
|
+
//= require_directory
|
3
|
+
|
4
|
+
(function(){
|
5
|
+
|
6
|
+
spud.admin.events = {
|
7
|
+
init: function(){
|
8
|
+
$(document).on('ajax:success','.js-spud-calendar-delete-action', deletedCalendar);
|
9
|
+
}
|
10
|
+
};
|
11
|
+
|
12
|
+
var deletedCalendar = function(){
|
13
|
+
$(this).closest('.spud_events_admin_calendar_legend_item').fadeOut(500, function(){ $(this).remove(); });
|
14
|
+
};
|
15
|
+
|
16
|
+
})();
|
File without changes
|
File without changes
|
File without changes
|
@@ -49,10 +49,8 @@
|
|
49
49
|
|
50
50
|
#spud_events_admin_calendar,
|
51
51
|
#spud_events_calendar {
|
52
|
-
|
53
|
-
padding-bottom: 50px;
|
52
|
+
margin: 0 0 20px;
|
54
53
|
position: relative;
|
55
|
-
float: left;
|
56
54
|
}
|
57
55
|
#spud_events_calendar {
|
58
56
|
width: auto;
|
@@ -66,7 +64,7 @@
|
|
66
64
|
margin: 15px 0 0;
|
67
65
|
}
|
68
66
|
#spud_events_admin_calendar th,
|
69
|
-
#spud_events_calendar th {
|
67
|
+
#spud_events_calendar th {
|
70
68
|
text-align: center;
|
71
69
|
}
|
72
70
|
#spud_events_admin_calendar td,
|
@@ -78,21 +76,33 @@
|
|
78
76
|
vertical-align: top;
|
79
77
|
width: 98px;
|
80
78
|
}
|
81
|
-
.
|
82
|
-
.spud_events_calendar_date_container {
|
83
|
-
display: block;
|
84
|
-
padding: 18px 5px 0;
|
85
|
-
position: relative;
|
86
|
-
}
|
87
|
-
span.spud_events_admin_calendar_date,
|
88
|
-
span.spud_events_calendar_date {
|
79
|
+
.calendar-day{
|
89
80
|
position: absolute;
|
90
81
|
top: 3px;
|
91
|
-
|
82
|
+
left: 3px;
|
92
83
|
font-size: 11px;
|
93
84
|
line-height: 11px;
|
94
85
|
}
|
95
86
|
|
87
|
+
.not-month .calendar-day {
|
88
|
+
display: none;
|
89
|
+
}
|
90
|
+
.not-month .calendar-events {
|
91
|
+
display: none;
|
92
|
+
}
|
93
|
+
|
94
|
+
.calendar-events-list{
|
95
|
+
list-style: none;
|
96
|
+
margin: 10px 0 0;
|
97
|
+
padding: 0;
|
98
|
+
}
|
99
|
+
.calendar-events-list li{
|
100
|
+
margin: 4px;
|
101
|
+
}
|
102
|
+
.calendar-events-list a{
|
103
|
+
text-decoration: none;
|
104
|
+
}
|
105
|
+
|
96
106
|
/* Calendar Legend
|
97
107
|
----------------------- */
|
98
108
|
#spud_events_admin_calendar_legend,
|
@@ -100,7 +110,6 @@ span.spud_events_calendar_date {
|
|
100
110
|
list-style: none;
|
101
111
|
border: 1px solid #d9d9d9;
|
102
112
|
padding: 0;
|
103
|
-
margin: 45px 0 0 725px;
|
104
113
|
}
|
105
114
|
#spud_events_admin_calendar_legend li,
|
106
115
|
#spud_events_calendar_legend li {
|
@@ -120,17 +129,3 @@ span.spud_events_calendar_date {
|
|
120
129
|
#spud_events_calendar_legend li:last-child {
|
121
130
|
border: none;
|
122
131
|
}
|
123
|
-
.spud_events_admin_calendar_actions,
|
124
|
-
.spud_events_calendar_actions {
|
125
|
-
text-align: right;
|
126
|
-
}
|
127
|
-
|
128
|
-
#spud_events_admin_calendar_legend span,
|
129
|
-
#spud_events_calendar_legend span {
|
130
|
-
display: inline-block;
|
131
|
-
-moz-border-radius: 3px;
|
132
|
-
-webkit-border-radius: 3px;
|
133
|
-
border-radius: 3px;
|
134
|
-
padding: 2px 8px;
|
135
|
-
margin: 8px 0 0 8px;
|
136
|
-
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class Admin::CalendarEventsController < Admin::ApplicationController
|
2
|
+
add_breadcrumb 'Events', :admin_list_spud_calendar_events_path
|
3
|
+
belongs_to_app :events
|
4
|
+
|
5
|
+
respond_to :html, :xml, :json
|
6
|
+
respond_to :js, only: [:index]
|
7
|
+
|
8
|
+
def index
|
9
|
+
if params[:month]
|
10
|
+
year = params[:year] ? params[:year].to_i : Date.today.year
|
11
|
+
begin
|
12
|
+
@calendar_date = Date.new(year, params[:month].to_i)
|
13
|
+
rescue
|
14
|
+
@calendar_date = Date.today
|
15
|
+
end
|
16
|
+
else
|
17
|
+
@calendar_date = Date.today
|
18
|
+
end
|
19
|
+
|
20
|
+
if params[:spud_calendar] && calendar = SpudCalendar.find_by_title(params[:spud_calendar].titleize)
|
21
|
+
@calendar_events = calendar.events
|
22
|
+
else
|
23
|
+
@calendar_events = SpudCalendarEvent
|
24
|
+
end
|
25
|
+
@calendar_events = @calendar_events.in_month_of(@calendar_date).order('spud_calendar_events.start_at ASC').to_a
|
26
|
+
|
27
|
+
@calendars = SpudCalendar.all
|
28
|
+
@current_calendar = params[:spud_calendar] ? params[:spud_calendar] : 0
|
29
|
+
|
30
|
+
respond_with(@calendars, include: :events)
|
31
|
+
end
|
32
|
+
|
33
|
+
def new
|
34
|
+
@calendar_event = SpudCalendarEvent.new
|
35
|
+
if params[:spud_calendar]
|
36
|
+
@calendar_event.spud_calendar_id = SpudCalendar.find_by_title(params[:spud_calendar].titleize).id
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def edit
|
41
|
+
@calendar_event = SpudCalendarEvent.find(params[:id])
|
42
|
+
end
|
43
|
+
|
44
|
+
def create
|
45
|
+
@calendar_event = SpudCalendarEvent.new(calendar_event_params)
|
46
|
+
flash[:notice] = 'Calendar event was successfully created.' if @calendar_event.save
|
47
|
+
respond_with(@calendar_event, location: admin_list_spud_calendar_events_path)
|
48
|
+
end
|
49
|
+
|
50
|
+
def update
|
51
|
+
@calendar_event = SpudCalendarEvent.find(params[:id])
|
52
|
+
flash[:notice] = 'Calendar event was successfully updated.' if @calendar_event.update_attributes(calendar_event_params)
|
53
|
+
respond_with(@calendar_event, location: admin_list_spud_calendar_events_path)
|
54
|
+
end
|
55
|
+
|
56
|
+
def destroy
|
57
|
+
@calendar_event = SpudCalendarEvent.find(params[:id])
|
58
|
+
flash[:notice] = 'Calendar event deleted successfully' if @calendar_event.destroy
|
59
|
+
respond_with(@calendar_event, location: admin_list_spud_calendar_events_path)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def calendar_event_params
|
65
|
+
params.require(:spud_calendar_event).permit(:title, :description, :start_at, :end_at, :all_day, :spud_calendar_id, :spud_calendar, :location, :address, :address_2, :city, :state, :zip)
|
66
|
+
end
|
67
|
+
end
|
@@ -1,40 +1,38 @@
|
|
1
|
-
class
|
1
|
+
class Admin::CalendarsController < Admin::ApplicationController
|
2
|
+
add_breadcrumb 'Events', :admin_list_spud_calendar_events_path
|
2
3
|
|
3
|
-
|
4
|
-
add_breadcrumb "Events", :spud_admin_list_spud_calendar_events_path
|
5
|
-
|
6
|
-
belongs_to_spud_app :events
|
4
|
+
belongs_to_app :events
|
7
5
|
|
8
6
|
respond_to :html, :xml, :json, :js
|
9
7
|
|
10
8
|
def new
|
11
|
-
@page_name =
|
9
|
+
@page_name = 'New Calendar'
|
12
10
|
@calendar = SpudCalendar.new
|
13
11
|
respond_with(@calendar)
|
14
12
|
end
|
15
13
|
|
16
14
|
def create
|
17
|
-
@calendar = SpudCalendar.new(
|
15
|
+
@calendar = SpudCalendar.new(calendar_params)
|
18
16
|
if @calendar.save
|
19
|
-
redirect_to
|
17
|
+
redirect_to admin_list_spud_calendar_events_path
|
20
18
|
else
|
21
|
-
render :
|
19
|
+
render action: 'new'
|
22
20
|
end
|
23
21
|
end
|
24
22
|
|
25
23
|
def edit
|
26
|
-
@page_name =
|
24
|
+
@page_name = 'Edit Calendar'
|
27
25
|
@calendar = SpudCalendar.find(params[:id])
|
28
26
|
respond_with(@calendar)
|
29
27
|
end
|
30
28
|
|
31
29
|
def update
|
32
30
|
@calendar = SpudCalendar.find(params[:id])
|
33
|
-
if @calendar.update_attributes(
|
31
|
+
if @calendar.update_attributes(calendar_params)
|
34
32
|
flash[:notice] = 'Calendar was successfully updated.'
|
35
|
-
redirect_to
|
33
|
+
redirect_to admin_list_spud_calendar_events_path
|
36
34
|
else
|
37
|
-
render :
|
35
|
+
render action: 'edit'
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
@@ -45,8 +43,13 @@ class Spud::Admin::CalendarsController < Spud::Admin::ApplicationController
|
|
45
43
|
end
|
46
44
|
@calendar.destroy
|
47
45
|
respond_with(@calendar) do |format|
|
48
|
-
format.js { render(:
|
46
|
+
format.js { render(nothing: true) }
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
50
|
+
private
|
51
|
+
|
52
|
+
def calendar_params
|
53
|
+
params.require(:spud_calendar).permit(:title)
|
54
|
+
end
|
52
55
|
end
|
@@ -1,8 +1,14 @@
|
|
1
1
|
class CalendarEventsController < ApplicationController
|
2
|
-
|
3
|
-
layout
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
respond_to :html, :json
|
3
|
+
layout SpudEvents.config.calendar_layout
|
4
|
+
|
5
|
+
def index
|
6
|
+
@events = SpudCalendarEvent.ordered.paginate(per_page: 10, page: params[:page])
|
7
|
+
respond_with @events
|
8
|
+
end
|
9
|
+
|
10
|
+
def show
|
11
|
+
@event = SpudCalendarEvent.find(params[:id])
|
12
|
+
respond_with @event
|
13
|
+
end
|
8
14
|
end
|
@@ -1,30 +1,30 @@
|
|
1
1
|
class CalendarsController < ApplicationController
|
2
|
-
|
3
|
-
layout
|
2
|
+
respond_to :html, :json
|
3
|
+
layout SpudEvents.config.calendar_layout
|
4
|
+
before_action :calendar_date
|
4
5
|
|
5
6
|
def show
|
6
|
-
if params[:month]
|
7
|
-
year = params[:year] ? params[:year] : Time.new.year
|
8
|
-
begin
|
9
|
-
@calendar_date = Time.local(year, params[:month])
|
10
|
-
rescue
|
11
|
-
@calendar_date = default_date
|
12
|
-
end
|
13
|
-
else
|
14
|
-
@calendar_date = default_date
|
15
|
-
end
|
16
7
|
if params[:calendar] && calendar = SpudCalendar.find_by_title(params[:calendar].titleize)
|
17
|
-
@events = calendar.spud_calendar_events.
|
8
|
+
@events = calendar.spud_calendar_events.in_month_of(@calendar_date).order(:start_at).to_a
|
18
9
|
else
|
19
|
-
@events = SpudCalendarEvent.
|
10
|
+
@events = SpudCalendarEvent.in_month_of(@calendar_date).order(:start_at).to_a
|
20
11
|
end
|
21
12
|
@current_calendar = params[:calendar] ? params[:calendar] : 0
|
22
|
-
|
13
|
+
respond_with @events
|
23
14
|
end
|
24
15
|
|
25
|
-
|
26
|
-
tempDate = Time.new
|
27
|
-
return Time.local(tempDate.year,tempDate.month)
|
16
|
+
private
|
28
17
|
|
18
|
+
def calendar_date
|
19
|
+
if params[:month]
|
20
|
+
year = params[:year] ? params[:year].to_i : Date.today.year
|
21
|
+
begin
|
22
|
+
@calendar_date = Date.new(year, params[:month].to_i)
|
23
|
+
rescue
|
24
|
+
@calendar_date = Date.today
|
25
|
+
end
|
26
|
+
else
|
27
|
+
@calendar_date = Date.today
|
28
|
+
end
|
29
29
|
end
|
30
30
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Admin::CalendarsHelper
|
2
|
+
def link_to_previous_admin_calendar_month(date, _url_for_options = {})
|
3
|
+
date = date.advance(months: -1)
|
4
|
+
calendar = params[:calendar] ? params[:calendar] : nil
|
5
|
+
link_to('« Previous Month'.html_safe, admin_list_spud_calendar_events_path(month: date.month, year: date.year, calendar: calendar), class: 'spud_events_calendar_link previous_calendar btn btn-sm btn-default').html_safe
|
6
|
+
end
|
7
|
+
|
8
|
+
def link_to_next_admin_calendar_month(date, _url_for_options = {})
|
9
|
+
date = date.advance(months: 1)
|
10
|
+
calendar = params[:calendar] ? params[:calendar] : nil
|
11
|
+
link_to('Next Month »'.html_safe, admin_list_spud_calendar_events_path(month: date.month, year: date.year, calendar: calendar), class: 'spud_events_calendar_link next_calendar btn btn-sm btn-default pull-right').html_safe
|
12
|
+
end
|
13
|
+
end
|
@@ -1,48 +1,79 @@
|
|
1
1
|
module CalendarsHelper
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
# Builds a calendar for the given date
|
3
|
+
#
|
4
|
+
# * date: Determines the month to be displayed. Given date will have the "today" css class
|
5
|
+
# * opts:
|
6
|
+
# - headers: Array of weekday headers (optional)
|
7
|
+
#
|
8
|
+
def spud_calendar_for_date(date, opts = {}, &block)
|
9
|
+
events = SpudCalendarEvent.in_month_of(date)
|
10
|
+
spud_calendar_for_events(events, date, opts, &block)
|
7
11
|
end
|
8
12
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
options_for_select(SpudCalendar.all.collect { |f| [f.title, f.title.gsub(/([^A-Z0-9]+)/i, "-").downcase] }.insert(0, text_for_all), @current_calendar)
|
13
|
+
# Builds a calendar for the given date and identifier
|
14
|
+
#
|
15
|
+
# * identifier: Symbol for the SpudCalendar you wish to display
|
16
|
+
# * date: Determines the month to be displayed. Given date will have the "today" css class
|
17
|
+
# * opts:
|
18
|
+
# - headers: Array of weekday headers (optional)
|
19
|
+
#
|
20
|
+
def spud_calendar_for_identifier(identifier, date, opts = {}, &block)
|
21
|
+
calendar = SpudCalendar.with_identifier(identifier)
|
22
|
+
if calendar.present?
|
23
|
+
events = calendar.spud_calendar_events.in_month_of(date)
|
24
|
+
else
|
25
|
+
logger.warn "Failed to load calendar by identifer '#{identifier}'. Does it exist?"
|
26
|
+
events = []
|
27
|
+
end
|
28
|
+
spud_calendar_for_events(events, date, opts, &block)
|
26
29
|
end
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
# Builds a calendar for the given date, with events
|
32
|
+
#
|
33
|
+
# * events: An array or relation of SpudCalendarEvent records
|
34
|
+
# * date: Determines the month to be displayed. Given date will have the "today" css class
|
35
|
+
# * opts:
|
36
|
+
# - headers: Array of weekday headers (optional)
|
37
|
+
#
|
38
|
+
def spud_calendar_for_events(events, date, opts = {}, &block)
|
39
|
+
events_array = events.to_a
|
40
|
+
cache(['spud-calendar', date.to_s, events]) do
|
41
|
+
concat(
|
42
|
+
SpudEvents::CalendarBuilder.new(self, date, opts).table do |day|
|
43
|
+
events = extract_events_for_date(events_array, day)
|
44
|
+
if block
|
45
|
+
block.call(day, events)
|
46
|
+
else
|
47
|
+
concat content_tag(:span, day.day.to_s, class: 'calendar-day')
|
48
|
+
if events.length > 0
|
49
|
+
list_items = events.collect do |event|
|
50
|
+
'<li>' + link_to(event.title, calendar_event_path(event)) + '</li>'
|
51
|
+
end.join('')
|
52
|
+
concat content_tag(:ul, raw(list_items), class: 'events-list')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
)
|
32
57
|
end
|
58
|
+
end
|
33
59
|
|
34
|
-
|
35
|
-
|
36
|
-
|
60
|
+
def link_to_previous_calendar_month(date)
|
61
|
+
date = date.advance(months: -1)
|
62
|
+
calendar = params[:calendar] ? params[:calendar] : nil
|
63
|
+
link_to('« Previous Month'.html_safe, calendar_path(month: date.month, year: date.year, calendar: calendar), class: 'spud_events_calendar_link previous_calendar btn').html_safe
|
64
|
+
end
|
37
65
|
|
38
|
-
|
66
|
+
def link_to_next_calendar_month(date)
|
67
|
+
date = date.advance(months: 1)
|
68
|
+
calendar = params[:calendar] ? params[:calendar] : nil
|
69
|
+
link_to('Next Month »'.html_safe, calendar_path(month: date.month, year: date.year, calendar: calendar), class: 'spud_events_calendar_link next_calendar btn').html_safe
|
70
|
+
end
|
39
71
|
|
72
|
+
private
|
40
73
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
else
|
45
|
-
return fore_color
|
74
|
+
def extract_events_for_date(events, date)
|
75
|
+
events.select do |event|
|
76
|
+
date >= event.start_date && date <= event.end_date
|
46
77
|
end
|
47
78
|
end
|
48
79
|
end
|