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

don`t require searchable custom fields to also be filters

ulferts84ff1d942621
diff --git a/app/models/queries/work_packages/filter/search_filter.rb b/app/models/queries/work_packages/filter/search_filter.rb
index 36ea249d338..e6108dfb4a0 100644
--- a/app/models/queries/work_packages/filter/search_filter.rb
+++ b/app/models/queries/work_packages/filter/search_filter.rb
@@ -72,18 +72,18 @@ class Queries::WorkPackages::Filter::SearchFilter <
end
def custom_field_configurations
+ # Does not remove custom fields that are not marked as filters
+ # as the intend of this filter is to search and it is used in the
+ # search context. Thus, only the searchable flag is of interest.
custom_fields =
if context&.project
context.project.all_work_package_custom_fields.select do |custom_field|
%w(text string).include?(custom_field.field_format) &&
- custom_field.is_filter == true &&
custom_field.searchable == true
end
else
::WorkPackageCustomField
- .filter
.where(field_format: %w(text string),
- is_filter: true,
searchable: true)
end
diff --git a/spec/features/search/search_spec.rb b/spec/features/search/search_spec.rb
index 879d5e0ed6f..93e708fe753 100644
--- a/spec/features/search/search_spec.rb
+++ b/spec/features/search/search_spec.rb
@@ -192,14 +192,24 @@ RSpec.describe 'Search', js: true, with_settings: { per_page_options: '5' } do
context 'as custom fields are no filters' do
let(:is_filter) { false }
- it "does not find WP via custom fields" do
+ it "finds WP global custom fields" do
select_autocomplete(page.find('.top-menu-search--input'),
- query: "text",
+ query: "string",
select_text: "In all projects ↵",
wait_dropdown_open: false)
table = Pages::EmbeddedWorkPackagesTable.new(find('.work-packages-embedded-view--container'))
table.ensure_work_package_not_listed!(work_packages[0])
+ table.expect_work_package_subject(work_packages[1].subject)
+ end
+
+ it "finds WP non global custom fields" do
+ select_autocomplete(page.find('.top-menu-search--input'),
+ query: "text",
+ select_text: "In all projects ↵",
+ wait_dropdown_open: false)
+ table = Pages::EmbeddedWorkPackagesTable.new(find('.work-packages-embedded-view--container'))
table.ensure_work_package_not_listed!(work_packages[1])
+ table.expect_work_package_subject(work_packages[0].subject)
end
end