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
Show correct numbers in Relations and Files tab of new SplitScreenComponent (WiP)
Henriette Darge948e99ae28ef
diff --git a/app/models/relation.rb b/app/models/relation.rbindex f57f195fb1f..5906c3c01a1 100644--- a/app/models/relation.rb+++ b/app/models/relation.rb@@ -103,6 +103,14 @@ class Relation < ApplicationRecordscope :follows_with_lag,-> { follows.where("lag > 0") }+ scope :visible_involved,+ ->(work_package) do+ visible_sql = WorkPackage.visible(User.current).select(:id).to_sql+ where("(from_id IN (?) AND to_id IN (#{visible_sql})) OR (to_id IN (?) AND from_id IN (#{visible_sql}))",+ work_package,+ work_package)+ end+validates :lag, numericality: { allow_nil: true }validates :to, uniqueness: { scope: :from }diff --git a/config/initializers/menus.rb b/config/initializers/menus.rbindex c1445d11b38..58783d58090 100644--- a/config/initializers/menus.rb+++ b/config/initializers/menus.rb@@ -654,10 +654,18 @@ Redmine::MenuManager.map :work_package_split_view do |menu|menu.push :files,{ tab: :files },skip_permissions_check: true,+ badge: ->(work_package:, **) {+ Attachment.where(container_type: "WorkPackage",+ container_id: work_package)+ .count+ },caption: :"js.work_packages.tabs.files"menu.push :relations,{ tab: :relations },skip_permissions_check: true,+ badge: ->(work_package:, **) {+ Relation.visible_involved(work_package).count + WorkPackage.where(parent_id: work_package).count+ },caption: :"js.work_packages.tabs.relations"menu.push :watchers,{ tab: :watchers },diff --git a/spec/models/queries/relations/filters/involved_filter_spec.rb b/spec/models/queries/relations/filters/involved_filter_spec.rbindex e76b51d7d71..e39735f0053 100644--- a/spec/models/queries/relations/filters/involved_filter_spec.rb+++ b/spec/models/queries/relations/filters/involved_filter_spec.rb@@ -67,6 +67,12 @@ RSpec.describe Queries::Relations::Filters::InvolvedFilter doexpect(instance.apply_to(model).to_sql).to eql expected.to_sqlend++ it "is the same as the visible_involved scope" do+ expected = Relation.visible_involved("1")++ expect(instance.apply_to(model).to_sql).to eql expected.to_sql+ endendcontext 'for "!"' do