add filter to token transfers

pull/2825/head
Ayrat Badykov 5 years ago
parent 3da7c8d057
commit 85fd91faac
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 3
      apps/block_scout_web/lib/block_scout_web/controllers/address_token_transfer_controller.ex
  2. 42
      apps/block_scout_web/lib/block_scout_web/templates/address_token_transfer/index.html.eex
  3. 8
      apps/block_scout_web/lib/block_scout_web/views/address_token_transfer_view.ex
  4. 11
      apps/block_scout_web/priv/gettext/default.pot
  5. 11
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po

@ -166,7 +166,7 @@ defmodule BlockScoutWeb.AddressTokenTransferController do
def index(
conn,
%{"address_id" => address_hash_string}
%{"address_id" => address_hash_string} = params
) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash) do
@ -176,6 +176,7 @@ defmodule BlockScoutWeb.AddressTokenTransferController do
address: address,
coin_balance_status: CoinBalanceOnDemand.trigger_fetch(address),
exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(),
filter: params["filter"],
current_path: current_path(conn),
counters_path: address_path(conn, :address_counters, %{"id" => to_string(address_hash)})
)

@ -12,6 +12,48 @@
</h2>
<% end %>
<%= if !assigns[:token] do %>
<div class="clearfix">
<h2 class="card-title float-left"><%= gettext "Transactions" %></h2>
<div class="dropdown float-right u-push-sm">
<button data-test="filter_dropdown" class="btn-dropdown-line dropdown-toggle" type="button"
id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Filter: <%= format_current_filter(@filter) %>
</button>
<div class="dropdown-menu dropdown-menu-right filter" aria-labelledby="dropdownMenu2">
<%= link(
gettext("All"),
to: address_token_transfers_path(@conn, :index, to_string(@address.hash)),
class: "address__link address__link--active dropdown-item",
"data-test": "filter_option"
) %>
<%= link(
gettext("To"),
to: address_token_transfers_path(
@conn,
:index,
to_string(@address.hash),
filter: "to"
),
class: "address__link address__link--active dropdown-item",
"data-test": "filter_option"
) %>
<%= link(
gettext("From"),
to: address_token_transfers_path(
@conn,
:index,
to_string(@address.hash),
filter: "from"
),
class: "address__link address__link--active dropdown-item",
"data-test": "filter_option"
) %>
</div>
</div>
</div>
<% end %>
<%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>
<div data-empty-response-message class="tile tile-muted text-center" style="display: none;">

@ -1,3 +1,11 @@
defmodule BlockScoutWeb.AddressTokenTransferView do
use BlockScoutWeb, :view
def format_current_filter(filter) do
case filter do
"to" -> gettext("To")
"from" -> gettext("From")
_ -> gettext("All")
end
end
end

@ -135,9 +135,11 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:27
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:25
#: lib/block_scout_web/templates/address_transaction/index.html.eex:23
#: lib/block_scout_web/templates/layout/_network_selector.html.eex:21
#: lib/block_scout_web/views/address_internal_transaction_view.ex:8
#: lib/block_scout_web/views/address_token_transfer_view.ex:8
#: lib/block_scout_web/views/address_transaction_view.ex:8
msgid "All"
msgstr ""
@ -706,8 +708,10 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:44
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:42
#: lib/block_scout_web/templates/address_transaction/index.html.eex:40
#: lib/block_scout_web/views/address_internal_transaction_view.ex:7
#: lib/block_scout_web/views/address_token_transfer_view.ex:7
#: lib/block_scout_web/views/address_transaction_view.ex:7
msgid "From"
msgstr ""
@ -810,7 +814,7 @@ msgid "There are no logs for this transaction."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:18
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:60
msgid "There are no token transfers for this address."
msgstr ""
@ -847,8 +851,10 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:33
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:31
#: lib/block_scout_web/templates/address_transaction/index.html.eex:29
#: lib/block_scout_web/views/address_internal_transaction_view.ex:6
#: lib/block_scout_web/views/address_token_transfer_view.ex:6
#: lib/block_scout_web/views/address_transaction_view.ex:6
msgid "To"
msgstr ""
@ -1302,7 +1308,7 @@ msgstr ""
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:61
#: lib/block_scout_web/templates/address_logs/index.html.eex:21
#: lib/block_scout_web/templates/address_token/index.html.eex:13
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:23
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:65
#: lib/block_scout_web/templates/address_transaction/index.html.eex:59
#: lib/block_scout_web/templates/address_validation/index.html.eex:22
#: lib/block_scout_web/templates/block_transaction/index.html.eex:23
@ -1855,6 +1861,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:3
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:17
#: lib/block_scout_web/templates/address_transaction/index.html.eex:15
#: lib/block_scout_web/templates/block_transaction/index.html.eex:10
#: lib/block_scout_web/templates/block_transaction/index.html.eex:18

@ -135,9 +135,11 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:27
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:25
#: lib/block_scout_web/templates/address_transaction/index.html.eex:23
#: lib/block_scout_web/templates/layout/_network_selector.html.eex:21
#: lib/block_scout_web/views/address_internal_transaction_view.ex:8
#: lib/block_scout_web/views/address_token_transfer_view.ex:8
#: lib/block_scout_web/views/address_transaction_view.ex:8
msgid "All"
msgstr ""
@ -706,8 +708,10 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:44
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:42
#: lib/block_scout_web/templates/address_transaction/index.html.eex:40
#: lib/block_scout_web/views/address_internal_transaction_view.ex:7
#: lib/block_scout_web/views/address_token_transfer_view.ex:7
#: lib/block_scout_web/views/address_transaction_view.ex:7
msgid "From"
msgstr ""
@ -810,7 +814,7 @@ msgid "There are no logs for this transaction."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:18
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:60
msgid "There are no token transfers for this address."
msgstr ""
@ -847,8 +851,10 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:33
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:31
#: lib/block_scout_web/templates/address_transaction/index.html.eex:29
#: lib/block_scout_web/views/address_internal_transaction_view.ex:6
#: lib/block_scout_web/views/address_token_transfer_view.ex:6
#: lib/block_scout_web/views/address_transaction_view.ex:6
msgid "To"
msgstr ""
@ -1302,7 +1308,7 @@ msgstr ""
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:61
#: lib/block_scout_web/templates/address_logs/index.html.eex:21
#: lib/block_scout_web/templates/address_token/index.html.eex:13
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:23
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:65
#: lib/block_scout_web/templates/address_transaction/index.html.eex:59
#: lib/block_scout_web/templates/address_validation/index.html.eex:22
#: lib/block_scout_web/templates/block_transaction/index.html.eex:23
@ -1855,6 +1861,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:3
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:17
#: lib/block_scout_web/templates/address_transaction/index.html.eex:15
#: lib/block_scout_web/templates/block_transaction/index.html.eex:10
#: lib/block_scout_web/templates/block_transaction/index.html.eex:18

Loading…
Cancel
Save