From afb9c414f16aba17fae8053e29fb49a0bf5c30bb Mon Sep 17 00:00:00 2001 From: Klaus Zanders Date: Tue, 29 Apr 2025 12:27:31 +0200 Subject: [PATCH 1/2] Do not use UTC time for detecting total for days --- .../stimulus/controllers/dynamic/my/time-tracking.controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts b/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts index e5241f1319a..51fa3e578c3 100644 --- a/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts +++ b/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts @@ -246,7 +246,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; From 6f77e6320231dd5832704982d41c5576fe0239ce Mon Sep 17 00:00:00 2001 From: Klaus Zanders Date: Tue, 29 Apr 2025 12:28:04 +0200 Subject: [PATCH 2/2] fix an error to not close the dialog when we are not in the dialog --- .../app/controllers/time_entries_controller.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/costs/app/controllers/time_entries_controller.rb b/modules/costs/app/controllers/time_entries_controller.rb index 2865e586c05..9de5ccc9dbd 100644 --- a/modules/costs/app/controllers/time_entries_controller.rb +++ b/modules/costs/app/controllers/time_entries_controller.rb @@ -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