mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
fixed search form
This commit is contained in:
parent
fd34d3330d
commit
fee6b897af
2 changed files with 23 additions and 11 deletions
|
@ -5,14 +5,16 @@ module Admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
if params[:statuses_contains]
|
domains = if params[:statuses_contains]
|
||||||
domains = Domain.includes(:registrar, :registrant).where(
|
Domain.includes(:registrar, :registrant).where(
|
||||||
"domains.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
|
'domains.statuses @> ?::varchar[]', "{#{params[:statuses_contains].join(',')}}"
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
domains = Domain.includes(:registrar, :registrant)
|
Domain.includes(:registrar, :registrant)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
domains = get_domains_which_related_to_registrars
|
||||||
|
|
||||||
normalize_search_parameters do
|
normalize_search_parameters do
|
||||||
@q = domains.search(params[:q])
|
@q = domains.search(params[:q])
|
||||||
@domains = @q.result.page(params[:page])
|
@domains = @q.result.page(params[:page])
|
||||||
|
@ -59,7 +61,7 @@ module Admin
|
||||||
redirect_to [:admin, @domain]
|
redirect_to [:admin, @domain]
|
||||||
else
|
else
|
||||||
build_associations
|
build_associations
|
||||||
flash.now[:alert] = I18n.t('failed_to_update_domain') + ' ' + @domain.errors.full_messages.join(", ")
|
flash.now[:alert] = I18n.t('failed_to_update_domain') + ' ' + @domain.errors.full_messages.join(', ')
|
||||||
render 'edit'
|
render 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -105,7 +107,7 @@ module Admin
|
||||||
begin
|
begin
|
||||||
end_time = params[:q][:valid_to_lteq].try(:to_date)
|
end_time = params[:q][:valid_to_lteq].try(:to_date)
|
||||||
params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
|
params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
|
||||||
rescue
|
rescue StandardError
|
||||||
logger.warn('Invalid date')
|
logger.warn('Invalid date')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -113,5 +115,15 @@ module Admin
|
||||||
|
|
||||||
params[:q][:valid_to_lteq] = ca_cache
|
params[:q][:valid_to_lteq] = ca_cache
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_domains_which_related_to_registrars
|
||||||
|
if params[:registrar_id_eq]
|
||||||
|
Domain.includes(:registrar, :registrant).where(
|
||||||
|
registrar: params[:registrar_id_eq]
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Domain.includes(:registrar, :registrant)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :registrar_name, for: nil %>
|
<%= f.label :registrar_name, for: nil %>
|
||||||
<%= select_tag 'q[registrar_id_eq]', options_for_select(Registrar.all.map { |x| [x, x.id] }, params[:q][:registrar_id_eq]), { multiple: true, class: 'form-control js-combobox' } %>
|
<%= select_tag :registrar_id_eq, options_for_select(Registrar.all.map { |x| [x, x.id] }, params[:registrar_id_eq]), { multiple: true, class: 'form-control js-combobox' } %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue