fixed filter and serching bugs

This commit is contained in:
olegphenomenon 2022-04-25 09:35:45 +03:00
parent af1d5b1736
commit 851656c02e
4 changed files with 8 additions and 22 deletions

View file

@ -5,7 +5,8 @@ module Admin
def index
params[:q] ||= {}
@auctions = Auction.with_status(params[:statuses_contains])
@auctions = Auction.with_domain_name(params[:domain_matches])
.with_status(params[:statuses_contains])
.with_start_created_at_date(params[:created_at_start])
.with_end_created_at_date(params[:created_at_end])
@ -16,7 +17,7 @@ module Admin
@auctions = @q.result.page(params[:page])
end
@auctions = @auctions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
@auctions = @auctions.per(params[:results_per_page_auction]) if params[:results_per_page_auction].to_i.positive?
domains = ReservedDomain.all.order(:name)
q = domains.ransack(PartialSearchFormatter.format(params[:q]))
@ -57,14 +58,6 @@ module Admin
end
end
def send_to_auction
auction = Auction.find(params[:id])
p ">>>>>.."
p auction
p ">>>>>>"
end
private
def validate_table(table)

View file

@ -29,6 +29,10 @@ class Auction < ApplicationRecord
where("created_at <= ?", end_created_at) if end_created_at.present?
}
scope :with_domain_name, -> (domain_name) {
where('domain ilike ?', "%#{domain_name.strip}%") if domain_name.present?
}
def self.pending(domain_name)
find_by(domain: domain_name.to_s, status: PENDING_STATUSES)
end

View file

@ -117,9 +117,6 @@
<th class="col-xs-1">
<%= sort_link(@q, 'type') %>
</th>
<th class="col-xs-3">
Action
</th>
</tr>
</thead>
@ -131,12 +128,7 @@
<td><%= auction.created_at %></td>
<td><%= auction.registration_code %></td>
<td><%= auction.registration_deadline %></td>
<td><%= auction.platform %></td>
<td>
<%= button_tag type: 'button', data: { confirm: "Are you sure?" }, class: 'btn btn-primary' do %>
<% link_to 'Send to auction', send_to_auction_admin_auction_path(auction), method: :post, style: "color: white;" %>
<% end %>
</td>
<td><%= auction.platform.nil? ? 'automatically' : auction.platform %></td>
</tr>
<% end %>
</tbody>

View file

@ -267,9 +267,6 @@ Rails.application.routes.draw do
resources :accounts
resources :account_activities
resources :auctions, only: [ :index, :create ] do
member do
post 'send_to_auction', to: 'auctions#send_to_auction', as: :send_to_auction
end
collection do
post 'upload_spreadsheet', to: 'auctions#upload_spreadsheet', as: :upload_spreadsheet
end