diff --git a/app/controllers/paid_time_off_controller.rb b/app/controllers/paid_time_off_controller.rb index 07f571b..ea64301 100644 --- a/app/controllers/paid_time_off_controller.rb +++ b/app/controllers/paid_time_off_controller.rb @@ -2,5 +2,6 @@ class PaidTimeOffController < ApplicationController def index @pto = current_user.paid_time_off + @schedule = Schedule.new end end diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb new file mode 100644 index 0000000..f33cea5 --- /dev/null +++ b/app/controllers/schedule_controller.rb @@ -0,0 +1,7 @@ +class ScheduleController < ApplicationController + def create + respond_to do |format| + format.json {render :json => {:msg => "success"}} + end + end +end diff --git a/app/helpers/schedule_helper.rb b/app/helpers/schedule_helper.rb new file mode 100644 index 0000000..3334a9b --- /dev/null +++ b/app/helpers/schedule_helper.rb @@ -0,0 +1,2 @@ +module ScheduleHelper +end diff --git a/app/models/paid_time_off.rb b/app/models/paid_time_off.rb index f2bdcdd..9fb6194 100644 --- a/app/models/paid_time_off.rb +++ b/app/models/paid_time_off.rb @@ -1,7 +1,7 @@ class PaidTimeOff < ActiveRecord::Base attr_accessible :pto_earned, :pto_taken, :sick_days_earned, :sick_days_taken, :user_id belongs_to :user - has_one :schedule, :foreign_key => :user_id, :primary_key => :user_id + has_many :schedule, :foreign_key => :user_id, :primary_key => :user_id def sick_days_remaining self.sick_days_earned - self.sick_days_taken diff --git a/app/views/paid_time_off/index.html.erb b/app/views/paid_time_off/index.html.erb index 12c9cc7..f1ceeca 100644 --- a/app/views/paid_time_off/index.html.erb +++ b/app/views/paid_time_off/index.html.erb @@ -23,27 +23,43 @@ Schedule PTO -
-
- -
- -
-
- - - - -
-
-
- - -
-
- + +
+ <%= form_for @schedule, :url => "#",:html => {:id => "cal_update"} do |s|%> +
+ <%= s.label :event_name, "Event Name", {:class => "control-label"}%> + <%= s.text_field :event_name, {:placeholder => "My PTO", :class => "span6"}%> +
+
+ <%= s.text_field :event_type, {:type => "hidden", :value => "pto", :class => "span6"}%> +
+
+ <%= s.label :event_desc, "Event Description", {:class => "control-label"}%> + <%= s.text_field :event_desc, {:placeholder => "Travel to Europe", :class => "span6"}%> +
+
+ +
+
+ + + + +
+
+
+ <%= s.submit "Submit", {:id => 'cal_update_submit', :class => "btn btn-primary pull-left"} %> + <% end %> +
+
+ + + +
+ + @@ -176,4 +192,21 @@ function drawChart2() { chart.draw(data, options); } +$("#cal_update_submit").click(function(event) { + var valuesToSubmit = $("#cal_update").serialize(); + event.preventDefault(); + $.ajax({ + url: "/schedule.json", + data: valuesToSubmit, + type: "POST", + success: function(response) { + $('#success').show(500).delay(1500).fadeOut(); + + }, + error: function(event) { + $('#failure').show(500).delay(1500).fadeOut(); + } + }); +}); + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index fbb0567..3fbab21 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,6 +35,10 @@ resources :tutorials do end end +resources :schedule do + +end + resources :admin do get "dashboard" get "get_user" diff --git a/test/functional/schedule_controller_test.rb b/test/functional/schedule_controller_test.rb new file mode 100644 index 0000000..25a9061 --- /dev/null +++ b/test/functional/schedule_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ScheduleControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/helpers/schedule_helper_test.rb b/test/unit/helpers/schedule_helper_test.rb new file mode 100644 index 0000000..9955464 --- /dev/null +++ b/test/unit/helpers/schedule_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class ScheduleHelperTest < ActionView::TestCase +end