Merge pull request #18764 from opf/bug/63690

Fix wrong calculation for time entries without start&end times
This commit is contained in:
Klaus Zanders
2025-04-30 09:23:50 +02:00
committed by GitHub
2 changed files with 12 additions and 6 deletions
@@ -252,7 +252,7 @@ export default class MyTimeTrackingController extends Controller {
if (!eventStart) return;
// Format event date for comparison
const eventDateStr = eventStart.toISOString().slice(0, 10);
const eventDateStr = moment(eventStart).format('YYYY-MM-DD');
if (eventDateStr === dayStr && event.extendedProps && event.extendedProps.hours) {
totalHours += event.extendedProps.hours as number;
@@ -107,13 +107,15 @@ class TimeEntriesController < ApplicationController
@time_entry = call.result
if call.success?
close_dialog_via_turbo_stream("#time-entry-dialog", additional: { spent_on: @time_entry.spent_on })
elsif params[:no_dialog]
render_error_flash_message_via_turbo_stream(message: t("notice_time_entry_update_failed",
errors: call.errors.full_messages.join(", ")))
else
if request_from_dialog?
close_dialog_via_turbo_stream("#time-entry-dialog", additional: { spent_on: @time_entry.spent_on })
end
elsif call.failure? && request_from_dialog?
form_component = TimeEntries::TimeEntryFormComponent.new(time_entry: @time_entry, **form_config_options)
update_via_turbo_stream(component: form_component, status: :bad_request)
else
render_error_flash_message_via_turbo_stream(message: t("notice_time_entry_update_failed",
errors: call.errors.full_messages.join(", ")))
end
respond_with_turbo_streams(status: call.success? ? :ok : :bad_request)
@@ -134,6 +136,10 @@ class TimeEntriesController < ApplicationController
private
def request_from_dialog?
!ActiveModel::Type::Boolean.new.cast(params[:no_dialog])
end
def prefill_time_entry_from_params # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
# correct time calcuation needs a time zone
@time_entry.time_zone ||= User.current.time_zone.name