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
Move Cells to new ViewComponents
Klaus Zanders99635571d353
diff --git a/modules/meeting/app/cells/meetings/row_cell.rb b/modules/meeting/app/cells/meetings/row_cell.rbdeleted file mode 100644index bd9556163f2..00000000000--- a/modules/meeting/app/cells/meetings/row_cell.rb+++ /dev/null@@ -1,25 +0,0 @@-module Meetings- class RowCell < ::RowCell- include ApplicationHelper-- def project- link_to_project model.project, {}, {}, false- end-- def title- link_to model.title, meeting_path(model)- end-- def start_time- safe_join([format_date(model.start_time), format_time(model.start_time, false)], " ")- end-- def duration- "#{number_with_delimiter model.duration} h"- end-- def location- h(model.location)- end- end-enddiff --git a/modules/meeting/app/cells/meetings/table_cell.rb b/modules/meeting/app/cells/meetings/table_cell.rbdeleted file mode 100644index 2213cfa57b8..00000000000--- a/modules/meeting/app/cells/meetings/table_cell.rb+++ /dev/null@@ -1,29 +0,0 @@-module Meetings- class TableCell < ::TableCell- options :current_project # used to determine if displaying the projects column-- sortable_columns :title, :start_time, :duration, :location-- def initial_sort- %i[start_time asc]- end-- def paginated?- true- end-- def headers- @headers ||= [- [:title, { caption: Meeting.human_attribute_name(:title) }],- current_project.blank? ? [:project, { caption: Meeting.human_attribute_name(:project) }] : nil,- [:start_time, { caption: Meeting.human_attribute_name(:start_time) }],- [:duration, { caption: Meeting.human_attribute_name(:duration) }],- [:location, { caption: Meeting.human_attribute_name(:location) }]- ].compact- end-- def columns- @columns ||= headers.map(&:first)- end- end-enddiff --git a/modules/meeting/app/components/meetings/row_component.rb b/modules/meeting/app/components/meetings/row_component.rbnew file mode 100644index 00000000000..b9855385f10--- /dev/null+++ b/modules/meeting/app/components/meetings/row_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 Meetings+ class RowComponent < ::RowComponent+ include ApplicationHelper++ def project+ link_to_project model.project, {}, {}, false+ end++ def title+ link_to model.title, meeting_path(model)+ end++ def start_time+ safe_join([format_date(model.start_time), format_time(model.start_time, false)], " ")+ end++ def duration+ "#{number_with_delimiter model.duration} h"+ end++ def location+ h(model.location)+ end+ end+enddiff --git a/modules/meeting/app/components/meetings/table_component.rb b/modules/meeting/app/components/meetings/table_component.rbnew file mode 100644index 00000000000..6d33134a7bd--- /dev/null+++ b/modules/meeting/app/components/meetings/table_component.rb@@ -0,0 +1,59 @@+# 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 Meetings+ class TableComponent < ::TableComponent+ options :current_project # used to determine if displaying the projects column++ sortable_columns :title, :start_time, :duration, :location++ def initial_sort+ %i[start_time asc]+ end++ def paginated?+ true+ end++ def headers+ @headers ||= [+ [:title, { caption: Meeting.human_attribute_name(:title) }],+ current_project.blank? ? [:project, { caption: Meeting.human_attribute_name(:project) }] : nil,+ [:start_time, { caption: Meeting.human_attribute_name(:start_time) }],+ [:duration, { caption: Meeting.human_attribute_name(:duration) }],+ [:location, { caption: Meeting.human_attribute_name(:location) }]+ ].compact+ end++ def columns+ @columns ||= headers.map(&:first)+ end+ end+enddiff --git a/modules/meeting/app/views/meetings/index.html.erb b/modules/meeting/app/views/meetings/index.html.erbindex 563079fecaf..e1dbe78001b 100644--- a/modules/meeting/app/views/meetings/index.html.erb+++ b/modules/meeting/app/views/meetings/index.html.erb@@ -47,5 +47,5 @@ See COPYRIGHT and LICENSE files for more details.<% if @meetings.empty? -%><%= no_results_box %><% else -%>-<%= rails_cell Meetings::TableCell, @meetings, current_project: @project %>+<%= render Meetings::TableComponent.new(rows: @meetings, current_project: @project) %><% end -%>