From d733a5d0f2a9eea957654ad2ceccd05b2224aec0 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 24 Apr 2019 15:13:33 +0300 Subject: [PATCH] add Back button --- .../controllers/address_controller.ex | 17 +++++++++++++++-- .../templates/address/index.html.eex | 18 ++++++++++++------ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex index 730b09eb8f..6f834034cf 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex @@ -21,10 +21,12 @@ defmodule BlockScoutWeb.AddressController do nil next_page_params -> + next_params = Map.put(next_page_params, "prev_page_path", cur_page_path(conn, params)) + address_path( conn, :index, - next_page_params + next_params ) end @@ -34,7 +36,8 @@ defmodule BlockScoutWeb.AddressController do address_count: Chain.count_addresses_with_balance_from_cache(), exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(), total_supply: Chain.total_supply(), - next_page_path: next_page_path + next_page_path: next_page_path, + prev_page_path: params["prev_page_path"] ) end @@ -49,4 +52,14 @@ defmodule BlockScoutWeb.AddressController do def validation_count(%Address{} = address) do Chain.address_to_validation_count(address) end + + defp cur_page_path(conn, %{"hash" => _hash, "fetched_coin_balance" => _balance} = params) do + address_path( + conn, + :index, + params + ) + end + + defp cur_page_path(conn, _), do: address_path(conn, :index) end diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex index cf4e0efb95..535b732f44 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex @@ -8,8 +8,19 @@ <%= gettext " addresses of" %> <%= Cldr.Number.to_string!(@address_count, format: "#,###") %> <%= gettext "total addresses with a balance" %> -

+ <%= if @next_page_path do %> + " class="button button-secondary button-small float-right mt-0 ml-1"> + <%= gettext("Next") %> + + <% end %> + <%= if @prev_page_path do %> + " class="button button-secondary button-small float-right mt-0"> + <%= gettext("Back") %> + + <% end %> +

+
<%= for {{address, tx_count}, index} <- Enum.with_index(@address_tx_count_pairs, 1) do %> <%= render "_tile.html", @@ -17,11 +28,6 @@ total_supply: @total_supply, tx_count: tx_count, validation_count: validation_count(address) %> <% end %> - <%= if @next_page_path do %> - " class="button button-secondary button-small float-right mt-4"> - <%= gettext("Next") %> - - <% end %>