Skip to content

Commit

Permalink
updated admin auction view
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Aug 25, 2023
1 parent 7c73208 commit 3ffaa7f
Show file tree
Hide file tree
Showing 33 changed files with 802 additions and 301 deletions.
19 changes: 19 additions & 0 deletions app/assets/builds/application.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions app/assets/builds/application.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions app/helpers/invoices_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def fetch_errors_from_response(channel:, response:)
return 'OK' if response['transaction_result'] == 'completed'

fetch_everypay_errors(response)
when 'SEB', 'LHV', 'Swedbank'
fetch_banklink_errors(response)
# when 'SEB', 'LHV', 'Swedbank'
# fetch_banklink_errors(response)
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Application } from "@hotwired/stimulus"
const application = Application.start()

// Configure Stimulus development experience
application.debug = false
application.debug = document.documentElement.classList.contains("debug");
window.Stimulus = application

export { application }
21 changes: 21 additions & 0 deletions app/javascript/controllers/form/autosave_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = ["form", "select"]
static values = {
select: String,
}


connect() {
this.selectValue = this.selectTarget.value;
}

save() {
if (confirm("Are you sure?") == true) {
this.formTarget.requestSubmit()
} else {
this.selectTarget.value = this.selectValue;
}
}
}
3 changes: 3 additions & 0 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ application.register("form--bundle-checkbox", Form__BundleCheckboxController);
import Form__CheckboxToggleController from "./form/checkbox_toggle_controller";
application.register("form--checkbox-toggle", Form__CheckboxToggleController);

import Form__AutosaveController from "./form/autosave_controller";
application.register("form--autosave", Form__AutosaveController);

import Table__OrdeableController from "./table/ordeable_controller";
application.register("table--ordeable", Table__OrdeableController);

Expand Down
10 changes: 10 additions & 0 deletions app/views/admin/auctions/_deposit_participant.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<tr>
<td><%= user.display_name %></td>
<td><%= user.email %></td>
<td style="text-align: center">
<label class="o-checkbox" for="with_deposit_participants">
<%= form.check_box :user_ids, { multiple: true, checked: auction.allow_to_set_bid?(user) }, user.id, nil %>
<div class="o-checkbox__slider round"></div>
</label>
</td>
</tr>
70 changes: 70 additions & 0 deletions app/views/admin/auctions/_deposit_participants.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<div style='c-table c-table--sortable'>
<h2><%= t('auctions.show.user_list') %></h2>
<%= form_with url: admin_auction_path(@auction), method: :get,
data: { controller: 'form--debounce', form__debounce_target: 'form',
turbo_action: "advance", turbo_frame: "results",
action: 'input->form--debounce#search' } do |form| %>
<div class="c-table__filters">
<%= form.hidden_field :auction_id, value: auction.id %>
<%= form.search_field :search_string, value: params[:search_string], placeholder: 'Input user name, email or phone number', class: 'c-table__search__input js-table-search-dt' %>
<div>
<label>Show only those who have made a deposit</label>
<label class="o-checkbox" for="with_deposit_participants">
<%= form.check_box :with_deposit_participants, { data: { name: 'first_checkbox' } }, 1, nil %>
<div class="o-checkbox__slider round"></div>
</label>
</div>
<div>
<label>Show only those who haven't made a deposit</label>
<label class="o-checkbox" for="without_deposit_participants">
<%= form.check_box :without_deposit_participants, { data: { name: 'second_checkbox' } }, 1, nil %>
<div class="o-checkbox__slider round"></div>
</label>
</div>
</div>
<% end %>

<div class="content">
<%= form_with url: apply_auction_participants_admin_auctions_path do |form| %>
<%= form.hidden_field :auction_uuid, value: auction.uuid %>
<div class="c-table__filters">
<div class="c-table__filters__btns" style='display: flex !important; align-items: center !important; justify-content: space-between !important; width: 100%;'>
<%= form.submit t('auctions.show.apply'), class: 'c-btn c-btn--blue', style: 'padding: 0 30px;' %>
</div>
</div>

<% header_collection = [ { column: nil, caption: t('offers.price'), options: { class: "" } },
{ column: nil, caption: 'Email', options: { class: "" } },
{ column: nil, caption: t('auctions.show.allow'), options: { class: "" } },] %>

