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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
fix some labels and redirect to correct view mode
Klaus Zanders3ac027a4a127
diff --git a/modules/costs/app/components/my/time_tracking/header_component.html.erb b/modules/costs/app/components/my/time_tracking/header_component.html.erbindex 3fa0caefe7e..22696b5ca1b 100644--- a/modules/costs/app/components/my/time_tracking/header_component.html.erb+++ b/modules/costs/app/components/my/time_tracking/header_component.html.erb@@ -24,13 +24,15 @@button_arguments: { button_block: params[:view_mode] == "list" ? list_button : cal_button }) do |menu|menu.with_item(- label: "Calendar", tag: :a,+ label: t(:label_calendar),+ tag: :a,href: url_for(params.permit(:controller, :action, :date).merge(view_mode: "calendar"))) do |item|item.with_leading_visual_icon(icon: :calendar)endmenu.with_item(- label: "List", tag: :a,+ label: t(:label_list),+ tag: :a,href: url_for(params.permit(:controller, :action, :date).merge(view_mode: "list"))) do |item|item.with_leading_visual_icon(icon: "list-unordered")diff --git a/modules/costs/app/controllers/my/time_tracking_controller.rb b/modules/costs/app/controllers/my/time_tracking_controller.rbindex cf596ae1623..ae18f2fe518 100644--- a/modules/costs/app/controllers/my/time_tracking_controller.rb+++ b/modules/costs/app/controllers/my/time_tracking_controller.rb@@ -52,34 +52,22 @@ module Mydef calendarif browser.device.mobile?- redirect_to action: :day+ redirect_to action: :day, view_mode: default_view_modeelse- redirect_to action: :week+ redirect_to action: :week, view_mode: default_view_modeendenddef dayload_time_entries(current_day)-- # TODO: At some point the filters will reduce the list, so we need to load them seperately- @project_filters = @time_entries.map(&:project).uniq- @activity_filters = @time_entries.map(&:activity).uniqenddef weekload_time_entries(current_day.all_week)-- # TODO: At some point the filters will reduce the list, so we need to load them seperately- @project_filters = @time_entries.map(&:project).uniq- @activity_filters = @time_entries.map(&:activity).uniqenddef monthload_time_entries(current_day.all_month)-- # TODO: At some point the filters will reduce the list, so we need to load them seperately- @project_filters = @time_entries.map(&:project).uniq- @activity_filters = @time_entries.map(&:activity).uniqenddef today?@@ -110,6 +98,18 @@ module My@current_day = parsed_date || current_dateend+ def default_view_mode+ if TimeEntry.can_track_start_and_end_time?+ "calendar"+ else+ "list"+ end+ end++ def view_mode+ ActiveSupport::StringInquirer.new(params[:view_mode] || default_view_mode)+ end+def current_datecase params[:action].to_symwhen :day then Time.zone.today@@ -126,7 +126,7 @@ module Myenddef list_view_component- if params[:view_mode] == "list"+ if view_mode.list?My::TimeTracking::ListComponent.new(time_entries: @time_entries, mode: params[:action].to_sym, date: current_day)elseMy::TimeTracking::CalendarComponent.new(time_entries: @time_entries, mode: params[:action].to_sym, date: current_day)diff --git a/modules/costs/config/routes.rb b/modules/costs/config/routes.rbindex 08529386bbe..29a8ce80b38 100644--- a/modules/costs/config/routes.rb+++ b/modules/costs/config/routes.rb@@ -51,14 +51,11 @@ Rails.application.routes.draw doget "/timer" => "timer#show", as: "timers"get "/time-tracking" => "time_tracking#calendar"- get "/time-tracking/day(-:view_mode)" => "time_tracking#day",- defaults: { view_mode: "calendar" },+ get "/time-tracking/day(-:view_mode)(/:date)" => "time_tracking#day",as: :time_tracking_day- get "/time-tracking/week(-:view_mode)" => "time_tracking#week",- defaults: { view_mode: "calendar" },+ get "/time-tracking/week(-:view_mode)(/:date)" => "time_tracking#week",as: :time_tracking_week- get "/time-tracking/month(-:view_mode)" => "time_tracking#month",- defaults: { view_mode: "calendar" },+ get "/time-tracking/month(-:view_mode)(/:date)" => "time_tracking#month",as: :time_tracking_monthend