mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 14:06:21 +02:00
added modal window
This commit is contained in:
parent
2aa1100305
commit
77249629bb
6 changed files with 102 additions and 30 deletions
|
@ -6,6 +6,7 @@ module Admin
|
|||
params[:q] ||= {}
|
||||
|
||||
@auctions = Auction.with_status(params[:statuses_contains])
|
||||
@auction = Auction.new
|
||||
|
||||
normalize_search_parameters do
|
||||
@q = @auctions.ransack(PartialSearchFormatter.format(params[:q]))
|
||||
|
@ -14,16 +15,47 @@ module Admin
|
|||
|
||||
@auctions = @auctions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
||||
domains = ReservedDomain.all.order(:name)
|
||||
q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
||||
@domains = q.result.page(params[:page])
|
||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
||||
render_by_format('admin/auctions/index', 'auctions')
|
||||
end
|
||||
|
||||
def update
|
||||
def create
|
||||
auction = Auction.new(domain: params[:domain], status: Auction.statuses[:started])
|
||||
|
||||
if auction.save
|
||||
remove_from_reserved(auction)
|
||||
flash[:notice] = "Auction #{params[:domain]} created"
|
||||
else
|
||||
flash[:alert] = "Something goes wrong"
|
||||
end
|
||||
|
||||
redirect_to admin_auctions_path
|
||||
end
|
||||
|
||||
def upload_spreadsheet
|
||||
table = CSV.parse(File.read(params[:q][:file]), headers: true)
|
||||
|
||||
table.each do |row|
|
||||
record = row.to_h
|
||||
auction = Auction.new(domain: record['name'], status: Auction.statuses[:started])
|
||||
remove_from_reserved(auction) if auction.save!
|
||||
end
|
||||
|
||||
redirect_to admin_auctions_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_from_reserved(auction)
|
||||
domain = ReservedDomain.find_by(name: auction.domain)
|
||||
|
||||
domain.destroy if domain.present?
|
||||
end
|
||||
|
||||
def normalize_search_parameters
|
||||
ca_cache = params[:q][:valid_to_lteq]
|
||||
begin
|
||||
|
|
|
@ -62,7 +62,7 @@ module Admin
|
|||
domain.destroy!
|
||||
end
|
||||
|
||||
redirect_to admin_reserved_domains_path
|
||||
redirect_to admin_auctions_path
|
||||
end
|
||||
|
||||
private
|
||||
|
|
15
app/views/admin/auctions/_modal.html.erb
Normal file
15
app/views/admin/auctions/_modal.html.erb
Normal file
|
@ -0,0 +1,15 @@
|
|||
<div class="modal fade" id="user-form-edit" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLongTitle">Select reserved domains</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<%= render template: 'admin/reserved_domains/index' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,17 +0,0 @@
|
|||
<%= search_form_for [:admin, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| %>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3"></div>
|
||||
<div class="col-md-4"></div>
|
||||
|
||||
<div class="col-md-12 text-right">
|
||||
<%= link_to t('.download_csv_btn'), admin_domains_path(format: :csv, params: params.permit!),
|
||||
"data-toggle" => "tooltip", "data-placement" => "bottom", "title" => t('.download_csv_btn'),
|
||||
class: 'btn btn-primary' %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row form-group"></div>
|
||||
<% end %>
|
|
@ -34,14 +34,34 @@
|
|||
<%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4" style="padding-top: 25px;">
|
||||
<button class="btn btn-primary">
|
||||
<div class="col-md-4" style="padding-top: 25px; display: flex; flex-direction: row;">
|
||||
<button class="btn btn-primary" style="margin-right: 10px;">
|
||||
|
||||
<span class="glyphicon glyphicon-search"></span>
|
||||
|
||||
</button>
|
||||
<div style="margin-right: 10px;">
|
||||
<%= link_to(t('.reset_btn'), admin_auctions_path, class: 'btn btn-default') %>
|
||||
</div>
|
||||
<div style="margin-right: 10px;">
|
||||
<%= link_to 'Download auction list', admin_auctions_path(format: :csv, params: params.permit!),
|
||||
"data-toggle" => "tooltip", "data-placement" => "bottom", "title" => t('.download_csv_btn'),
|
||||
class: 'btn btn-primary' %>
|
||||
</div>
|
||||
<div >
|
||||
<%= link_to "#", class: "btn btn-warning edit",
|
||||
data: {
|
||||
toggle: "modal",
|
||||
url: admin_reserved_domains_path,
|
||||
target: "#user-form-edit"} do %>
|
||||
<i class="glyphicon glyphicon-menu-right glyphicon-white"></i>
|
||||
Get reserved domains
|
||||
<% end %>
|
||||
|
||||
<%= render 'modal' %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -49,13 +69,27 @@
|
|||
|
||||
<hr />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-12 text-right" style='margin: 0 0 10px 0;'>
|
||||
<%= link_to 'Download auction list', admin_auctions_path(format: :csv, params: params.permit!),
|
||||
"data-toggle" => "tooltip", "data-placement" => "bottom", "title" => t('.download_csv_btn'),
|
||||
class: 'btn btn-primary' %>
|
||||
<%= search_form_for [:admin, @q], method: :post, html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f| %>
|
||||
<%= label_tag :new_auction %>
|
||||
|
||||
<div style="display: flex; flex-direction: row; align-items: center;">
|
||||
<%= text_field_tag :domain, params[:domain], class: 'form-control', placeholder: 'domain name' %>
|
||||
<%= f.submit 'Create', class: 'btn btn-primary', style: 'margin-left: .4rem;' %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12" style='margin: 0 0 10px 0; '>
|
||||
<%= search_form_for @q, url: upload_spreadsheet_admin_auctions_path, method: :post, html: { style: 'margin-bottom: 0; display: flex; flex-direction: row; align-items: center;', class: 'js-form', autocomplete: 'off' } do |f| %>
|
||||
<%= f.file_field :file,
|
||||
accept: ".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel",
|
||||
direct_upload: true,
|
||||
style: 'width: 200px;' %>
|
||||
<%= f.submit 'Upload csv', class: 'btn btn-primary' %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -99,3 +133,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('#user-form-edit').on("show.bs.modal", function(e) {
|
||||
$(this).find('.modal-body').load(e.relatedTarget.dataset.url);
|
||||
});
|
||||
</script>
|
|
@ -266,11 +266,13 @@ Rails.application.routes.draw do
|
|||
|
||||
resources :accounts
|
||||
resources :account_activities
|
||||
resources :auctions, only: [ :index ] do
|
||||
resources :auctions, only: [ :index, :create ] do
|
||||
collection do
|
||||
patch :update
|
||||
post 'upload_spreadsheet', to: 'auctions#upload_spreadsheet', as: :upload_spreadsheet
|
||||
end
|
||||
end
|
||||
# post 'admi/upload_spreadsheet', to: 'customers#upload_spreadsheet', as: :customers_upload_spreadsheet
|
||||
|
||||
|
||||
resources :bank_statements do
|
||||
resources :bank_transactions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue