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
Make filter a bit more usable
Oliver Günther3651147f67ce
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rbindex 907362da191..d1cd2431001 100644--- a/app/controllers/search_controller.rb+++ b/app/controllers/search_controller.rb@@ -154,15 +154,14 @@ class SearchController < ApplicationControllerenddef search_classes- scope = search_types & search_params.keys-- scope = if scope.empty?- search_types- elsif scope & ["work_packages"] == scope- []- else- scope- end+ scope =+ if search_params[:filter] == "work_packages"+ [] # work packages are handled in the frontend+ elsif search_params[:filter].present?+ [search_params[:filter]] & search_types+ else+ search_types+ endscope.index_with { |s| scope_class(s) }enddiff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erbindex dd6ced4de04..1b479e5ebab 100644--- a/app/views/search/index.html.erb+++ b/app/views/search/index.html.erb@@ -56,25 +56,22 @@ See COPYRIGHT and LICENSE files for more details.)header.with_tab_nav(label: nil) do |tab_nav|- (search_types + ["all"]).each do |name|+ search_types.each do |name|tab_nav.with_tab(selected: search_params[:filter] == name,- href: search_path(- {- filter: name,- q: @question,- scope: search_params[:scope]- }.compact- )- ) do |t|- t.with_text { OpenProject::GlobalSearch.tab_name(name) }- end+ href: search_path(filter: name, q: @question, scope: search_params[:scope])+ ) { |t| t.with_text { OpenProject::GlobalSearch.tab_name(name) } }end++ tab_nav.with_tab(+ selected: search_params[:filter].blank?,+ href: search_path(q: @question, scope: search_params[:scope])+ ) { |t| t.with_text { OpenProject::GlobalSearch.tab_name("all") } }endend%>-<% if params[:work_packages].present? %>+<% if params[:filter] == "work_packages" %><opce-global-search-work-packages></opce-global-search-work-packages><% else %>diff --git a/frontend/src/app/core/global_search/services/global-search.service.ts b/frontend/src/app/core/global_search/services/global-search.service.tsindex 503490805c9..ea13067f3fe 100644--- a/frontend/src/app/core/global_search/services/global-search.service.ts+++ b/frontend/src/app/core/global_search/services/global-search.service.ts@@ -165,7 +165,7 @@ export class GlobalSearchService {params = `q=${encodeURIComponent(this.searchTerm)}`;if (this.currentTab.length > 0 && this.currentTab !== 'all') {- params = `${params}&${this.currentTab}=1`;+ params = `${params}&filter=${this.currentTab}`;}if (this.projectScope.length > 0) {params = `${params}&scope=${this.projectScope}`;diff --git a/modules/meeting/spec/models/permitted_params_spec.rb b/modules/meeting/spec/models/permitted_params_spec.rbindex a6041fee707..00711737692 100644--- a/modules/meeting/spec/models/permitted_params_spec.rb+++ b/modules/meeting/spec/models/permitted_params_spec.rb@@ -34,7 +34,7 @@ RSpec.describe PermittedParams dodescribe "#search" doit "permits its whitelisted params" do- acceptable_params = { messages: 1 }+ acceptable_params = { filter: :messages }permitted = ActionController::Parameters.new(acceptable_params).permit!params = ActionController::Parameters.new(acceptable_params)diff --git a/spec/features/work_packages/navigation_spec.rb b/spec/features/work_packages/navigation_spec.rbindex 941ca8bf69a..fa0d6e185b2 100644--- a/spec/features/work_packages/navigation_spec.rb+++ b/spec/features/work_packages/navigation_spec.rb@@ -172,7 +172,7 @@ RSpec.describe "Work package navigation", :js, :selenium doit "double clicking search result row (Regression #30247)" dowork_package.subject = "Foobar"work_package.save!- visit search_path(q: "Foo", work_packages: 1, scope: :all)+ visit search_path(q: "Foo", filter: :work_packages, scope: :all)table = Pages::EmbeddedWorkPackagesTable.new page.find_by_id("content")table.expect_work_package_listed work_package