mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 13:36:15 +02:00
Add partial and wildcard search on /admin/contacts
This commit is contained in:
parent
5a0c812a15
commit
b46f387fcf
2 changed files with 8 additions and 10 deletions
|
@ -9,10 +9,8 @@ module Admin
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
search_params = params[:q].deep_dup
|
search_params = params[:q].deep_dup
|
||||||
|
|
||||||
if search_params[:domain_contacts_type_in].is_a?(Array) &&
|
search_params[:registrant_domains_id_not_null] = 1 if search_params[:domain_contacts_type_in].is_a?(Array) &&
|
||||||
search_params[:domain_contacts_type_in].delete('registrant')
|
search_params[:domain_contacts_type_in].delete('registrant')
|
||||||
search_params[:registrant_domains_id_not_null] = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
contacts = Contact.includes(:registrar).joins(:registrar)
|
contacts = Contact.includes(:registrar).joins(:registrar)
|
||||||
.select('contacts.*, registrars.name as registrars_name')
|
.select('contacts.*, registrars.name as registrars_name')
|
||||||
|
@ -20,7 +18,7 @@ module Admin
|
||||||
contacts = filter_by_flags(contacts)
|
contacts = filter_by_flags(contacts)
|
||||||
|
|
||||||
normalize_search_parameters do
|
normalize_search_parameters do
|
||||||
@q = contacts.ransack(search_params)
|
@q = contacts.ransack(PartialSearchFormatter.format(search_params))
|
||||||
@contacts = @q.result.distinct.page(params[:page])
|
@contacts = @q.result.distinct.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,6 +31,7 @@ module Admin
|
||||||
if params[:only_no_country_code].eql?('1')
|
if params[:only_no_country_code].eql?('1')
|
||||||
contacts = contacts.where("ident_country_code is null or ident_country_code=''")
|
contacts = contacts.where("ident_country_code is null or ident_country_code=''")
|
||||||
end
|
end
|
||||||
|
|
||||||
contacts = contacts.email_verification_failed if params[:email_verification_failed].eql?('1')
|
contacts = contacts.email_verification_failed if params[:email_verification_failed].eql?('1')
|
||||||
contacts
|
contacts
|
||||||
end
|
end
|
||||||
|
@ -41,8 +40,7 @@ module Admin
|
||||||
render json: Contact.search_by_query(params[:q])
|
render json: Contact.search_by_query(params[:q])
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
def update
|
||||||
cp = ignore_empty_statuses
|
cp = ignore_empty_statuses
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
.col-md-3
|
.col-md-3
|
||||||
.form-group
|
.form-group
|
||||||
= f.label t(:id)
|
= f.label t(:id)
|
||||||
= f.search_field :code_matches, class: 'form-control', placeholder: t(:id)
|
= f.search_field :code_matches, value: params[:q][:code_matches], class: 'form-control', placeholder: t(:id)
|
||||||
.col-md-3
|
.col-md-3
|
||||||
.form-group
|
.form-group
|
||||||
= f.label t(:ident)
|
= f.label t(:ident)
|
||||||
= f.search_field :ident_matches, class: 'form-control', placeholder: t(:ident)
|
= f.search_field :ident_matches, value: params[:q][:ident_matches], class: 'form-control', placeholder: t(:ident)
|
||||||
.col-md-3
|
.col-md-3
|
||||||
.form-group
|
.form-group
|
||||||
= label_tag t(:ident_type)
|
= label_tag t(:ident_type)
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
.col-md-3
|
.col-md-3
|
||||||
.form-group
|
.form-group
|
||||||
= f.label t(:email)
|
= f.label t(:email)
|
||||||
= f.search_field :email_matches, class: 'form-control', placeholder: t(:email)
|
= f.search_field :email_matches, value: params[:q][:email_matches], class: 'form-control', placeholder: t(:email)
|
||||||
.col-md-3
|
.col-md-3
|
||||||
.form-group
|
.form-group
|
||||||
= label_tag t(:country)
|
= label_tag t(:country)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue