diff --git a/app/components/search_component.rb b/app/components/search_component.rb index 35eeefda7..201c341cf 100644 --- a/app/components/search_component.rb +++ b/app/components/search_component.rb @@ -13,6 +13,8 @@ class SearchComponent < ViewComponent::Base user_path(current_user) elsif request.path.include?("organisations") organisations_path + elsif request.path.include?("logs") + case_logs_path end end diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index 0db5762ef..bdf9e9e9b 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -11,13 +11,17 @@ class CaseLogsController < ApplicationController def index set_session_filters + all_logs = current_user.case_logs + @pagy, @case_logs = pagy( filtered_case_logs( filtered_collection( - current_user.case_logs, params["search-field"] + all_logs, search_term ), ), ) + @searched = search_term.presence + @total_count = all_logs.size respond_to do |format| format.html @@ -92,6 +96,10 @@ private API_ACTIONS = %w[create show update destroy].freeze + def search_term + params["search"] + end + def json_api_request? API_ACTIONS.include?(request["action"]) && request.format.json? end