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 37b641e8de1..f695d3784f4 100644 --- a/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts +++ b/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts @@ -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; 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