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
[Op#57515]: Reuse custom fields view components
Kabiru Mwenja8118ecdb8d83
diff --git a/app/components/settings/project_custom_fields/project_custom_field_mapping/row_component.html.erb b/app/components/admin/custom_fields/custom_field_projects/row_component.html.erbsimilarity index 100%rename from app/components/settings/project_custom_fields/project_custom_field_mapping/row_component.html.erbrename to app/components/admin/custom_fields/custom_field_projects/row_component.html.erbdiff --git a/app/components/admin/custom_fields/custom_field_projects/row_component.rb b/app/components/admin/custom_fields/custom_field_projects/row_component.rbnew file mode 100644index 00000000000..fe94c8e9f65--- /dev/null+++ b/app/components/admin/custom_fields/custom_field_projects/row_component.rb@@ -0,0 +1,45 @@+#-- 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 Admin+ module CustomFields+ module CustomFieldProjects+ class RowComponent < Projects::RowComponent+ include OpTurbo::Streamable++ def wrapper_uniq_by+ "project-#{project.id}"+ end++ def more_menu_items+ []+ end+ end+ end+ end+enddiff --git a/app/components/admin/custom_fields/custom_field_projects/table_component.html.erb b/app/components/admin/custom_fields/custom_field_projects/table_component.html.erbnew file mode 100644index 00000000000..3488dfd2353--- /dev/null+++ b/app/components/admin/custom_fields/custom_field_projects/table_component.html.erb@@ -0,0 +1,32 @@+<%#-- 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.++++#%>++<%= component_wrapper(tag: "div", data: { turbo: true }) do %>+ <%= render_parent %>+<% end %>diff --git a/app/components/admin/custom_fields/custom_field_projects/table_component.rb b/app/components/admin/custom_fields/custom_field_projects/table_component.rbnew file mode 100644index 00000000000..9ef7650dab1--- /dev/null+++ b/app/components/admin/custom_fields/custom_field_projects/table_component.rb@@ -0,0 +1,62 @@+#-- 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 Admin+ module CustomFields+ module CustomFieldProjects+ class TableComponent < Projects::TableComponent+ include OpTurbo::Streamable++ def columns+ @columns ||= query.selects.reject { |select| select.is_a?(Queries::Selects::NotExistingSelect) }+ end++ def sortable?+ false+ end++ # @override optional_pagination_options are passed to the pagination_options+ # which are passed to #pagination_links_full in pagination_helper.rb+ #+ # In Turbo streamable components, we need to be able to specify the url_for(action:) so that links are+ # generated in the context of the component index action, instead of any turbo stream actions performing+ # partial updates on the page.+ #+ # params[:url_for_action] is passed to the pagination_options making it's way down to any pagination links+ # that are generated via link_to which calls url_for which uses the params[:url_for_action] to specify+ # the controller action that link_to should use.+ #+ def optional_pagination_options+ return super unless params[:url_for_action]++ super.merge(params: { action: params[:url_for_action] })+ end+ end+ end+ end+enddiff --git a/app/components/settings/project_custom_fields/project_custom_field_mapping/row_component.rb b/app/components/settings/project_custom_fields/project_custom_field_mapping/row_component.rbindex 0a4a86a2d3a..f785bfd2d76 100644--- a/app/components/settings/project_custom_fields/project_custom_field_mapping/row_component.rb+++ b/app/components/settings/project_custom_fields/project_custom_field_mapping/row_component.rb@@ -29,13 +29,7 @@module Settingsmodule ProjectCustomFieldsmodule ProjectCustomFieldMapping- class RowComponent < Projects::RowComponent- include OpTurbo::Streamable-- def wrapper_uniq_by- "project-#{project.id}"- end-+ class RowComponent < Admin::CustomFields::CustomFieldProjects::RowComponentdef more_menu_items@more_menu_items ||= [more_menu_detach_project].compactenddiff --git a/app/components/settings/project_custom_fields/project_custom_field_mapping/table_component.rb b/app/components/settings/project_custom_fields/project_custom_field_mapping/table_component.rbindex 0d62babb1d3..b63ca837dbc 100644--- a/app/components/settings/project_custom_fields/project_custom_field_mapping/table_component.rb+++ b/app/components/settings/project_custom_fields/project_custom_field_mapping/table_component.rb@@ -29,33 +29,7 @@module Settingsmodule ProjectCustomFieldsmodule ProjectCustomFieldMapping- class TableComponent < Projects::TableComponent # rubocop:disable OpenProject/AddPreviewForViewComponent- include OpTurbo::Streamable-- def columns- @columns ||= query.selects.reject { |select| select.is_a?(Queries::Selects::NotExistingSelect) }- end-- def sortable?- false- end-- # @override optional_pagination_options are passed to the pagination_options- # which are passed to #pagination_links_full in pagination_helper.rb- #- # In Turbo streamable components, we need to be able to specify the url_for(action:) so that links are- # generated in the context of the component index action, instead of any turbo stream actions performing- # partial updates on the page.- #- # params[:url_for_action] is passed to the pagination_options making it's way down to any pagination links- # that are generated via link_to which calls url_for which uses the params[:url_for_action] to specify- # the controller action that link_to should use.- #- def optional_pagination_options- return super unless params[:url_for_action]-- super.merge(params: { action: params[:url_for_action] })- end+ class TableComponent < Admin::CustomFields::CustomFieldProjects::TableComponentendendend