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:
@@ -18,8 +18,23 @@ class ScheduleController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_pto_schedule
|
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|
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$('#calendar').fullCalendar({
|
$('#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();
|
$('#failure').show(500).delay(1500).fadeOut();
|
||||||
} else {
|
} else {
|
||||||
$('#success').show(500).delay(1500).fadeOut();
|
$('#success').show(500).delay(1500).fadeOut();
|
||||||
|
$('#calendar').fullCalendar('refetchEvents')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(event) {
|
error: function(event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user