<%= turbo_frame_tag "results" do %>
<!-- Options attributes are used as table attributes -->
<%= component 'common/table', header_collection:, options: { class: 'js-table-dt' } do %>
<!-- "The body of the table also needs to be in the component block, so the component wraps it with the necessary tags." -->
<%= tag.tbody id: "auctions-table-body", class: 'contents' do %>
<%- if @users.present? %>
<% @users.each do |user| %>
<%= render partial: 'deposit_participant', locals: { user: user, form: form, auction: auction } %>
<% end %>
<%- else %>
<tr>
<td colspan="3" style="text-align: center; font-weight: bold; font-size: 1.2rem; padding: 3rem 0 !important;"><%= t(:no_offers) %></td>
</tr>
<%- end %>
<% end %>
<% end %>
<% end %>

<%= turbo_frame_tag "results" do %>
<div class="column" style="margin-top:10px; text-align: center;">
<% if @pagy.pages > 1 %>
<div class="footer">
<%== pagy_nav(@pagy) %>
</div>
<% end %>
</div>
<% end %>
<%= component 'common/pagy', pagy: @pagy %>
<% end %>
</div>
</div>
6 changes: 4 additions & 2 deletions app/views/admin/auctions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
data: { controller: 'form--debounce', form__debounce_target: 'form', turbo_action: "advance",
turbo_frame: "results", action: 'input->form--debounce#search' } do |form| %>
<div class="c-table__filters">
<%= form.search_field :domain_name, value: params[:domain_name], placeholder: t('search_by_domain_name') %>
<%= form.search_field :domain_name, value: params[:domain_name], placeholder: t('search_by_domain_name'), class: 'c-table__search__input js-table-search-dt' %>
</div>
<div class="c-table__filters" >
<div class="c-table__filters">
<div class="c-table__filters__btns" style='display: flex !important; align-items: center !important; justify-content: space-between !important; width: 100%;'>
<div>
<%= form.label :type, 'Select type of auction' %>
Expand Down Expand Up @@ -116,6 +116,8 @@
<%= render @auctions, form: @form_auction_table %>
<% end %>
<% end %>

<%= component 'common/pagy', pagy: @pagy %>
<% end %>
</div>
</div>
63 changes: 63 additions & 0 deletions app/views/admin/auctions/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<%= component 'common/hero', title: "#{t('.title')}: #{@auction.domain_name}" %>
<div class="o-container">
<div class="c-table c-table--sortable" data-controller='form--bundle-checkbox'>
<%= component 'common/table', header_collection: [], options: { class: 'js-table-dt dataTable no-footer' } do %>
<%= tag.tbody id: "auctions-table-body", class: 'contents' do %>
<tr>
<td><strong><%= t('auctions.domain_name') %></strong></td>
<td class="monospace">
<%= domain_name_with_embedded_colors(@auction.domain_name) %>
</td>
</tr>
<tr>
<td><strong><%= t('auctions.starts_at') %></strong></td>
<td><%= I18n.l(@auction.starts_at) if @auction.starts_at.present? %>
</tr>
<tr>
<td><strong><%= t('auctions.ends_at') %></strong></td>
<td><%= I18n.l(@auction.ends_at) if @auction.ends_at.present? %></td>
</tr>
<%- if @auction.offer_from_user(current_user).present? %>
<tr>
<td><strong><%= t('auctions.your_current_price') %></strong></td>
<td><%= @auction.current_price_from_user(current_user) %></td>
</tr>
<% end %>
<% end %>
<% end %>

<div class="c-table__filters__btns" style='padding: 1rem 0; display: flex; justify-content: end;'>
<%= button_to t(:delete), admin_auction_path(@auction), method: :delete, class: "c-btn c-btn--red", form: { data: { turbo_confirm: t(".confirm_delete") } } %>
<%= link_to t(:result_name), admin_result_path(@auction.result), class: "c-btn c-btn--green" if @auction.result %>
<%= link_to t(:versions_name), admin_auction_versions_path(@auction), class: "c-btn c-btn--blue" %>
</div>

