mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 06:26:15 +02:00
Add missing partial and wildcard search on /admin/domains
This commit is contained in:
parent
b46f387fcf
commit
eaf89a02f7
2 changed files with 6 additions and 14 deletions
|
@ -17,18 +17,10 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
normalize_search_parameters do
|
normalize_search_parameters do
|
||||||
@q = domains.ransack(params[:q])
|
@q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
||||||
@domains = @q.result.page(params[:page])
|
@domains = @q.result.page(params[:page])
|
||||||
(redirect_to [:admin, @domains.first] and return if @domains.count == 1 && params[:q][:name_matches].present?)
|
|
||||||
if @domains.count.zero? && params[:q][:name_matches] !~ /^%.+%$/
|
|
||||||
# if we do not get any results, add wildcards to the name field and search again
|
|
||||||
n_cache = params[:q][:name_matches]
|
|
||||||
params[:q][:name_matches] = "%#{params[:q][:name_matches]}%"
|
|
||||||
@q = domains.ransack(params[:q])
|
|
||||||
@domains = @q.result.page(params[:page])
|
|
||||||
params[:q][:name_matches] = n_cache # we don't want to show wildcards in search form
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@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?
|
||||||
|
|
||||||
render_by_format('admin/domains/index', 'domains')
|
render_by_format('admin/domains/index', 'domains')
|
||||||
|
@ -95,7 +87,7 @@ module Admin
|
||||||
def build_associations
|
def build_associations
|
||||||
@server_statuses = @domain.statuses.select { |x| DomainStatus::SERVER_STATUSES.include?(x) }
|
@server_statuses = @domain.statuses.select { |x| DomainStatus::SERVER_STATUSES.include?(x) }
|
||||||
@server_statuses = [nil] if @server_statuses.empty?
|
@server_statuses = [nil] if @server_statuses.empty?
|
||||||
@other_statuses = @domain.statuses.select { |x| !DomainStatus::SERVER_STATUSES.include?(x) }
|
@other_statuses = @domain.statuses.reject { |x| DomainStatus::SERVER_STATUSES.include?(x) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def ignore_empty_statuses
|
def ignore_empty_statuses
|
||||||
|
|
|
@ -9,19 +9,19 @@
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :registrant_ident, for: nil %>
|
<%= f.label :registrant_ident, for: nil %>
|
||||||
<%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %>
|
<%= f.search_field :registrant_ident_matches, value: params[:q][:registrant_ident_matches], class: 'form-control', placeholder: t(:registrant_ident) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :contact_ident, for: nil %>
|
<%= f.label :contact_ident, for: nil %>
|
||||||
<%= f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) %>
|
<%= f.search_field :contacts_ident_matches, value: params[:q][:contacts_ident_matches], class: 'form-control', placeholder: t(:contact_ident) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :nameserver_hostname, for: nil %>
|
<%= f.label :nameserver_hostname, for: nil %>
|
||||||
<%= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) %>
|
<%= f.search_field :nameservers_hostname_matches, value: params[:q][:nameservers_hostname_matches], class: 'form-control', placeholder: t(:nameserver_hostname) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue