From a599ca9862f6d3936d994a9613ff13f97b842f69 Mon Sep 17 00:00:00 2001 From: Ken Johnson Date: Fri, 31 May 2013 10:31:35 -0400 Subject: [PATCH] so now, when you add a PTO scheduled date, the calendar on your PTO page automatically updates to show this event :-) --- app/controllers/schedule_controller.rb | 17 ++++++++++++++++- app/views/paid_time_off/index.html.erb | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb index 11f43f2..82d4736 100644 --- a/app/controllers/schedule_controller.rb +++ b/app/controllers/schedule_controller.rb @@ -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 diff --git a/app/views/paid_time_off/index.html.erb b/app/views/paid_time_off/index.html.erb index 599e753..4f28aac 100644 --- a/app/views/paid_time_off/index.html.erb +++ b/app/views/paid_time_off/index.html.erb @@ -127,7 +127,7 @@