made some big changes here. The schedule had a has_one relationship with the PTO model. That is a problem since we only get one result back. meaning, a user cant have multiple scheduled events. This has been fixed with the use of has_many within the PTO model. Now, in relation to the PTO section, the next changes to happen are to be a fully functional create action that allows an event to be schedule, the form and controller has already been created. Umm, also, a calendar has been added and when we get the results back from a call to the create event action we will update that calendar. Think that is about it for now
This commit is contained in:
@@ -2,5 +2,6 @@ class PaidTimeOffController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@pto = current_user.paid_time_off
|
@pto = current_user.paid_time_off
|
||||||
|
@schedule = Schedule.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
class ScheduleController < ApplicationController
|
||||||
|
def create
|
||||||
|
respond_to do |format|
|
||||||
|
format.json {render :json => {:msg => "success"}}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
module ScheduleHelper
|
||||||
|
end
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
class PaidTimeOff < ActiveRecord::Base
|
class PaidTimeOff < ActiveRecord::Base
|
||||||
attr_accessible :pto_earned, :pto_taken, :sick_days_earned, :sick_days_taken, :user_id
|
attr_accessible :pto_earned, :pto_taken, :sick_days_earned, :sick_days_taken, :user_id
|
||||||
belongs_to :user
|
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
|
def sick_days_remaining
|
||||||
self.sick_days_earned - self.sick_days_taken
|
self.sick_days_earned - self.sick_days_taken
|
||||||
|
|||||||
@@ -23,27 +23,43 @@
|
|||||||
<span class="fs1" aria-hidden="true" data-icon=""></span> Schedule PTO
|
<span class="fs1" aria-hidden="true" data-icon=""></span> Schedule PTO
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="widget-body">
|
<!-- Begin WB-->
|
||||||
<form class="form-horizontal" action="#">
|
<div class="widget-body">
|
||||||
|
<%= form_for @schedule, :url => "#",:html => {:id => "cal_update"} do |s|%>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="date_range1">
|
<%= s.label :event_name, "Event Name", {:class => "control-label"}%>
|
||||||
Date Range Input
|
<%= s.text_field :event_name, {:placeholder => "My PTO", :class => "span6"}%>
|
||||||
</label>
|
</div>
|
||||||
<div class="controls">
|
<div class="control-group">
|
||||||
<div class="input-append">
|
<%= s.text_field :event_type, {:type => "hidden", :value => "pto", :class => "span6"}%>
|
||||||
<input type="text" name="date_range1" id="date_range1" class="span8 date_picker" placeholder="Select Date"/>
|
</div>
|
||||||
<span class="add-on">
|
<div class="control-group">
|
||||||
<i class="icon-calendar"></i>
|
<%= s.label :event_desc, "Event Description", {:class => "control-label"}%>
|
||||||
</span>
|
<%= s.text_field :event_desc, {:placeholder => "Travel to Europe", :class => "span6"}%>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="control-group">
|
||||||
</div>
|
<label class="control-label" for="date_range1">
|
||||||
|
Event Dates
|
||||||
|
</label>
|
||||||
</form>
|
<div class="controls">
|
||||||
</div>
|
<div class="input-append">
|
||||||
</div>
|
<input type="text" name="date_range1" id="date_range1" class="span8 date_picker" placeholder="Select Date"/>
|
||||||
|
<span class="add-on">
|
||||||
|
<i class="icon-calendar"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= s.submit "Submit", {:id => 'cal_update_submit', :class => "btn btn-primary pull-left"} %>
|
||||||
|
<% end %>
|
||||||
|
<div class="clearfix">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- End WB-->
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- End DP-->
|
<!-- End DP-->
|
||||||
@@ -176,4 +192,21 @@ function drawChart2() {
|
|||||||
chart.draw(data, options);
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -35,6 +35,10 @@ resources :tutorials do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :schedule do
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
resources :admin do
|
resources :admin do
|
||||||
get "dashboard"
|
get "dashboard"
|
||||||
get "get_user"
|
get "get_user"
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ScheduleControllerTest < ActionController::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ScheduleHelperTest < ActionView::TestCase
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user