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
Use `with_tab_nav` in the page header instead of seperate component
Klaus Zanderse960ec2e3574
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.erbindex 82afbdfbdcd..9a4539d2adb 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@@ -1,7 +1,6 @@<% helpers.html_title t(:label_my_time_tracking), "#{t("label_#{mode}")} #{t(:label_calendar)} #{I18n.l(date)}" -%><%= flex_layout(data: wrapper_data, classes: "my-time-tracking-calendar-view") do |calendar_page| %><% calendar_page.with_row { render(My::TimeTracking::HeaderComponent.new(mode:, date:, view_mode: :calendar)) } %>- <% calendar_page.with_row { render(My::TimeTracking::ViewModeSwitcherComponent.new(mode:, date:, view_mode: :calendar)) } %><% calendar_page.with_row { render(My::TimeTracking::SubHeaderComponent.new(mode:, date:, view_mode: :calendar)) } %><% calendar_page.with_row(classes: "op-fc-wrapper", data: { "my--time-tracking-target" => "calendar" }) %>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 fa96e9ac17b..b1b6f725b5c 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@@ -7,5 +7,17 @@])+ header.with_tab_nav(label: I18n.t(:label_view_mode_switcher)) do |nav|+ nav.with_tab(selected: view_mode == :calendar, href: view_mode_switch_link(:calendar)) do |tab|+ tab.with_text { I18n.t(:label_calendar) }+ tab.with_icon(icon: :calendar)+ end++ nav.with_tab(selected: view_mode == :list, href: view_mode_switch_link(:list)) do |tab|+ tab.with_text { I18n.t(:label_list) }+ tab.with_icon(icon: "op-view-list")+ end+ end+header.with_action_zen_mode_buttonend %>diff --git a/modules/costs/app/components/my/time_tracking/header_component.rb b/modules/costs/app/components/my/time_tracking/header_component.rbindex 4ac91f705c6..f66e48fa79e 100644--- a/modules/costs/app/components/my/time_tracking/header_component.rb+++ b/modules/costs/app/components/my/time_tracking/header_component.rb@@ -32,6 +32,10 @@ module Mymodule TimeTrackingclass HeaderComponent < ApplicationComponentoptions :date, :mode, :view_mode++ def view_mode_switch_link(new_view_mode)+ my_time_tracking_path(date: date, mode: mode, view_mode: new_view_mode)+ endendendenddiff --git a/modules/costs/app/components/my/time_tracking/list_component.html.erb b/modules/costs/app/components/my/time_tracking/list_component.html.erbindex 06dfae607b9..0424eb7ead5 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@@ -1,7 +1,6 @@<% helpers.html_title t(:label_my_time_tracking), "#{t("label_#{mode}")} #{t(:label_list)} #{I18n.l(date)}" -%><%= component_wrapper(tag: "div", data: wrapper_data) do %><%= render(My::TimeTracking::HeaderComponent.new(mode:, date:, view_mode: :list)) %>- <%= render(My::TimeTracking::ViewModeSwitcherComponent.new(mode:, date:, view_mode: :list)) %><%= render(My::TimeTracking::SubHeaderComponent.new(mode:, date:, view_mode: :list)) %><%= flex_layout(classes: ["my-time-tracking-list-view"]) do |flex| %>diff --git a/modules/costs/app/components/my/time_tracking/view_mode_switcher_component.rb b/modules/costs/app/components/my/time_tracking/view_mode_switcher_component.rbdeleted file mode 100644index 225dce321ae..00000000000--- a/modules/costs/app/components/my/time_tracking/view_mode_switcher_component.rb+++ /dev/null@@ -1,57 +0,0 @@-# frozen_string_literal: true--# -- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-# ++--module My- module TimeTracking- class ViewModeSwitcherComponent < ApplicationComponent- options :mode,- :view_mode,- :date-- def call- render(Primer::Alpha::TabNav.new(label: I18n.t(:label_view_mode_switcher))) do |component|- component.with_tab(selected: view_mode == :calendar, href: link(:calendar)) do |tab|- tab.with_text { I18n.t(:label_calendar) }- tab.with_icon(icon: :calendar)- end-- component.with_tab(selected: view_mode == :list, href: link(:list)) do |tab|- tab.with_text { I18n.t(:label_list) }- tab.with_icon(icon: "op-view-list")- end- end- end-- def link(new_view_mode)- my_time_tracking_path(date: date, mode: mode, view_mode: new_view_mode)- end- end- end-end