diff --git a/.gitignore b/.gitignore index 0a27bf8e565e..a677a999f576 100644 --- a/.gitignore +++ b/.gitignore @@ -134,6 +134,8 @@ structure.sql lefthook-local.yml .rubocop-local.yml +/.lefthook-local/ + frontend/package-lock.json # Testing and nextcloud infrastructure diff --git a/app/components/projects/row_component.rb b/app/components/projects/row_component.rb index 3f540eac0ecd..67cb4292198f 100644 --- a/app/components/projects/row_component.rb +++ b/app/components/projects/row_component.rb @@ -29,8 +29,9 @@ #++ module Projects class RowComponent < ::RowComponent - delegate :favored_project_ids, to: :table delegate :identifier, to: :project + delegate :favored_project_ids, to: :table + delegate :project_life_cycle_step_by_definition, to: :table def project model.first @@ -69,6 +70,8 @@ def currently_favored? def column_value(column) if custom_field_column?(column) custom_field_column(column) + elsif life_cycle_step_column?(column) + life_cycle_step_column(column) else send(column.attribute) end @@ -94,6 +97,16 @@ def custom_field_column(column) end end + def life_cycle_step_column(column) + return nil unless user_can_view_project? + + life_cycle_step = project_life_cycle_step_by_definition(column.life_cycle_step_definition, project) + + return nil if life_cycle_step.blank? + + fmt_date_or_range(life_cycle_step.start_date, life_cycle_step.end_date) + end + def created_at helpers.format_date(project.created_at) end @@ -374,8 +387,29 @@ def custom_field_column?(column) column.is_a?(::Queries::Projects::Selects::CustomField) end + def life_cycle_step_column?(column) + column.is_a?(::Queries::Projects::Selects::LifeCycleStep) + end + def current_page table.model.current_page.to_s end + + private + + # If only the `start_date` is given, will return a formatted version of that date as string. + # When `end_date` is given as well, will return a representation of the date range from start to end. + # @example + # fmt_date_or_range(Date.new(2024, 12, 4)) + # "04/12/2024" + # + # fmt_date_or_range(Date.new(2024, 12, 4), Date.new(2024, 12, 10)) + # "04/12/2024 - 10/12/2024" + def fmt_date_or_range(start_date, end_date = nil) + [start_date, end_date] + .compact + .map { |d| helpers.format_date(d) } + .join(" - ") + end end end diff --git a/app/components/projects/table_component.html.erb b/app/components/projects/table_component.html.erb index a114faeff841..9f33feb4aeea 100644 --- a/app/components/projects/table_component.html.erb +++ b/app/components/projects/table_component.html.erb @@ -56,7 +56,7 @@ See COPYRIGHT and LICENSE files for more details. <% else %> <% if use_quick_action_table_headers? %> - <%= quick_action_table_header column.attribute, order_options(column, turbo: true) %> + <%= quick_action_table_header column, order_options(column, turbo: true) %> <% else %>