Skip to content

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

Ensure Calendar Index Pages sort by `project_name`

Aaron Contrerase10d207de009
diff --git a/modules/calendar/app/components/calendar/row_component.rb b/modules/calendar/app/components/calendar/row_component.rb
index 17f7e5433c7..040f3f43d79 100644
--- a/modules/calendar/app/components/calendar/row_component.rb
+++ b/modules/calendar/app/components/calendar/row_component.rb
@@ -38,7 +38,7 @@ module Calendar
link_to query.name, project_calendar_path(project, query.id)
end
- def project_id
+ def project_name
link_to project.name, project_path(project)
end
diff --git a/modules/calendar/app/components/calendar/table_component.rb b/modules/calendar/app/components/calendar/table_component.rb
index dfe47166c09..a9553381d6a 100644
--- a/modules/calendar/app/components/calendar/table_component.rb
+++ b/modules/calendar/app/components/calendar/table_component.rb
@@ -30,7 +30,11 @@ module Calendar
class TableComponent < ::TableComponent
options :current_project, :current_user
- sortable_columns :name, :project_id, :created_at
+ sortable_columns :name, :project_name, :created_at
+
+ def sortable_columns_correlation
+ super.merge(project_name: 'projects.name')
+ end
def initial_sort
%i[name asc]
@@ -42,9 +46,9 @@ module Calendar
def headers
@headers ||= [
- ['name', { caption: I18n.t(:label_name) }],
- current_project.blank? ? ['project_id', { caption: I18n.t('attributes.project') }] : nil,
- ['created_at', { caption: I18n.t('attributes.created_at') }]
+ [:name, { caption: I18n.t(:label_name) }],
+ current_project.blank? ? [:project_name, { caption: I18n.t('attributes.project') }] : nil,
+ [:created_at, { caption: I18n.t('attributes.created_at') }]
].compact
end
diff --git a/modules/calendar/app/controllers/calendar/calendars_controller.rb b/modules/calendar/app/controllers/calendar/calendars_controller.rb
index 6bbe71d7e61..c12ea9c21e9 100644
--- a/modules/calendar/app/controllers/calendar/calendars_controller.rb
+++ b/modules/calendar/app/controllers/calendar/calendars_controller.rb
@@ -93,7 +93,7 @@ module ::Calendar
def visible_views
base_query = Query
.visible(current_user)
- .joins(:views)
+ .joins(:views, :project)
.where('views.type' => 'work_packages_calendar')
if @project