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

Add an action to redirect to the correct view

Klaus Zanders9efb90418b5f
diff --git a/modules/costs/app/controllers/my/time_tracking_controller.rb b/modules/costs/app/controllers/my/time_tracking_controller.rb
index d87a65edc67..54248c0c85f 100644
--- a/modules/costs/app/controllers/my/time_tracking_controller.rb
+++ b/modules/costs/app/controllers/my/time_tracking_controller.rb
@@ -32,7 +32,7 @@ module My
class TimeTrackingController < ApplicationController
before_action :require_login
- no_authorization_required!(:day, :week, :month)
+ no_authorization_required!(:calendar, :day, :week, :month)
current_menu_item do |ctrl|
if ctrl.params[:action] == "day" && ctrl.today?
@@ -50,6 +50,11 @@ module My
helper_method :current_day, :today?, :this_week?, :this_month?, :time_entries_json
+ def calendar
+ # TODO: on mobile, we should show the day view
+ redirect_to action: :week
+ end
+
def day
load_time_entries(current_day)
diff --git a/modules/costs/config/routes.rb b/modules/costs/config/routes.rb
index 3f4d3d70702..92d16421f7f 100644
--- a/modules/costs/config/routes.rb
+++ b/modules/costs/config/routes.rb
@@ -50,6 +50,7 @@ Rails.application.routes.draw do
namespace "my" do
get "/timer" => "timer#show", as: "timers"
+ get "/time-tracking" => "time_tracking#calendar"
get "/time-tracking/day" => "time_tracking#day"
get "/time-tracking/week" => "time_tracking#week"
get "/time-tracking/month" => "time_tracking#month"
diff --git a/modules/costs/lib/costs/engine.rb b/modules/costs/lib/costs/engine.rb
index a321326683d..5366b3c45bd 100644
--- a/modules/costs/lib/costs/engine.rb
+++ b/modules/costs/lib/costs/engine.rb
@@ -144,7 +144,7 @@ module Costs
menu :global_menu,
:my_time_tracking,
- { controller: "/my/time_tracking", action: "week" },
+ { controller: "/my/time_tracking", action: "calendar" },
after: :my_page,
caption: :label_my_time_tracking,
icon: :stopwatch