Skip to content

Commit

Permalink
properly set the beginning of the week we're looking at
Browse files Browse the repository at this point in the history
  • Loading branch information
fermion committed Dec 19, 2023
1 parent a90dd4f commit 44e9bac
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/components/work_week_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<%= tag.turbo_frame id: turbo_frame_id do %>
<%= form_for @work_week, url: form_path, data: { work_week_target: "form" } do |form| %>
<%= hidden_field_tag :assignment_id, @assignment.id %>
<%= hidden_field_tag :beginning_of_week, @beginning_of_week %>
<%= form.hidden_field :cweek %>
<%= form.hidden_field :year %>
<%= form.hidden_field :beginning_of_week %>
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/staff_plans/work_weeks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class StaffPlans::WorkWeeksController < ApplicationController

before_action :set_beginning_of_week
def create
@work_week = assignment.work_weeks.create(create_work_week_params)
end
Expand All @@ -10,6 +12,10 @@ def update

private

def set_beginning_of_week
@beginning_of_week = params[:beginning_of_week].to_i
end

def create_work_week_params
params.require(:work_week).permit(:estimated_hours, :actual_hours, :cweek, :year, :beginning_of_week)
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/staff_plans/work_weeks/create.turbo_stream.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
work_week: @work_week,
assignment: @work_week.assignment,
work_week_beginning_of_week: @work_week.beginning_of_week,
beginning_of_week: @work_week.beginning_of_week,
beginning_of_week: @beginning_of_week,
render_td: false
))
) %>
2 changes: 1 addition & 1 deletion app/views/staff_plans/work_weeks/update.turbo_stream.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
work_week: @work_week,
assignment: @work_week.assignment,
work_week_beginning_of_week: @work_week.beginning_of_week,
beginning_of_week: @work_week.beginning_of_week,
beginning_of_week: @beginning_of_week,
render_td: false
))
) %>

0 comments on commit 44e9bac

Please sign in to comment.