<% header_collection = [ {column: nil, caption: t('offers.price'), options: {}},
{ column: nil, caption: t('users.display_name'), options: { class: "" } },
{ column: nil, caption: t(:created_at), options: { class: "" } },
{ column: nil, caption: t(:updated_at), options: { class: "" } },
{ column: nil, caption: t(:versions_name), options: { class: "" } }] %>
<%= component 'common/table', header_collection:, options: { class: 'js-table-dt' } do %>
<%= tag.tbody id: "auctions-table-body", class: 'contents' do %>
<%- if @offers.present? %>
<tr class="offers-table-row">
<td><%= t('offers.price_in_currency', price: offer.price) %></td>
<td><%= offer.user&.display_name || t(:deleted_user) %></td>
<td><%= I18n.l(offer.created_at) %></td>
<td><%= I18n.l(offer.updated_at) %></td>
<td><%= link_to t(:versions_name), admin_offer_versions_path(offer), class: "ui button primary" %></td>
</tr>
<%- else %>
<tr>
<td colspan="5" style="text-align: center; font-weight: bold; font-size: 1.2rem; padding: 3rem 0 !important;"><%= t(:no_offers) %></td>
</tr>
<%- end %>
<% end %>
<% end %>

<% if @auction.enable_deposit? %>
<%= render partial: 'deposit_participants', locals: { auction: @auction } %>
<% end %>
</div>
</div>
</div>
13 changes: 5 additions & 8 deletions app/views/admin/bans/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<div class="c-table c-table--sortable">
<%= form_with(url: admin_bans_path, local: true, method: :get) do |f| %>
<div class="c-table__filters" >
<div class="c-table__filters__btns">
<div class="c-table__filters__btns" style='display: flex !important; align-items: center !important; justify-content: space-between !important; width: 100%;'>
<%= f.search_field :search_string, value: params[:search_string], placeholder: t('search_by_domain_name'), class: 'c-table__search__input js-table-search-dt' %>
<%= f.button 'Search', class: "ui icon primary button" %>
<%= f.button 'Search', class: "c-btn c-btn--blue" %>
</div>
</div>
<% end %>
Expand All @@ -29,12 +29,9 @@
<%= link_to t('results.invoice'), admin_invoice_path(ban.invoice_id) %>
<% end %>
</td>
<td>
<%= link_to t(:delete), admin_ban_path(ban), method: :delete,
data: { confirm: t(:are_you_sure) }, target: '_top',
class: "ui button secondary" %>
<%= link_to t(:versions_name),
admin_ban_versions_path(ban), class: "ui button primary" %>
<td class="c-table__filters__btns" style='padding: 1rem 0; display: flex; justify-content: end;'>
<%= button_to t(:delete), admin_ban_path(ban), method: :delete, class: "c-btn c-btn--red", form: { data: { turbo_confirm: t(".confirm_delete") } } %>
<%= link_to t(:versions_name), admin_ban_versions_path(ban), class: "c-btn c-btn--blue", style: 'height: 40%;'%>
</td>
</tr>
<% end %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/admin/billing_profiles/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
</div>
<% end %>
<% header_collection = [{column: nil, caption: t('billing_profiles.user'), options: {}},
{ column: 'domain_name', caption: t('billing_profiles.name'), options: { class: "sorting" } },
{ column: 'starts_at', caption: t('billing_profiles.vat_code'), options: { class: "sorting" } },
{ column: 'ends_at', caption: t('billing_profiles.address'), options: { class: "sorting" } }] %>
{ column: nil, caption: t('billing_profiles.billing_profile_name'), options: { class: "" } },
{ column: nil, caption: t('billing_profiles.vat_code'), options: { class: "" } },
{ column: nil, caption: t('billing_profiles.address'), options: { class: "" } }] %>
<%= turbo_frame_tag "results" do %>
<%= component 'common/table', header_collection:, options: { class: 'js-table-dt dataTable no-footer' } do %>
<%= component 'common/table', header_collection:, options: { class: 'js-table-dt' } do %>
<%= tag.tbody class: 'contents' do %>
<% @billing_profiles.each do |billing_profile| %>
<tr class="billing-profiles-table-row">
Expand Down
6 changes: 6 additions & 0 deletions app/views/admin/billing_profiles/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,11 @@
</tr>
<% end %>
<% end %>

