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
Correct page header and extract redundant sub header
Klaus Zanders1bc09d6aa5e4
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 ddbeadf9292..618580688ef 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,33 +1,6 @@<%= flex_layout(data: wrapper_data, classes: "time-entry-calendar") do |calendar_page| %>-<% calendar_page.with_row { render(My::TimeTracking::HeaderComponent.new(mode:, date:, view_mode: :calendar)) } %>-<% calendar_page.with_row do %>- <%= render(Primer::OpenProject::SubHeader.new) do |component|- component.with_filter_component do- render(My::TimeTracking::ModeSwitcherComponent.new(current_mode: mode, view_mode: :calendar))- end-- component.with_text { title }-- component.with_action_component do- render(Primer::Beta::ButtonGroup.new) do |group|- group.with_button(icon: "arrow-left", tag: :a, **previous_attrs)- group.with_button(icon: "arrow-right", tag: :a, **next_attrs)- end- end-- component.with_action_button(tag: :a, href: today_href) { I18n.t(:label_today) }-- component.with_action_button(- scheme: :primary,- data: {- "turbo-stream" => true- },- tag: :a,- href: dialog_time_entries_path(onlyMe: true)- ) { t(:button_log_time) }- end %>- <% end %>-+ <% calendar_page.with_row { render(My::TimeTracking::HeaderComponent.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" }) %><% if mode != :day %>diff --git a/modules/costs/app/components/my/time_tracking/calendar_component.rb b/modules/costs/app/components/my/time_tracking/calendar_component.rbindex 4a470fe99a5..f502d4d1ef7 100644--- a/modules/costs/app/components/my/time_tracking/calendar_component.rb+++ b/modules/costs/app/components/my/time_tracking/calendar_component.rb@@ -33,7 +33,6 @@ module Myclass CalendarComponent < ApplicationComponentinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers- include SharedComponentoptions time_entries: [],mode: :week,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 27bcf1636f2..dc850a30bad 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@@ -1,9 +1,9 @@<%= render(Primer::OpenProject::PageHeader.new) do |header|- header.with_title(variant: :large) { title }+ header.with_title { I18n.t(:label_my_time_tracking) }header.with_breadcrumbs([- { text: I18n.t(:label_my_time_tracking), href: my_time_tracking_path },- title+ { href: home_path, text: helpers.organization_name },+ { text: I18n.t(:label_my_time_tracking), href: my_time_tracking_path }])diff --git a/modules/costs/app/components/my/time_tracking/header_component.rb b/modules/costs/app/components/my/time_tracking/header_component.rbindex 3b3adb37f79..91f70a3a9d9 100644--- a/modules/costs/app/components/my/time_tracking/header_component.rb+++ b/modules/costs/app/components/my/time_tracking/header_component.rb@@ -33,38 +33,6 @@ module Myclass HeaderComponent < ApplicationComponentoptions :date, :mode, :view_mode- def title- case mode- when :week then week_title- when :month then month_title- when :day then day_title- end- end-- def day_title- if Date.current == date- I18n.t(:label_today)- else- I18n.t(:label_specific_day, day: I18n.l(date, format: :short))- end- end-- def week_title- if Date.current.all_week.include?(date)- I18n.t(:label_this_week)- else- I18n.t(:label_specific_week, week: I18n.l(date, format: "%W %Y"))- end- end-- def month_title- if Date.current.all_month.include?(date)- I18n.t(:label_this_month)- else- I18n.t(:label_specific_month, month: I18n.l(date, format: "%B %Y"))- end- end-def view_mode_blockif view_mode == :listlambda do |button|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.erbindex 49f20518569..b9988e90c71 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,30 +1,6 @@<%= component_wrapper(tag: "div", data: wrapper_data) do %><%= render(My::TimeTracking::HeaderComponent.new(mode:, date:, view_mode: :list)) %>- <%= render(Primer::OpenProject::SubHeader.new) do |component|- component.with_filter_component do- render(My::TimeTracking::ModeSwitcherComponent.new(current_mode: mode, view_mode: :list))- end-- component.with_text { title }-- component.with_action_component do- render(Primer::Beta::ButtonGroup.new) do |group|- group.with_button(icon: "arrow-left", tag: :a, **previous_attrs)- group.with_button(icon: "arrow-right", tag: :a, **next_attrs)- end- end-- component.with_action_button(tag: :a, href: today_href) { t(:label_today) }-- component.with_action_button(- scheme: :primary,- data: {- "turbo-stream" => true- },- tag: :a,- href: dialog_time_entries_path(onlyMe: true)- ) { t(:button_log_time) }- end %>+ <%= render(My::TimeTracking::SubHeaderComponent.new(mode:, date:, view_mode: :list)) %><%- range.each_with_index do |date, i| %><%= render(Primer::OpenProject::Heading.new(tag: :h2, classes: class_names("mt-3" => !i.zero?))) dodiff --git a/modules/costs/app/components/my/time_tracking/list_component.rb b/modules/costs/app/components/my/time_tracking/list_component.rbindex 9f74645253b..fb94d9ba26f 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,6 @@ module Mymodule TimeTrackingclass ListComponent < ApplicationComponentinclude OpTurbo::Streamable- include SharedComponentoptions time_entries: [],mode: :week,diff --git a/modules/costs/app/components/my/time_tracking/sub_header_component.html.erb b/modules/costs/app/components/my/time_tracking/sub_header_component.html.erbnew file mode 100644index 00000000000..f3cbceefe02--- /dev/null+++ b/modules/costs/app/components/my/time_tracking/sub_header_component.html.erb@@ -0,0 +1,30 @@+<%= render(Primer::OpenProject::SubHeader.new) do |component|+ component.with_filter_component do+ render(My::TimeTracking::ModeSwitcherComponent.new(current_mode: mode, view_mode: view_mode))+ end++ component.with_text { title }++ component.with_action_component do+ render(Primer::Beta::ButtonGroup.new) do |group|+ group.with_button(icon: "arrow-left", tag: :a, **previous_attrs)+ group.with_button(icon: "arrow-right", tag: :a, **next_attrs)+ end+ end++ component.with_action_button(tag: :a, href: today_href) do |button|+ button.with_leading_visual_icon(icon: "op-calendar-day")+ I18n.t(:label_today_capitalized)+ end++ component.with_action_button(+ scheme: :primary,+ data: { "turbo-stream" => true },+ aria: { "label" => t(:button_log_time) },+ tag: :a,+ href: dialog_time_entries_path(onlyMe: true)+ ) do |button|+ button.with_leading_visual_icon(icon: "plus")+ t(:button_log_time)+ end+ end %>diff --git a/modules/costs/app/components/my/time_tracking/shared_component.rb b/modules/costs/app/components/my/time_tracking/sub_header_component.rbsimilarity index 97%rename from modules/costs/app/components/my/time_tracking/shared_component.rbrename to modules/costs/app/components/my/time_tracking/sub_header_component.rbindex 618fd5b40a4..0428a2516a2 100644--- a/modules/costs/app/components/my/time_tracking/shared_component.rb+++ b/modules/costs/app/components/my/time_tracking/sub_header_component.rb@@ -27,11 +27,12 @@## See COPYRIGHT and LICENSE files for more details.# ++-#+module Mymodule TimeTracking- module SharedComponent- extend ActiveSupport::Concern+ class SubHeaderComponent < ApplicationComponent+ options :date, :mode, :view_mode+def title # rubocop:disable Metrics/AbcSizecase modewhen :day