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 typeahead filter for principals and projects

Oliver Günther8f26b2462202
diff --git a/app/models/queries/filters/shared/any_user_name_attribute_filter.rb b/app/models/queries/filters/shared/any_user_name_attribute_filter.rb
index 40092397ea1..b80d83b4b19 100644
--- a/app/models/queries/filters/shared/any_user_name_attribute_filter.rb
+++ b/app/models/queries/filters/shared/any_user_name_attribute_filter.rb
@@ -41,6 +41,7 @@ module Queries::Filters::Shared::AnyUserNameAttributeFilter
def available_operators
[Queries::Operators::Contains,
+ Queries::Operators::Everywhere,
Queries::Operators::NotContains]
end
diff --git a/app/models/queries/principals.rb b/app/models/queries/principals.rb
index 5323df6ea00..830ef614ca6 100644
--- a/app/models/queries/principals.rb
+++ b/app/models/queries/principals.rb
@@ -39,6 +39,7 @@ module Queries::Principals
register.filter query, filters::StatusFilter
register.filter query, filters::NameFilter
register.filter query, filters::AnyNameAttributeFilter
+ register.filter query, filters::TypeaheadFilter
register.filter query, filters::IdFilter
register.order query, orders::NameOrder
diff --git a/app/models/queries/principals/filters/typeahead_filter.rb b/app/models/queries/principals/filters/typeahead_filter.rb
new file mode 100644
index 00000000000..e8eba86b0ca
--- /dev/null
+++ b/app/models/queries/principals/filters/typeahead_filter.rb
@@ -0,0 +1,43 @@
+#-- encoding: UTF-8
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2021 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::Principals::Filters::TypeaheadFilter < Queries::Principals::Filters::AnyNameAttributeFilter
+ def self.key
+ :typeahead
+ end
+
+ def type
+ :search
+ end
+
+ def human_name
+ I18n.t('label_search')
+ end
+end
diff --git a/app/models/queries/projects.rb b/app/models/queries/projects.rb
index 6e3bde4f5b4..7682fb849b7 100644
--- a/app/models/queries/projects.rb
+++ b/app/models/queries/projects.rb
@@ -40,6 +40,7 @@ module Queries::Projects
filter query, filters::TemplatedFilter
filter query, filters::PublicFilter
filter query, filters::NameAndIdentifierFilter
+ filter query, filters::TypeaheadFilter
filter query, filters::CustomFieldFilter
filter query, filters::CreatedAtFilter
filter query, filters::LatestActivityAtFilter
diff --git a/app/models/queries/projects/filters/name_and_identifier_filter.rb b/app/models/queries/projects/filters/name_and_identifier_filter.rb
index ff4ca55641c..11e948eacd7 100644
--- a/app/models/queries/projects/filters/name_and_identifier_filter.rb
+++ b/app/models/queries/projects/filters/name_and_identifier_filter.rb
@@ -39,7 +39,7 @@ class Queries::Projects::Filters::NameAndIdentifierFilter < Queries::Projects::F
where_equal
when '!'
where_not_equal
- when '~'
+ when '~', '**'
where_contains
when '!~'
where_not_contains
diff --git a/app/models/queries/projects/filters/typeahead_filter.rb b/app/models/queries/projects/filters/typeahead_filter.rb
new file mode 100644
index 00000000000..8b6f7993f53
--- /dev/null
+++ b/app/models/queries/projects/filters/typeahead_filter.rb
@@ -0,0 +1,43 @@
+#-- encoding: UTF-8
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2021 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::Projects::Filters::TypeaheadFilter < Queries::Projects::Filters::NameAndIdentifierFilter
+ def self.key
+ :typeahead
+ end
+
+ def type
+ :search
+ end
+
+ def human_name
+ I18n.t('label_search')
+ end
+end