<div class="c-table__filters__btns" style='padding: 1rem 0; display: flex; justify-content: end;'>
<%- if @billing_profile.user %>
<%= link_to t(:user), admin_user_path(@billing_profile.user), class: "c-btn c-btn--blue" %>
<% end %>
</div>
</div>
</div>
32 changes: 22 additions & 10 deletions app/views/admin/finished_auctions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,37 @@
<div class="o-container">
<div class="c-table c-table--sortable">
<%= form_with url: admin_finished_auctions_index_path,
method: :get, data: { controller: 'debounce', debounce_target: 'form',
method: :get, data: { controller: 'form--debounce form--filter', form__debounce_target: 'form',
turbo_action: "advance", turbo_frame: "results",
action: 'input->debounce#search' }, class: 'ui big form' do |form| %>
<div class="c-table__filters">
<%= form.search_field :domain_name, value: params[:domain_name], placeholder: t('search_by_domain_name'), class: 'prompt' %>
<%= form.label :type, 'Select type of auction' %>
<%= form.select :type, options_for_select(Auction.platforms, selected: params[:type]), {include_blank: 'All'}, {class: '' } %>
<%= link_to 'Clear', request.path, class: 'ui primary button' %>
action: 'input->form--debounce#search' } do |form| %>
<div class="c-table__filters" style='display: flex; align-items: center;'>
<div style='display: flex; align-items: center; gap: 0 1.8rem;'>
<%= form.search_field :domain_name, value: params[:domain_name], placeholder: t('search_by_domain_name'), class: 'c-table__search__input js-table-search-dt' %>
<div style='display: flex; align-items: center; gap: 0 1rem;'>
<%= form.radio_button :type, 'all', class: "js-table-filter-btn", checked: true, style: 'visibility: hidden; position: absolute;', id: 'filter_all_button', data: { form__filter_target: 'button' } %>
<%= form.label :type_all, "kõik", class: "c-table__filters__btn is-active js-table-filter-btn", style: 'cursor: pointer;', for: 'filter_all_button', data: { form__filter_target: 'label', action: "click->form--filter#click" } %>
<%= form.radio_button :type, 'english', class: "js-table-filter-btn", style: 'visibility: hidden; position: absolute;', id: 'filter_IO_button', data: { form__filter_target: 'button' } %>
<%= form.label :type_english, class: "c-table__filters__btn js-table-filter-btn", style: 'cursor: pointer;', for: 'filter_IO_button', data: { form__filter_target: 'label', action: "click->form--filter#click" } do %>
<span class="o-io-icon"></span><span class="u-hidden-m"> inglise oksjon</span>
<% end %>
<%= form.radio_button :type, 'blind', class: "js-table-filter-btn", style: 'visibility: hidden; position: absolute;', id: 'filter_PO_button', data: { form__filter_target: 'button' } %>
<%= form.label :type_blind, class: "c-table__filters__btn js-table-filter-btn", style: 'cursor: pointer;', for: 'filter_PO_button', data: { form__filter_target: 'label', action: "click->form--filter#click" } do %>
<span class="o-po-icon"></span>
<span class="u-hidden-m"> pime oksjon</span>
<% end %>
</div>
</div>
<div class="c-table__filters__btns" style='height: 50%'>
<%= link_to 'Clear', request.path, class: 'c-btn c-btn--orange' %>
</div>
</div>
<% end %>

<% header_collection = [
{ column: 'domain_name', caption: t('auctions.domain_name'), options: { class: "sorting" } },
{ column: 'ends_at', caption: t('auctions.finished_at'), options: { class: "sorting" } },
{ column: 'platform', caption: t('auctions.platform'), options: { class: "sorting" } },
{ column: nil, caption: t('auctions.last_offer'), options: { class: "" } },
{ column: nil, caption: t('auctions.last_participant'), options: { class: '' } }] %>

<%= turbo_frame_tag "results" do %>
<!-- Options attributes are used as table attributes -->
<%= component 'common/table', header_collection:, options: { class: 'js-table-dt dataTable no-footer' } do %>
Expand Down Expand Up @@ -47,6 +60,5 @@
<% end %>
<% end %>
<% end %>

</div>
</div>
Loading

0 comments on commit 3ffaa7f

Please sign in to comment.