Browse Source

feat: fix search bug

pull/1327/head
natdeanlewissoftwire 3 years ago
parent
commit
f8030f5b2c
  1. 2
      app/components/search_component.rb
  2. 19
      app/views/logs/index.html.erb

2
app/components/search_component.rb

@ -23,6 +23,8 @@ class SearchComponent < ViewComponent::Base
user_path(current_user)
elsif request.path.include?("organisations")
organisations_path
elsif FeatureToggle.sales_log_enabled? && request.path.include?("sales-logs")
sales_logs_path
elsif request.path.include?("logs")
lettings_logs_path
end

19
app/views/logs/index.html.erb

@ -64,9 +64,24 @@
<%= render partial: "log_filters" %>
<div class="app-filter-layout__content">
<%= render SearchComponent.new(current_user:, search_label: "Search by log ID, tenant code, property reference or postcode", value: @searched) %>
<% if current_page?(controller: 'lettings_logs', action: 'index') %>
<%= render SearchComponent.new(current_user:, search_label: "Search by log ID, tenant code, property reference or postcode", value: @searched) %>
<% end %>
<% if FeatureToggle.sales_log_enabled? && current_page?(controller: 'sales_logs', action: 'index') %>
<%= render SearchComponent.new(current_user:, search_label: "Search by log ID, purchaser code or postcode", value: @searched) %>
<% end %>
<%= govuk_section_break(visible: true, size: "m") %>
<%= render partial: "log_list", locals: { logs: @logs, title: "Logs", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count, csv_download_url: csv_download_lettings_logs_path(search: @search_term) } %>
<% if current_page?(controller: 'lettings_logs', action: 'index') %>
<%= render partial: "log_list", locals: { logs: @logs, title: "Logs", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count, csv_download_url: csv_download_lettings_logs_path(search: @search_term) } %>
<% end %>
<% if FeatureToggle.sales_log_enabled? && current_page?(controller: 'sales_logs', action: 'index') %>
<%= render partial: "log_list", locals: { logs: @logs, title: "Logs", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count } %>
<% end %>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "logs" } %>
</div>
</div>

Loading…
Cancel
Save