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

refactor a bit more stuff

Klaus Zanders4f39ee95c313
diff --git a/modules/costs/app/components/my/time_tracking/calendar_component.html.erb b/modules/costs/app/components/my/time_tracking/calendar_component.html.erb
index d9b301699e3..edd6f7c9dd8 100644
--- a/modules/costs/app/components/my/time_tracking/calendar_component.html.erb
+++ b/modules/costs/app/components/my/time_tracking/calendar_component.html.erb
@@ -23,7 +23,9 @@
<div data-my--time-tracking-target="calendar"></div>
- <%- if mode != :day %>
- <div><%= total_hours %></div>
- <%- end %>
-<%- end %>
+ <% if mode != :day %>
+ <%= flex_layout(align_items: :flex_end) do |flex| %>
+ <% flex.with_row(mt: 2, font_weight: :bold) { total_hours } %>
+ <% end %>
+ <% end %>
+<% end %>
diff --git a/modules/costs/app/components/my/time_tracking/calendar_component.rb b/modules/costs/app/components/my/time_tracking/calendar_component.rb
index c6c39eccc7a..4a470fe99a5 100644
--- a/modules/costs/app/components/my/time_tracking/calendar_component.rb
+++ b/modules/costs/app/components/my/time_tracking/calendar_component.rb
@@ -32,7 +32,8 @@ module My
module TimeTracking
class CalendarComponent < ApplicationComponent
include OpTurbo::Streamable
- include ComponentNavigation
+ include OpPrimer::ComponentHelpers
+ include SharedComponent
options time_entries: [],
mode: :week,
diff --git a/modules/costs/app/components/my/time_tracking/list_component.html.erb b/modules/costs/app/components/my/time_tracking/list_component.html.erb
index 13dd2c0c42c..50b66aa528f 100644
--- a/modules/costs/app/components/my/time_tracking/list_component.html.erb
+++ b/modules/costs/app/components/my/time_tracking/list_component.html.erb
@@ -9,7 +9,7 @@
end
end
- component.with_action_button(tag: :a, href: today_href) { "Today" }
+ component.with_action_button(tag: :a, href: today_href) { t("label_today") }
component.with_action_button(
scheme: :primary,
diff --git a/modules/costs/app/components/my/time_tracking/list_component.rb b/modules/costs/app/components/my/time_tracking/list_component.rb
index 885763cbba4..4e1fea3c00c 100644
--- a/modules/costs/app/components/my/time_tracking/list_component.rb
+++ b/modules/costs/app/components/my/time_tracking/list_component.rb
@@ -32,7 +32,7 @@ module My
module TimeTracking
class ListComponent < ApplicationComponent
include OpTurbo::Streamable
- include ComponentNavigation
+ include SharedComponent
options time_entries: [],
mode: :week,
diff --git a/modules/costs/app/components/my/time_tracking/component_navigation.rb b/modules/costs/app/components/my/time_tracking/shared_component.rb
similarity index 90%
rename from modules/costs/app/components/my/time_tracking/component_navigation.rb
rename to modules/costs/app/components/my/time_tracking/shared_component.rb
index 175d1fdcb8c..618fd5b40a4 100644
--- a/modules/costs/app/components/my/time_tracking/component_navigation.rb
+++ b/modules/costs/app/components/my/time_tracking/shared_component.rb
@@ -30,7 +30,7 @@
#
module My
module TimeTracking
- module ComponentNavigation
+ module SharedComponent
extend ActiveSupport::Concern
def title # rubocop:disable Metrics/AbcSize
case mode
@@ -41,14 +41,14 @@ module My
eow = date.end_of_week
if bow.year == eow.year && bow.month == eow.month
- "#{bow.strftime('%d.')} - #{eow.strftime('%d. %B %Y')}"
+ [I18n.l(bow, format: "%d."), I18n.l(eow, format: "%d. %B %Y")].join(" - ")
elsif bow.year == eow.year
- "#{bow.strftime('%d. %B')} - #{eow.strftime('%d. %B %Y')}"
+ [I18n.l(bow, format: "%d. %B"), I18n.l(eow, format: "%d. %B %Y")].join(" - ")
else
- "#{bow.strftime('%d. %B %Y')} - #{eow.strftime('%d. %B %Y')}"
+ [I18n.l(bow, format: "%d. %B %Y"), I18n.l(eow, format: "%d. %B %Y")].join(" - ")
end
when :month
- date.strftime("%B %Y")
+ I18n.l(date, format: "%B %Y")
end
end
diff --git a/modules/costs/app/components/my/time_tracking/time_entry_row.rb b/modules/costs/app/components/my/time_tracking/time_entry_row.rb
index 4c4215b446d..d85fa6568ef 100644
--- a/modules/costs/app/components/my/time_tracking/time_entry_row.rb
+++ b/modules/costs/app/components/my/time_tracking/time_entry_row.rb
@@ -34,10 +34,12 @@ module My
def button_links
[
action_menu
- ]
+ ].compact
end
def action_menu
+ return nil unless User.current.allowed_in_work_package?(:edit_own_time_entries, time_entry.work_package)
+
render(Primer::Alpha::ActionMenu.new) do |menu|
menu.with_show_button(icon: "kebab-horizontal", "aria-label": t("label_more"), scheme: :invisible)
menu.with_item(
diff --git a/modules/costs/app/controllers/time_entries_controller.rb b/modules/costs/app/controllers/time_entries_controller.rb
index 7e5f15ab3d1..40fb48ef8d3 100644
--- a/modules/costs/app/controllers/time_entries_controller.rb
+++ b/modules/costs/app/controllers/time_entries_controller.rb
@@ -125,8 +125,6 @@ class TimeEntriesController < ApplicationController
form_component = TimeEntries::TimeEntryFormComponent.new(time_entry: @time_entry, **form_config_options)
update_via_turbo_stream(component: form_component, status: :bad_request)
end
-
- respond_with_turbo_streams
end
private