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

fix behavior that created a new time entry instead of updating the old one

Klaus Zandersd47f81f52730
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 c81c15257b8..70f45291a61 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
@@ -58,16 +58,22 @@ module TimeEntries
}
if time_entry.persisted?
- base.merge({
- url: time_entry_path(time_entry),
- method: :patch
- })
+ base.deep_merge({
+ url: time_entry_path(time_entry),
+ method: :patch,
+ data: {
+ refresh_form_url: refresh_form_time_entry_path(time_entry)
+ }
+ })
else
- base.merge({
- url: time_entries_path,
- method: :post
- })
+ base.deep_merge({
+ url: time_entries_path,
+ method: :post,
+ data: {
+ refresh_form_url: refresh_form_time_entries_path
+ }
+ })
end
end
end
diff --git a/modules/costs/app/controllers/time_entries_controller.rb b/modules/costs/app/controllers/time_entries_controller.rb
index 7598efb0570..191bb56a140 100644
--- a/modules/costs/app/controllers/time_entries_controller.rb
+++ b/modules/costs/app/controllers/time_entries_controller.rb
@@ -40,7 +40,7 @@ class TimeEntriesController < ApplicationController
before_action :load_and_authorize_optional_work_package
end
- before_action :load_or_build_and_authorize_time_entry, only: %i[dialog update destroy]
+ before_action :load_or_build_and_authorize_time_entry, only: %i[dialog update destroy refresh_form]
authorization_checked! :dialog, :create, :update, :user_tz_caption, :refresh_form, :destroy
@@ -68,7 +68,7 @@ class TimeEntriesController < ApplicationController
def refresh_form
call = TimeEntries::SetAttributesService.new(
user: current_user,
- model: TimeEntry.new,
+ model: @time_entry,
contract_class: EmptyContract
).call(permitted_params.time_entries)
diff --git a/modules/costs/config/routes.rb b/modules/costs/config/routes.rb
index bf5540981ee..ab1c4e3752b 100644
--- a/modules/costs/config/routes.rb
+++ b/modules/costs/config/routes.rb
@@ -34,6 +34,7 @@ Rails.application.routes.draw do
get :dialog, on: :member
get "/users/:user_id/tz_caption", action: :user_tz_caption, on: :collection
post :refresh_form, on: :collection
+ post :refresh_form, on: :member
end
scope "projects/:project_id", as: "projects" do