mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 06:26:15 +02:00
Enabled partial search
This commit is contained in:
parent
26cb791586
commit
ee1117021b
5 changed files with 9 additions and 9 deletions
|
@ -8,7 +8,7 @@ module Repp
|
||||||
def index
|
def index
|
||||||
records = current_user.registrar.cash_account.activities
|
records = current_user.registrar.cash_account.activities
|
||||||
|
|
||||||
q = records.ransack(search_params)
|
q = records.ransack(PartialSearchFormatter.format(search_params))
|
||||||
q.sorts = 'created_at desc' if q.sorts.empty?
|
q.sorts = 'created_at desc' if q.sorts.empty?
|
||||||
activities = q.result(distinct: true)
|
activities = q.result(distinct: true)
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_params
|
def search_params
|
||||||
index_params.fetch(:q, {})
|
index_params.fetch(:q, {}) || {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def limit
|
def limit
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Repp
|
||||||
authorize! :check, Epp::Contact
|
authorize! :check, Epp::Contact
|
||||||
records = current_user.registrar.contacts
|
records = current_user.registrar.contacts
|
||||||
|
|
||||||
q = records.ransack(search_params)
|
q = records.ransack(PartialSearchFormatter.format(search_params))
|
||||||
q.sorts = 'created_at desc' if q.sorts.empty?
|
q.sorts = 'created_at desc' if q.sorts.empty?
|
||||||
contacts = q.result(distinct: true)
|
contacts = q.result(distinct: true)
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_params
|
def search_params
|
||||||
index_params.fetch(:q, {})
|
index_params.fetch(:q, {}) || {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_filter_params
|
def domain_filter_params
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Repp
|
||||||
def index
|
def index
|
||||||
authorize! :info, Epp::Domain
|
authorize! :info, Epp::Domain
|
||||||
records = current_user.registrar.domains
|
records = current_user.registrar.domains
|
||||||
q = records.ransack(search_params)
|
q = records.ransack(PartialSearchFormatter.format(search_params))
|
||||||
q.sorts = ['valid_to asc', 'created_at desc'] if q.sorts.empty?
|
q.sorts = ['valid_to asc', 'created_at desc'] if q.sorts.empty?
|
||||||
# use distinct: false here due to ransack bug:
|
# use distinct: false here due to ransack bug:
|
||||||
# https://github.com/activerecord-hackery/ransack/issues/429
|
# https://github.com/activerecord-hackery/ransack/issues/429
|
||||||
|
@ -244,7 +244,7 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_params
|
def search_params
|
||||||
index_params.fetch(:q, {})
|
index_params.fetch(:q, {}) || {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_params
|
def update_params
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Repp
|
||||||
desc 'Get all invoices'
|
desc 'Get all invoices'
|
||||||
def index
|
def index
|
||||||
records = current_user.registrar.invoices
|
records = current_user.registrar.invoices
|
||||||
q = records.ransack(search_params)
|
q = records.ransack(PartialSearchFormatter.format(search_params))
|
||||||
q.sorts = 'created_at desc' if q.sorts.empty?
|
q.sorts = 'created_at desc' if q.sorts.empty?
|
||||||
invoices = q.result(distinct: true)
|
invoices = q.result(distinct: true)
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_params
|
def search_params
|
||||||
index_params.fetch(:q, {})
|
index_params.fetch(:q, {}) || {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def invoice_params
|
def invoice_params
|
||||||
|
|
|
@ -5,7 +5,7 @@ class PartialSearchFormatter
|
||||||
search_params.each do |key, value|
|
search_params.each do |key, value|
|
||||||
next unless key.include?('matches') && value.present?
|
next unless key.include?('matches') && value.present?
|
||||||
|
|
||||||
value << '%'
|
search_params[key] = "%#{value}%"
|
||||||
end
|
end
|
||||||
|
|
||||||
search_params
|
search_params
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue