Skip to content

Commit

Permalink
enable update method
Browse files Browse the repository at this point in the history
  • Loading branch information
klaustopher committed Dec 5, 2024
1 parent cd57025 commit 5722697
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def form_options
if time_entry.persisted?
base.merge({
url: project_time_entry_path(project, time_entry),
method: :post
method: :patch
})
else

Expand Down
2 changes: 2 additions & 0 deletions modules/costs/app/contracts/time_entries/base_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def self.model
attribute :user_id,
permission: :log_time

attribute :start_time # TODO: Add validation with global setting

def assignable_activities
if model.project
TimeEntryActivity.active_in_project(model.project)
Expand Down
19 changes: 16 additions & 3 deletions modules/costs/app/controllers/projects/time_entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,22 @@ def create
end

def update
puts "*" * 100
pp(permitted_params.time_entries)
puts "*" * 100
time_entry = TimeEntry.find_by(id: params[:id])

call = TimeEntries::UpdateService
.new(user: current_user, model: time_entry)
.call(time_entry_params)

@time_entry = call.result

if call.success?
# TODO: just close here?
else
form_component = TimeEntries::TimeEntryFormComponent.new(time_entry: @time_entry)
update_via_turbo_stream(component: form_component, status: :bad_request)

respond_with_turbo_streams
end
end

private
Expand Down

0 comments on commit 5722697

Please sign in to comment.