Browse Source

implemented search logic

pull/608/head
JG 3 years ago
parent
commit
5ab961147c
  1. 2
      app/components/search_component.rb
  2. 12
      app/controllers/organisations_controller.rb

2
app/components/search_component.rb

@ -11,6 +11,8 @@ class SearchComponent < ViewComponent::Base
def path(current_user) def path(current_user)
if request.path.include?("users") if request.path.include?("users")
user_path(current_user) user_path(current_user)
elsif request.path.include?("organisations") && request.path.include?("logs")
request.path
elsif request.path.include?("organisations") elsif request.path.include?("organisations")
organisations_path organisations_path
elsif request.path.include?("logs") elsif request.path.include?("logs")

12
app/controllers/organisations_controller.rb

@ -55,7 +55,17 @@ class OrganisationsController < ApplicationController
set_session_filters(specific_org: true) set_session_filters(specific_org: true)
organisation_logs = CaseLog.all.where(owning_organisation_id: @organisation.id) organisation_logs = CaseLog.all.where(owning_organisation_id: @organisation.id)
@pagy, @case_logs = pagy(filtered_case_logs(organisation_logs))
@pagy, @case_logs = pagy(
filtered_case_logs(
filtered_collection(
organisation_logs, search_term
),
),
)
@searched = search_term.presence
@total_count = organisation_logs.size
render "logs", layout: "application" render "logs", layout: "application"
else else
redirect_to(case_logs_path) redirect_to(case_logs_path)

Loading…
Cancel
Save