Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

form submission saves a time entry

Klaus Zanders52fe47d7ffc0
diff --git a/modules/costs/app/controllers/projects/time_entries_controller.rb b/modules/costs/app/controllers/projects/time_entries_controller.rb
index 798361ed2d6..3a5edf3e536 100644
--- a/modules/costs/app/controllers/projects/time_entries_controller.rb
+++ b/modules/costs/app/controllers/projects/time_entries_controller.rb
@@ -46,9 +46,20 @@ module Projects
end
def create
- puts "*" * 100
- pp(permitted_params.time_entries)
- puts "*" * 100
+ call = TimeEntries::CreateService
+ .new(user: current_user)
+ .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
def update
@@ -56,5 +67,13 @@ module Projects
pp(permitted_params.time_entries)
puts "*" * 100
end
+
+ private
+
+ def time_entry_params
+ permitted_params.time_entries.merge(
+ project_id: @project.id
+ )
+ end
end
end
diff --git a/modules/costs/lib/costs/patches/permitted_params_patch.rb b/modules/costs/lib/costs/patches/permitted_params_patch.rb
index 8570d9eda61..50356c8d6ac 100644
--- a/modules/costs/lib/costs/patches/permitted_params_patch.rb
+++ b/modules/costs/lib/costs/patches/permitted_params_patch.rb
@@ -72,7 +72,7 @@ module Costs::Patches::PermittedParamsPatch
:spent_on,
:start_time,
:work_package_id,
- :activity,
+ :activity_id,
:project_id,
:issue_id,
:user_id