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

Add principal type filter for the sharing modal

Henriette Darge051852232dc3
diff --git a/app/components/work_packages/share/modal_body_component.rb b/app/components/work_packages/share/modal_body_component.rb
index 1f6873b6dac..1de3f4f24e1 100644
--- a/app/components/work_packages/share/modal_body_component.rb
+++ b/app/components/work_packages/share/modal_body_component.rb
@@ -116,6 +116,7 @@ module WorkPackages
# filter.push({ entity_and_no_project_member: { operator: "=", values: [params[:work_package_id]] } })
end
+ filter.push({ principal_type: { operator: "=", values: [type_option[:value][:principal_type]] } })
end
unless role_option.nil? || role_filter_option_active?(role_option)
diff --git a/app/models/queries/members.rb b/app/models/queries/members.rb
index 15035ba9106..67c35b6928b 100644
--- a/app/models/queries/members.rb
+++ b/app/models/queries/members.rb
@@ -36,6 +36,7 @@ module Queries::Members
filter Filters::GroupFilter
filter Filters::RoleFilter
filter Filters::PrincipalFilter
+ filter Filters::PrincipalTypeFilter
filter Filters::CreatedAtFilter
filter Filters::UpdatedAtFilter
filter Filters::EntityIdFilter
diff --git a/app/models/queries/members/filters/principal_type_filter.rb b/app/models/queries/members/filters/principal_type_filter.rb
new file mode 100644
index 00000000000..a7b432a1dac
--- /dev/null
+++ b/app/models/queries/members/filters/principal_type_filter.rb
@@ -0,0 +1,49 @@
+#-- 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.
+#++
+
+class Queries::Members::Filters::PrincipalTypeFilter < Queries::Members::Filters::MemberFilter
+ def allowed_values
+ [[User.name, User.name], [Group.name, Group.name], [PlaceholderUser.name, PlaceholderUser.name]]
+ end
+
+ def joins
+ :principal
+ end
+
+ def type
+ :list
+ end
+
+ def self.key
+ :principal_type
+ end
+
+ def where
+ operator_strategy.sql_for_field(values, Principal.table_name, :type)
+ end
+end