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

show today/yesterday

Klaus Zanderse024f07d5802
diff --git a/modules/costs/app/components/my/time_tracking/table_component.html.erb b/modules/costs/app/components/my/time_tracking/list_component.html.erb
similarity index 91%
rename from modules/costs/app/components/my/time_tracking/table_component.html.erb
rename to modules/costs/app/components/my/time_tracking/list_component.html.erb
index 3bd72e72d76..13dd2c0c42c 100644
--- a/modules/costs/app/components/my/time_tracking/table_component.html.erb
+++ b/modules/costs/app/components/my/time_tracking/list_component.html.erb
@@ -22,7 +22,9 @@
end %>
<%- range.each_with_index do |date, i| %>
- <%= render(Primer::OpenProject::Heading.new(tag: :h2, classes: class_names("mt-3" => !i.zero?))) { date.strftime("%A %d") } %>
+ <%= render(Primer::OpenProject::Heading.new(tag: :h2, classes: class_names("mt-3" => !i.zero?))) do
+ date_title(date)
+ end %>
<%= render(My::TimeTracking::DailyEntriesTable.new(rows: time_entries_by_day[date], date: date)) %>
<%- end %>
<%- end %>
diff --git a/modules/costs/app/components/my/time_tracking/table_component.rb b/modules/costs/app/components/my/time_tracking/list_component.rb
similarity index 84%
rename from modules/costs/app/components/my/time_tracking/table_component.rb
rename to modules/costs/app/components/my/time_tracking/list_component.rb
index fa4056bd8a5..701057a3cbc 100644
--- a/modules/costs/app/components/my/time_tracking/table_component.rb
+++ b/modules/costs/app/components/my/time_tracking/list_component.rb
@@ -30,7 +30,7 @@
module My
module TimeTracking
- class TableComponent < ApplicationComponent
+ class ListComponent < ApplicationComponent
include OpTurbo::Streamable
include ComponentNavigation
@@ -65,6 +65,18 @@ module My
total_hours = time_entries_by_day[date].sum(&:hours).round(2)
DurationConverter.output(total_hours, format: :hours_and_minutes)
end
+
+ def date_title(date)
+ result = [date.strftime("%A %d")]
+
+ if date.today?
+ result << render(Primer::Beta::Text.new(color: :muted)) { t("label_today") }
+ elsif date.yesterday?
+ result << render(Primer::Beta::Text.new(color: :muted)) { t("label_yesterday") }
+ end
+
+ safe_join(result, " ")
+ end
end
end
end
diff --git a/modules/costs/app/controllers/my/time_tracking_controller.rb b/modules/costs/app/controllers/my/time_tracking_controller.rb
index 7c2f1594d9a..cf596ae1623 100644
--- a/modules/costs/app/controllers/my/time_tracking_controller.rb
+++ b/modules/costs/app/controllers/my/time_tracking_controller.rb
@@ -127,7 +127,7 @@ module My
def list_view_component
if params[:view_mode] == "list"
- My::TimeTracking::TableComponent.new(time_entries: @time_entries, mode: params[:action].to_sym, date: current_day)
+ My::TimeTracking::ListComponent.new(time_entries: @time_entries, mode: params[:action].to_sym, date: current_day)
else
My::TimeTracking::CalendarComponent.new(time_entries: @time_entries, mode: params[:action].to_sym, date: current_day)
end