fullcalendar_engine 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/fullcalendar_engine/{events.js → events.js.erb} +36 -35
- data/app/controllers/fullcalendar_engine/events_controller.rb +54 -40
- data/app/views/fullcalendar_engine/events/_edit_form.html.erb +0 -1
- data/app/views/fullcalendar_engine/events/_form.html.erb +3 -4
- data/app/views/fullcalendar_engine/events/index.html.erb +3 -9
- data/lib/fullcalendar_engine/version.rb +1 -1
- metadata +3 -3
@@ -1,24 +1,49 @@
|
|
1
1
|
// Place all the behaviors and hooks related to the matching controller here.
|
2
2
|
// All this logic will automatically be available in application.js.
|
3
|
+
|
4
|
+
full_calendar_options = <%= FullcalendarEngine::Configuration.to_json.html_safe %>
|
5
|
+
app_path = "<%= FullcalendarEngine::Configuration["mount_path"] %>"
|
6
|
+
|
7
|
+
$.extend(full_calendar_options, {
|
8
|
+
loading: function(bool){
|
9
|
+
if (bool)
|
10
|
+
$('#loading').show();
|
11
|
+
else
|
12
|
+
$('#loading').hide();
|
13
|
+
},
|
14
|
+
eventDrop: function(event, dayDelta, minuteDelta, allDay, revertFunc){
|
15
|
+
FullcalendarEngine.Events.move(event, dayDelta, minuteDelta, allDay);
|
16
|
+
},
|
17
|
+
eventResize: function(event, dayDelta, minuteDelta, revertFunc){
|
18
|
+
FullcalendarEngine.Events.resize(event, dayDelta, minuteDelta);
|
19
|
+
},
|
20
|
+
eventClick: function(event, jsEvent, view){
|
21
|
+
FullcalendarEngine.Events.showEventDetails(event);
|
22
|
+
},
|
23
|
+
select: function( startDate, endDate, allDay, jsEvent, view ) {
|
24
|
+
FullcalendarEngine.Form.display({
|
25
|
+
starttime: new Date(startDate.getTime()),
|
26
|
+
endtime: new Date(endDate.getTime()),
|
27
|
+
allDay: allDay
|
28
|
+
})
|
29
|
+
}
|
30
|
+
})
|
31
|
+
|
3
32
|
if (typeof(FullcalendarEngine) === 'undefined') { FullcalendarEngine = {}; }
|
4
33
|
|
5
34
|
FullcalendarEngine = {
|
6
35
|
Form: {
|
7
36
|
display: function(options) {
|
8
37
|
if (typeof(options) == 'undefined') { options = {} }
|
38
|
+
FullcalendarEngine.Form.fetch(options)
|
39
|
+
},
|
40
|
+
render: function(options){
|
9
41
|
$('#event_form').trigger('reset');
|
10
|
-
|
11
42
|
var startTime = options['starttime'] || new Date(), endTime = options['endtime'] || new Date(startTime.getTime());
|
12
|
-
|
13
43
|
if(startTime.getTime() == endTime.getTime()) { endTime.setMinutes(startTime.getMinutes() + 15); }
|
14
|
-
|
15
44
|
FullcalendarEngine.setTime('#event_starttime', startTime)
|
16
45
|
FullcalendarEngine.setTime('#event_endtime', endTime)
|
17
|
-
|
18
46
|
$('#event_all_day').attr('checked', options['allDay'])
|
19
|
-
|
20
|
-
// FullcalendarEngine.Form.fetch()
|
21
|
-
|
22
47
|
$('#create_event_dialog').dialog({
|
23
48
|
title: 'New Event',
|
24
49
|
modal: true,
|
@@ -26,12 +51,13 @@ FullcalendarEngine = {
|
|
26
51
|
close: function(event, ui) { $('#create_event_dialog').dialog('destroy') }
|
27
52
|
});
|
28
53
|
},
|
29
|
-
fetch: function(){
|
54
|
+
fetch: function(options){
|
30
55
|
$.ajax({
|
31
56
|
type: 'get',
|
32
57
|
dataType: 'script',
|
33
58
|
async: true,
|
34
|
-
url: FullcalendarEngine.app_path() + "/events/new"
|
59
|
+
url: FullcalendarEngine.app_path() + "/events/new",
|
60
|
+
success: function(){ FullcalendarEngine.Form.render(options) }
|
35
61
|
});
|
36
62
|
},
|
37
63
|
authenticity_token: function(){
|
@@ -79,7 +105,7 @@ FullcalendarEngine = {
|
|
79
105
|
});
|
80
106
|
},
|
81
107
|
refetch_events_and_close_dialog: function() {
|
82
|
-
$('
|
108
|
+
$('.calendar').fullCalendar('refetchEvents');
|
83
109
|
$('.dialog:visible').dialog('destroy');
|
84
110
|
},
|
85
111
|
showEventDetails: function(event){
|
@@ -169,29 +195,4 @@ $(document).ready(function(){
|
|
169
195
|
alert(xhr.responseText);
|
170
196
|
}
|
171
197
|
})
|
172
|
-
|
173
|
-
$.extend(full_calendar_options, {
|
174
|
-
loading: function(bool){
|
175
|
-
if (bool)
|
176
|
-
$('#loading').show();
|
177
|
-
else
|
178
|
-
$('#loading').hide();
|
179
|
-
},
|
180
|
-
eventDrop: function(event, dayDelta, minuteDelta, allDay, revertFunc){
|
181
|
-
FullcalendarEngine.Events.move(event, dayDelta, minuteDelta, allDay);
|
182
|
-
},
|
183
|
-
eventResize: function(event, dayDelta, minuteDelta, revertFunc){
|
184
|
-
FullcalendarEngine.Events.resize(event, dayDelta, minuteDelta);
|
185
|
-
},
|
186
|
-
eventClick: function(event, jsEvent, view){
|
187
|
-
FullcalendarEngine.Events.showEventDetails(event);
|
188
|
-
},
|
189
|
-
select: function( startDate, endDate, allDay, jsEvent, view ) {
|
190
|
-
FullcalendarEngine.Form.display({
|
191
|
-
starttime: new Date(startDate.getTime()),
|
192
|
-
endtime: new Date(endDate.getTime()),
|
193
|
-
allDay: allDay
|
194
|
-
})
|
195
|
-
}
|
196
|
-
})
|
197
198
|
});
|
@@ -1,18 +1,18 @@
|
|
1
|
-
require_dependency
|
1
|
+
require_dependency 'fullcalendar_engine/application_controller'
|
2
2
|
|
3
3
|
module FullcalendarEngine
|
4
4
|
class EventsController < ApplicationController
|
5
5
|
|
6
|
-
layout FullcalendarEngine::Configuration['layout'] ||
|
6
|
+
layout FullcalendarEngine::Configuration['layout'] || 'application'
|
7
7
|
|
8
|
-
before_filter :load_event, :
|
9
|
-
before_filter :determine_event_type, :
|
8
|
+
before_filter :load_event, only: [:edit, :update, :destroy, :move, :resize]
|
9
|
+
before_filter :determine_event_type, only: :create
|
10
10
|
|
11
11
|
def create
|
12
12
|
if @event.save
|
13
|
-
render :
|
13
|
+
render nothing: true
|
14
14
|
else
|
15
|
-
render :
|
15
|
+
render text: @event.errors.full_messages.to_sentence, status: 422
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -23,84 +23,98 @@ module FullcalendarEngine
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def get_events
|
26
|
-
@events = Event.where(
|
26
|
+
@events = Event.where('starttime >= :start_time and
|
27
|
+
endtime <= :end_time',
|
28
|
+
start_time: Time.at(params['start'].to_i).to_formatted_s(:db),
|
29
|
+
end_time: Time.at(params['end'].to_i).to_formatted_s(:db))
|
27
30
|
events = []
|
28
31
|
@events.each do |event|
|
29
|
-
events << {
|
32
|
+
events << { id: event.id,
|
33
|
+
title: event.title,
|
34
|
+
description: event.description || '',
|
35
|
+
start: event.starttime.iso8601,
|
36
|
+
end: event.endtime.iso8601,
|
37
|
+
allDay: event.all_day,
|
38
|
+
recurring: (event.event_series_id) ? true : false }
|
30
39
|
end
|
31
|
-
render :
|
40
|
+
render json: events.to_json
|
32
41
|
end
|
33
42
|
|
34
43
|
def move
|
35
44
|
if @event
|
36
|
-
@event.starttime = (
|
37
|
-
@event.endtime
|
38
|
-
@event.all_day
|
45
|
+
@event.starttime = make_time_from_minute_and_day_delta(@event.starttime)
|
46
|
+
@event.endtime = make_time_from_minute_and_day_delta(@event.endtime)
|
47
|
+
@event.all_day = params[:all_day]
|
39
48
|
@event.save
|
40
49
|
end
|
41
|
-
render :
|
50
|
+
render nothing: true
|
42
51
|
end
|
43
52
|
|
44
53
|
def resize
|
45
54
|
if @event
|
46
|
-
@event.endtime = (
|
55
|
+
@event.endtime = make_time_from_minute_and_day_delta(@event.endtime)
|
47
56
|
@event.save
|
48
57
|
end
|
49
|
-
render :
|
58
|
+
render nothing: true
|
50
59
|
end
|
51
60
|
|
52
61
|
def edit
|
53
|
-
render :
|
62
|
+
render json: { form: render_to_string(partial: 'edit_form') }
|
54
63
|
end
|
55
64
|
|
56
65
|
def update
|
57
66
|
case params[:event][:commit_button]
|
58
|
-
when
|
59
|
-
@events = @event.event_series.events
|
67
|
+
when 'Update All Occurrence'
|
68
|
+
@events = @event.event_series.events
|
60
69
|
@event.update_events(@events, event_params)
|
61
|
-
when
|
62
|
-
@events = @event.event_series.events.
|
70
|
+
when 'Update All Following Occurrence'
|
71
|
+
@events = @event.event_series.events.where('starttime > :start_time',
|
72
|
+
start_time: @event.starttime.to_formatted_s(:db)).to_a
|
63
73
|
@event.update_events(@events, event_params)
|
64
74
|
else
|
65
75
|
@event.attributes = event_params
|
66
76
|
@event.save
|
67
77
|
end
|
68
|
-
render :
|
78
|
+
render nothing: true
|
69
79
|
end
|
70
80
|
|
71
81
|
def destroy
|
72
82
|
case params[:delete_all]
|
73
|
-
when
|
83
|
+
when 'true'
|
74
84
|
@event.event_series.destroy
|
75
|
-
when
|
76
|
-
@events = @event.event_series.events.
|
77
|
-
|
85
|
+
when 'future'
|
86
|
+
@events = @event.event_series.events.where('starttime > :start_time',
|
87
|
+
start_time: @event.starttime.to_formatted_s(:db)).to_a
|
88
|
+
@event.event_series.events.delete(@events)
|
78
89
|
else
|
79
90
|
@event.destroy
|
80
91
|
end
|
81
|
-
render :
|
92
|
+
render nothing: true
|
82
93
|
end
|
83
94
|
|
84
95
|
private
|
85
96
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
97
|
+
def load_event
|
98
|
+
@event = Event.where(:id => params[:id]).first
|
99
|
+
unless @event
|
100
|
+
render json: { message: "Event Not Found.."}, status: 404 and return
|
91
101
|
end
|
102
|
+
end
|
92
103
|
|
93
|
-
|
94
|
-
|
95
|
-
|
104
|
+
def event_params
|
105
|
+
params.require(:event).permit('title', 'description', 'starttime', 'endtime', 'all_day', 'period', 'frequency', 'commit_button')
|
106
|
+
end
|
96
107
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
108
|
+
def determine_event_type
|
109
|
+
if params[:event][:period] == "Does not repeat"
|
110
|
+
@event = Event.new(event_params)
|
111
|
+
else
|
112
|
+
@event = EventSeries.new(event_params)
|
103
113
|
end
|
114
|
+
end
|
104
115
|
|
116
|
+
def make_time_from_minute_and_day_delta(event_time)
|
117
|
+
params[:minute_delta].to_i.minutes.from_now((params[:day_delta].to_i).days.from_now(event_time))
|
118
|
+
end
|
105
119
|
end
|
106
120
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_for @event ||= FullcalendarEngine::Event.new, :html => { :
|
1
|
+
<%= form_for @event ||= FullcalendarEngine::Event.new, :html => { id: 'event_form' } do |f| %>
|
2
2
|
<p>
|
3
3
|
<%=f.label :title %>
|
4
4
|
<br/>
|
@@ -25,14 +25,13 @@
|
|
25
25
|
</p>
|
26
26
|
<p>
|
27
27
|
<%=f.label :period, "Repeats" %>
|
28
|
-
<%=f.select :period, FullcalendarEngine::Event::REPEATS.values,{}, :
|
28
|
+
<%=f.select :period, FullcalendarEngine::Event::REPEATS.values, {}, onchange: "FullcalendarEngine.Events.showPeriodAndFrequency(this.value);" %>
|
29
29
|
</p>
|
30
30
|
<p id = "frequency" style = "display:none;">
|
31
31
|
<%=f.label :frequency, "Repeat every" %>
|
32
32
|
<%=f.select :frequency, (1..30).to_a %> <span id = "period"></span>
|
33
33
|
</p>
|
34
|
-
<%=f.hidden_field :id, :value => @event.id %>
|
35
34
|
<p>
|
36
|
-
<%=f.submit
|
35
|
+
<%=f.submit %> <span id = "creating_events" class="spinner" style = "display:none;">Creating, Please wait...</span>
|
37
36
|
</p>
|
38
37
|
<%end %>
|
@@ -1,14 +1,8 @@
|
|
1
1
|
<p>
|
2
|
-
<%= link_to 'Create Event', 'javascript:void()', :
|
2
|
+
<%= link_to 'Create Event', 'javascript:void()', id: 'new_event' %>
|
3
3
|
</p>
|
4
|
-
|
5
|
-
<%= content_tag :script do %>
|
6
|
-
full_calendar_options = <%= FullcalendarEngine::Configuration.to_json.html_safe %>
|
7
|
-
app_path = "<%= FullcalendarEngine::Configuration["mount_path"] %>"
|
8
|
-
<% end %>
|
9
|
-
|
10
4
|
<div>
|
11
|
-
<div
|
5
|
+
<div class='calendar'></div>
|
12
6
|
</div>
|
13
7
|
<div id="event_desc_dialog" class="dialog" style="display:none;"></div>
|
14
8
|
<div id="create_event_dialog" class="dialog" style ="display:none;">
|
@@ -17,7 +11,7 @@
|
|
17
11
|
|
18
12
|
<script>
|
19
13
|
$(document).ready(function(){
|
20
|
-
$('
|
14
|
+
$('.calendar').fullCalendar(full_calendar_options);
|
21
15
|
// page is now ready, initialize the calendar...
|
22
16
|
$('#new_event').click(function(event) {
|
23
17
|
FullcalendarEngine.Form.display()
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fullcalendar_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -55,11 +55,11 @@ files:
|
|
55
55
|
- app/assets/stylesheets/fullcalendar_engine/images/ui-bg_diagonals-thick_18_b81900_40x40.png
|
56
56
|
- app/assets/stylesheets/fullcalendar_engine/images/ui-bg_highlight-soft_75_ffe45c_1x100.png
|
57
57
|
- app/assets/stylesheets/fullcalendar_engine/images/ui-bg_diagonals-thick_20_666666_40x40.png
|
58
|
-
- app/assets/javascripts/fullcalendar_engine/events.js
|
59
58
|
- app/assets/javascripts/fullcalendar_engine/jquery-ui-1.10.3.custom.min.js
|
60
59
|
- app/assets/javascripts/fullcalendar_engine/fullcalendar.js
|
61
60
|
- app/assets/javascripts/fullcalendar_engine/application.js
|
62
61
|
- app/assets/javascripts/fullcalendar_engine/gcal.js
|
62
|
+
- app/assets/javascripts/fullcalendar_engine/events.js.erb
|
63
63
|
- app/models/fullcalendar_engine/event_series.rb
|
64
64
|
- app/models/fullcalendar_engine/event.rb
|
65
65
|
- app/controllers/fullcalendar_engine/events_controller.rb
|