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
[#47017] Replace Versions::TableCell by ViewComponent
Dombi Attila96fe5942b1e7
diff --git a/app/cells/versions/table_cell.rb b/app/cells/versions/table_cell.rbdeleted file mode 100644index cb888546ad5..00000000000--- a/app/cells/versions/table_cell.rb+++ /dev/null@@ -1,23 +0,0 @@-module Versions- class TableCell < ::TableCell- columns :name, :project, :start_date, :effective_date, :description, :status, :sharing, :wiki_page_title-- def sortable?- false- end-- def headers- columns.reject { |col| col == :wiki_page_title }.map do |name|- [name.to_s, header_options(name)]- end + [wiki_page_header_options]- end-- def header_options(name)- { caption: Version.human_attribute_name(name) }- end-- def wiki_page_header_options- ['wiki_page_title', { caption: WikiPage.model_name.human }]- end- end-enddiff --git a/app/cells/versions/row_cell.rb b/app/components/versions/row_component.rbsimilarity index 98%rename from app/cells/versions/row_cell.rbrename to app/components/versions/row_component.rbindex a98ab1a96e8..f3e9a94b834 100644--- a/app/cells/versions/row_cell.rb+++ b/app/components/versions/row_component.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) 2012-2023 the OpenProject GmbH@@ -27,7 +29,7 @@#++module Versions- class RowCell < ::RowCell+ class RowComponent < ::RowComponentinclude VersionsHelper# Overriding cell's method to set the project instance variable.diff --git a/app/components/versions/table_component.rb b/app/components/versions/table_component.rbnew file mode 100644index 00000000000..02b84793dd5--- /dev/null+++ b/app/components/versions/table_component.rb@@ -0,0 +1,55 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 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 Versions+ class TableComponent < ::TableComponent+ options :project++ columns :name, :project, :start_date, :effective_date, :description, :status, :sharing, :wiki_page_title++ def sortable?+ false+ end++ def headers+ columns.reject { |col| col == :wiki_page_title }.map do |name|+ [name.to_s, header_options(name)]+ end + [wiki_page_header_options]+ end++ def header_options(name)+ { caption: Version.human_attribute_name(name) }+ end++ def wiki_page_header_options+ ['wiki_page_title', { caption: WikiPage.model_name.human }]+ end+ end+enddiff --git a/app/views/projects/settings/versions/show.html.erb b/app/views/projects/settings/versions/show.html.erbindex f36c54c7999..48cc9c6e8c6 100644--- a/app/views/projects/settings/versions/show.html.erb+++ b/app/views/projects/settings/versions/show.html.erb@@ -42,7 +42,7 @@ See COPYRIGHT and LICENSE files for more details.<% end %><% if @versions.any? %>- <%= rails_cell Versions::TableCell, @versions, project: @project %>+ <%= render Versions::TableComponent.new(rows: @versions, project: @project) %><% if @project.versions.any? %><div class="generic-table--action-buttons">diff --git a/modules/backlogs/lib/open_project/backlogs/engine.rb b/modules/backlogs/lib/open_project/backlogs/engine.rbindex 5806b9b2d3f..22b1a43e00b 100644--- a/modules/backlogs/lib/open_project/backlogs/engine.rb+++ b/modules/backlogs/lib/open_project/backlogs/engine.rb@@ -139,7 +139,7 @@ module OpenProject::Backlogspatch_with_namespace :WorkPackages, :UpdateServicepatch_with_namespace :WorkPackages, :SetAttributesServicepatch_with_namespace :WorkPackages, :BaseContract- patch_with_namespace :Versions, :RowCell+ patch_with_namespace :Versions, :RowComponentconfig.to_prepare donext if Versions::BaseContract.included_modules.include?(OpenProject::Backlogs::Patches::Versions::BaseContractPatch)diff --git a/modules/backlogs/lib/open_project/backlogs/patches/versions/row_cell_patch.rb b/modules/backlogs/lib/open_project/backlogs/patches/versions/row_component_patch.rbsimilarity index 96%rename from modules/backlogs/lib/open_project/backlogs/patches/versions/row_cell_patch.rbrename to modules/backlogs/lib/open_project/backlogs/patches/versions/row_component_patch.rbindex 502ab4cbc8e..7f9cad8c407 100644--- a/modules/backlogs/lib/open_project/backlogs/patches/versions/row_cell_patch.rb+++ b/modules/backlogs/lib/open_project/backlogs/patches/versions/row_component_patch.rb@@ -26,7 +26,7 @@# See COPYRIGHT and LICENSE files for more details.#++-module OpenProject::Backlogs::Patches::Versions::RowCellPatch+module OpenProject::Backlogs::Patches::Versions::RowComponentPatchdef button_links(super + [backlogs_edit_link]).compactend