so now, when you add a PTO scheduled date, the calendar on your PTO page automatically updates to show this event :-)

This commit is contained in:
Ken Johnson
2013-05-31 10:31:35 -04:00
parent a6a38c773e
commit a599ca9862
2 changed files with 18 additions and 2 deletions
+16 -1
View File
@@ -18,8 +18,23 @@ class ScheduleController < ApplicationController
end
def get_pto_schedule
begin
schedules = current_user.paid_time_off.schedule
jfs = []
schedules.each do |s|
hash = Hash.new
hash[:id] = s[:id]
hash[:title] = s[:event_name]
hash[:start] = s[:date_begin]
hash[:end] = s[:date_end]
jfs << hash
end
rescue
end
respond_to do |format|
format.json {render :json => %q{[{"id":111,"title":"Event1","start":"2013-05-31","url":"http:\/\/yahoo.com\/"},{"id":222,"title":"Event2","start":"2013-05-30","end":"2013-05-30","url":"http:\/\/yahoo.com\/"}] }}
format.json do
render :json => jfs.to_json
end
end
end
+2 -1
View File
@@ -127,7 +127,7 @@
<script type="text/javascript">
$('#calendar').fullCalendar({
events: <%= get_pto_schedule_schedule_index_path.inspect.html_safe %>,
events: <%= get_pto_schedule_schedule_index_path(:format => "json").inspect.html_safe %>,
})
@@ -234,6 +234,7 @@ $("#cal_update_submit").click(function(event) {
$('#failure').show(500).delay(1500).fadeOut();
} else {
$('#success').show(500).delay(1500).fadeOut();
$('#calendar').fullCalendar('refetchEvents')
}
},
error: function(event) {