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

enable update method

Klaus Zanders5145c2495fbf
diff --git a/modules/costs/app/components/time_entries/time_entry_form_component.rb b/modules/costs/app/components/time_entries/time_entry_form_component.rb
index 887e712496c..648b155980c 100644
--- a/modules/costs/app/components/time_entries/time_entry_form_component.rb
+++ b/modules/costs/app/components/time_entries/time_entry_form_component.rb
@@ -54,7 +54,7 @@ module TimeEntries
if time_entry.persisted?
base.merge({
url: project_time_entry_path(project, time_entry),
- method: :post
+ method: :patch
})
else
diff --git a/modules/costs/app/contracts/time_entries/base_contract.rb b/modules/costs/app/contracts/time_entries/base_contract.rb
index 52aad1fda5d..1d9fdcf5aa6 100644
--- a/modules/costs/app/contracts/time_entries/base_contract.rb
+++ b/modules/costs/app/contracts/time_entries/base_contract.rb
@@ -69,6 +69,8 @@ module TimeEntries
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)
diff --git a/modules/costs/app/controllers/projects/time_entries_controller.rb b/modules/costs/app/controllers/projects/time_entries_controller.rb
index 3a5edf3e536..7cd85daa869 100644
--- a/modules/costs/app/controllers/projects/time_entries_controller.rb
+++ b/modules/costs/app/controllers/projects/time_entries_controller.rb
@@ -63,9 +63,22 @@ module Projects
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