mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 21:46:24 +02:00
Add missing partial and wildcard search on /admin/blocked_domains
This commit is contained in:
parent
eaf89a02f7
commit
4f96441f26
2 changed files with 6 additions and 10 deletions
|
@ -5,7 +5,7 @@ module Admin
|
||||||
def index
|
def index
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
domains = BlockedDomain.all.order(:name)
|
domains = BlockedDomain.all.order(:name)
|
||||||
@q = domains.ransack(params[:q])
|
@q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
||||||
@domains = @q.result.page(params[:page])
|
@domains = @q.result.page(params[:page])
|
||||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||||
|
|
||||||
|
@ -13,13 +13,10 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
||||||
@domain = BlockedDomain.new
|
@domain = BlockedDomain.new
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
||||||
@domain = BlockedDomain.new(blocked_domain_params)
|
@domain = BlockedDomain.new(blocked_domain_params)
|
||||||
|
|
||||||
if @domain.save
|
if @domain.save
|
||||||
|
@ -29,18 +26,16 @@ module Admin
|
||||||
flash.now[:alert] = I18n.t('failed_to_add_domain')
|
flash.now[:alert] = I18n.t('failed_to_add_domain')
|
||||||
render 'new'
|
render 'new'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
|
|
||||||
if BlockedDomain.find(params[:id]).destroy
|
if BlockedDomain.find(params[:id]).destroy
|
||||||
flash[:notice] = I18n.t('domain_deleted')
|
flash[:notice] = I18n.t('domain_deleted')
|
||||||
redirect_to admin_blocked_domains_path
|
|
||||||
else
|
else
|
||||||
flash.now[:alert] = I18n.t('failed_to_delete_domain')
|
flash.now[:alert] = I18n.t('failed_to_delete_domain')
|
||||||
redirect_to admin_blocked_domains_path
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
redirect_to admin_blocked_domains_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def blocked_domain_params
|
def blocked_domain_params
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
class PartialSearchFormatter
|
class PartialSearchFormatter
|
||||||
def self.format(search_params)
|
def self.format(params)
|
||||||
percentage = '%'
|
percentage = '%'
|
||||||
|
search_params = params.deep_dup
|
||||||
|
|
||||||
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.prepend(percentage).concat(percentage)
|
value << percentage
|
||||||
end
|
end
|
||||||
|
|
||||||
search_params
|
search_params
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue