Use bootstrap dropdown for filter options

Co-authored-by: tmecklem <timothy@mecklem.com>
Co-authored-by: katibest <katibest@gaslight.co>
Co-authored-by: Luke Imhoff <luke.imhoff@dockyard.com>
pull/130/head
jimmay5469 7 years ago committed by Luke Imhoff
parent 9408f19ab6
commit ee7175e449
  1. 16
      apps/explorer_web/assets/css/_typography.scss
  2. 47
      apps/explorer_web/assets/css/app.scss
  3. 11
      apps/explorer_web/assets/css/explorer/_button.scss
  4. 4
      apps/explorer_web/assets/css/explorer/_filter.scss
  5. 2
      apps/explorer_web/lib/explorer_web/controllers/address_transaction_controller.ex
  6. 56
      apps/explorer_web/lib/explorer_web/templates/address_transaction/index.html.eex
  7. 9
      apps/explorer_web/lib/explorer_web/views/address_transaction_view.ex
  8. 30
      apps/explorer_web/priv/gettext/default.pot
  9. 30
      apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po
  10. 2
      apps/explorer_web/test/explorer_web/features/contributor_browsing_test.exs

@ -8,10 +8,6 @@ body {
h1 {
font-size: 28px;
font-family: $ma-sans-serif;
@media screen and (max-width: 768px) {
font-size: 22px;
}
}
h2 {
@ -45,15 +41,9 @@ p {
}
}
.special {
font-size: 11px;
font-style: italic;
}
a {
text-decoration: none;
color: $ma-teal;
color: explorer-color("gray", "900");
font-size: 12px;
&:hover,
@ -61,7 +51,3 @@ a {
text-decoration: none;
}
}
.support {
font-size: 15px !important;
}

@ -7,9 +7,52 @@
/* This file is for your main application css. */
$icon-font-path: "/fonts/"; /* use fonts from priv/static/fonts/ */
@import "bootstrap";
@import "explorer/sb-admin-2";
@import "variables";
@import "utilities";
@import "fonts";
// Core CSS
@import "node_modules/bootstrap/scss/alert";
// @import "node_modules/bootstrap/scss/badge";
// @import "node_modules/bootstrap/scss/breadcrumb";
// @import "node_modules/bootstrap/scss/button-group";
// @import "node_modules/bootstrap/scss/button";
// @import "node_modules/bootstrap/scss/card";
// @import "node_modules/bootstrap/scss/carousel";
// @import "node_modules/bootstrap/scss/close";
// @import "node_modules/bootstrap/scss/code";
// @import "node_modules/bootstrap/scss/custom-forms";
@import "node_modules/bootstrap/scss/dropdown";
// @import "node_modules/bootstrap/scss/forms";
// @import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/grid";
// @import "node_modules/bootstrap/scss/images";
// @import "node_modules/bootstrap/scss/input-group";
// @import "node_modules/bootstrap/scss/jumbotron";
// @import "node_modules/bootstrap/scss/list-group";
// @import "node_modules/bootstrap/scss/media";
// @import "node_modules/bootstrap/scss/mixins";
// @import "node_modules/bootstrap/scss/modal";
// @import "node_modules/bootstrap/scss/nav";
// @import "node_modules/bootstrap/scss/navbar";
// @import "node_modules/bootstrap/scss/pagination";
// @import "node_modules/bootstrap/scss/popover";
// @import "node_modules/bootstrap/scss/print";
// @import "node_modules/bootstrap/scss/progress";
// @import "node_modules/bootstrap/scss/reboot";
// @import "node_modules/bootstrap/scss/root";
// @import "node_modules/bootstrap/scss/tables";
// @import "node_modules/bootstrap/scss/tooltip";
@import "node_modules/bootstrap/scss/transitions";
// @import "node_modules/bootstrap/scss/type";
//Custom SCSS
@import "explorer/sb-admin-2";
@import "typography";
@import "utilities";
@import "explorer/button";
@import "explorer/filter";

@ -29,18 +29,19 @@
}
&--secondary {
background-color: explorer-color("gray", "400");
color: $ma-white;
background-color: explorer-color("gray", "300");
color: explorer-color("gray", "900");
font-size: 13px;
-webkit-transition: background-color .25s;
transition: background-color .25s;
font-weight: 300;
font-weight: 400;
&:hover,
&:focus {
background-color: explorer-color("slate", "900");
color: $ma-white;
background-color: explorer-color("gray", "400");
color: explorer-color("gray", "900");;
text-decoration: none;
outline: none !important;
}
}

@ -0,0 +1,4 @@
.filter {
min-width: 100%;
transform: translate3d(1px, 26px, 0px) !important;
}

@ -23,7 +23,7 @@ defmodule ExplorerWeb.AddressTransactionController do
pagination: params
)
render(conn, "index.html", address: address, page: page)
render(conn, "index.html", address: address, filter: params["filter"], page: page)
{:error, :not_found} ->
not_found(conn)

@ -26,28 +26,40 @@
) %>
</h2>
</div>
<div>
<%= link(
gettext("All"),
class: "address__link address__link--active",
to: address_transaction_path(@conn, :index, @conn.assigns.locale, @conn.params["address_id"])
) %>
<%= link(
gettext("To"),
to: address_transaction_path(@conn, :index, @conn.assigns.locale, @conn.params["address_id"], filter: "to"),
class: "address__link address__link--active"
) %>
<%= link(
gettext("From"),
to: address_transaction_path(
@conn,
:index,
@conn.assigns.locale,
@conn.params["address_id"],
filter: "from"
),
class: "address__link address__link--active"
) %>
<div class="dropdown u-float-right u-push-sm-right u-push-sm-bottom">
<button data-test="filterDropdown" class="button button--secondary 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"),
class: "address__link address__link--active dropdown-item",
to: address_transaction_path(@conn, :index, @conn.assigns.locale, @conn.params["address_id"])
) %>
<%= link(
gettext("To"),
class: "address__link address__link--active dropdown-item",
to: address_transaction_path(
@conn,
:index,
@conn.assigns.locale,
@conn.params["address_id"],
filter: "to"
)
) %>
<%= link(
gettext("From"),
class: "address__link address__link--active dropdown-item",
to: address_transaction_path(
@conn,
:index,
@conn.assigns.locale,
@conn.params["address_id"],
filter: "from"
)
) %>
</div>
</div>
<div class="transactions__container">
<table class="transactions__table">

@ -5,6 +5,15 @@ defmodule ExplorerWeb.AddressTransactionView do
defdelegate balance(address), to: AddressView
defdelegate fee(transaction), to: TransactionView
def format_current_filter(filter) do
case filter do
"to" -> gettext("To")
"from" -> gettext("From")
_ -> gettext("All")
end
end
defdelegate status(transacton), to: TransactionView
defdelegate value(transaction), to: TransactionView
end

@ -1,4 +1,4 @@
#: lib/explorer_web/templates/address_transaction/index.html.eex:61
#: lib/explorer_web/templates/address_transaction/index.html.eex:73
#: lib/explorer_web/templates/block/index.html.eex:30
#: lib/explorer_web/templates/block_transaction/index.html.eex:43
#: lib/explorer_web/templates/chain/show.html.eex:65
@ -8,7 +8,7 @@
msgid "Age"
msgstr ""
#: lib/explorer_web/templates/address_transaction/index.html.eex:60
#: lib/explorer_web/templates/address_transaction/index.html.eex:72
#: lib/explorer_web/templates/block_transaction/index.html.eex:42
#: lib/explorer_web/templates/chain/show.html.eex:28
#: lib/explorer_web/templates/chain/show.html.eex:100
@ -31,7 +31,7 @@ msgstr ""
msgid "Gas Used"
msgstr ""
#: lib/explorer_web/templates/address_transaction/index.html.eex:59
#: lib/explorer_web/templates/address_transaction/index.html.eex:71
#: lib/explorer_web/templates/block/show.html.eex:40
#: lib/explorer_web/templates/block_transaction/index.html.eex:41
#: lib/explorer_web/templates/chain/show.html.eex:99
@ -63,7 +63,7 @@ msgstr ""
msgid "Transactions"
msgstr ""
#: lib/explorer_web/templates/address_transaction/index.html.eex:64
#: lib/explorer_web/templates/address_transaction/index.html.eex:76
#: lib/explorer_web/templates/block_transaction/index.html.eex:46
#: lib/explorer_web/templates/chain/show.html.eex:102
#: lib/explorer_web/templates/pending_transaction/index.html.eex:38
@ -158,13 +158,14 @@ msgstr ""
msgid "Address"
msgstr ""
#: lib/explorer_web/templates/address_transaction/index.html.eex:41
#: lib/explorer_web/templates/address_transaction/index.html.eex:62
#: lib/explorer_web/templates/address_transaction/index.html.eex:52
#: lib/explorer_web/templates/address_transaction/index.html.eex:74
#: lib/explorer_web/templates/block_transaction/index.html.eex:44
#: lib/explorer_web/templates/pending_transaction/index.html.eex:36
#: lib/explorer_web/templates/transaction/index.html.eex:37
#: lib/explorer_web/templates/transaction/overview.html.eex:47
#: lib/explorer_web/templates/transaction/show.html.eex:26
#: lib/explorer_web/views/address_transaction_view.ex:12
msgid "From"
msgstr ""
@ -177,13 +178,14 @@ msgstr ""
msgid "Success"
msgstr ""
#: lib/explorer_web/templates/address_transaction/index.html.eex:36
#: lib/explorer_web/templates/address_transaction/index.html.eex:63
#: lib/explorer_web/templates/address_transaction/index.html.eex:41
#: lib/explorer_web/templates/address_transaction/index.html.eex:75
#: lib/explorer_web/templates/block_transaction/index.html.eex:45
#: lib/explorer_web/templates/pending_transaction/index.html.eex:37
#: lib/explorer_web/templates/transaction/index.html.eex:38
#: lib/explorer_web/templates/transaction/overview.html.eex:61
#: lib/explorer_web/templates/transaction/show.html.eex:27
#: lib/explorer_web/views/address_transaction_view.ex:11
msgid "To"
msgstr ""
@ -302,7 +304,7 @@ msgstr ""
msgid "Out of Gas"
msgstr ""
#: lib/explorer_web/templates/address_transaction/index.html.eex:57
#: lib/explorer_web/templates/address_transaction/index.html.eex:69
#: lib/explorer_web/templates/block_transaction/index.html.eex:39
#: lib/explorer_web/templates/pending_transaction/index.html.eex:31
#: lib/explorer_web/templates/transaction/index.html.eex:31
@ -318,8 +320,8 @@ msgid "Showing #%{number}"
msgstr ""
#: lib/explorer_web/templates/address_transaction/index.html.eex:12
#: lib/explorer_web/templates/address_transaction/index.html.eex:112
#: lib/explorer_web/templates/address_transaction/index.html.eex:115
#: lib/explorer_web/templates/address_transaction/index.html.eex:124
#: lib/explorer_web/templates/address_transaction/index.html.eex:127
#: lib/explorer_web/templates/block_transaction/index.html.eex:90
#: lib/explorer_web/templates/chain/show.html.eex:128
#: lib/explorer_web/templates/pending_transaction/index.html.eex:80
@ -371,11 +373,11 @@ msgstr ""
msgid "Wei"
msgstr ""
#: lib/explorer_web/templates/address_transaction/index.html.eex:31
#: lib/explorer_web/templates/address_transaction/index.html.eex:36
#: lib/explorer_web/views/address_transaction_view.ex:13
msgid "All"
msgstr ""
#, elixir-format
#: lib/explorer_web/templates/address_transaction/index.html.eex:65
#: lib/explorer_web/templates/address_transaction/index.html.eex:77
msgid "Fee"
msgstr ""

@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Language: en\n"
#: lib/explorer_web/templates/address_transaction/index.html.eex:61
#: lib/explorer_web/templates/address_transaction/index.html.eex:73
#: lib/explorer_web/templates/block/index.html.eex:30
#: lib/explorer_web/templates/block_transaction/index.html.eex:43
#: lib/explorer_web/templates/chain/show.html.eex:65
@ -20,7 +20,7 @@ msgstr ""
msgid "Age"
msgstr "Age"
#: lib/explorer_web/templates/address_transaction/index.html.eex:60
#: lib/explorer_web/templates/address_transaction/index.html.eex:72
#: lib/explorer_web/templates/block_transaction/index.html.eex:42
#: lib/explorer_web/templates/chain/show.html.eex:28
#: lib/explorer_web/templates/chain/show.html.eex:100
@ -43,7 +43,7 @@ msgstr "%{year} POA Network Ltd. All rights reserved"
msgid "Gas Used"
msgstr "Gas Used"
#: lib/explorer_web/templates/address_transaction/index.html.eex:59
#: lib/explorer_web/templates/address_transaction/index.html.eex:71
#: lib/explorer_web/templates/block/show.html.eex:40
#: lib/explorer_web/templates/block_transaction/index.html.eex:41
#: lib/explorer_web/templates/chain/show.html.eex:99
@ -75,7 +75,7 @@ msgstr "POA Network Explorer"
msgid "Transactions"
msgstr "Transactions"
#: lib/explorer_web/templates/address_transaction/index.html.eex:64
#: lib/explorer_web/templates/address_transaction/index.html.eex:76
#: lib/explorer_web/templates/block_transaction/index.html.eex:46
#: lib/explorer_web/templates/chain/show.html.eex:102
#: lib/explorer_web/templates/pending_transaction/index.html.eex:38
@ -170,13 +170,14 @@ msgstr "%{count} transactions in this block"
msgid "Address"
msgstr "Address"
#: lib/explorer_web/templates/address_transaction/index.html.eex:41
#: lib/explorer_web/templates/address_transaction/index.html.eex:62
#: lib/explorer_web/templates/address_transaction/index.html.eex:52
#: lib/explorer_web/templates/address_transaction/index.html.eex:74
#: lib/explorer_web/templates/block_transaction/index.html.eex:44
#: lib/explorer_web/templates/pending_transaction/index.html.eex:36
#: lib/explorer_web/templates/transaction/index.html.eex:37
#: lib/explorer_web/templates/transaction/overview.html.eex:47
#: lib/explorer_web/templates/transaction/show.html.eex:26
#: lib/explorer_web/views/address_transaction_view.ex:12
msgid "From"
msgstr "From"
@ -189,13 +190,14 @@ msgstr "Overview"
msgid "Success"
msgstr "Success"
#: lib/explorer_web/templates/address_transaction/index.html.eex:36
#: lib/explorer_web/templates/address_transaction/index.html.eex:63
#: lib/explorer_web/templates/address_transaction/index.html.eex:41
#: lib/explorer_web/templates/address_transaction/index.html.eex:75
#: lib/explorer_web/templates/block_transaction/index.html.eex:45
#: lib/explorer_web/templates/pending_transaction/index.html.eex:37
#: lib/explorer_web/templates/transaction/index.html.eex:38
#: lib/explorer_web/templates/transaction/overview.html.eex:61
#: lib/explorer_web/templates/transaction/show.html.eex:27
#: lib/explorer_web/views/address_transaction_view.ex:11
msgid "To"
msgstr "To"
@ -314,7 +316,7 @@ msgstr ""
msgid "Out of Gas"
msgstr ""
#: lib/explorer_web/templates/address_transaction/index.html.eex:57
#: lib/explorer_web/templates/address_transaction/index.html.eex:69
#: lib/explorer_web/templates/block_transaction/index.html.eex:39
#: lib/explorer_web/templates/pending_transaction/index.html.eex:31
#: lib/explorer_web/templates/transaction/index.html.eex:31
@ -330,8 +332,8 @@ msgid "Showing #%{number}"
msgstr ""
#: lib/explorer_web/templates/address_transaction/index.html.eex:12
#: lib/explorer_web/templates/address_transaction/index.html.eex:112
#: lib/explorer_web/templates/address_transaction/index.html.eex:115
#: lib/explorer_web/templates/address_transaction/index.html.eex:124
#: lib/explorer_web/templates/address_transaction/index.html.eex:127
#: lib/explorer_web/templates/block_transaction/index.html.eex:90
#: lib/explorer_web/templates/chain/show.html.eex:128
#: lib/explorer_web/templates/pending_transaction/index.html.eex:80
@ -383,11 +385,11 @@ msgstr ""
msgid "Wei"
msgstr ""
#: lib/explorer_web/templates/address_transaction/index.html.eex:31
#: lib/explorer_web/templates/address_transaction/index.html.eex:36
#: lib/explorer_web/views/address_transaction_view.ex:13
msgid "All"
msgstr ""
#, elixir-format
#: lib/explorer_web/templates/address_transaction/index.html.eex:65
#: lib/explorer_web/templates/address_transaction/index.html.eex:77
msgid "Fee"
msgstr ""

@ -243,6 +243,7 @@ defmodule ExplorerWeb.UserListTest do
test "can filter to only see transactions to an address", %{session: session} do
session
|> visit("/en/addresses/0xlincoln")
|> click(css("[data-test='filterDropdown']", text: "Filter: All"))
|> click(css(".address__link", text: "To"))
|> assert_has(css(".transactions__link--long-hash", text: "0xSk8"))
|> refute_has(css(".transactions__link--long-hash", text: "0xrazerscooter"))
@ -251,6 +252,7 @@ defmodule ExplorerWeb.UserListTest do
test "can filter to only see transactions from an address", %{session: session} do
session
|> visit("/en/addresses/0xlincoln")
|> click(css("[data-test='filterDropdown']", text: "Filter: All"))
|> click(css(".address__link", text: "From"))
|> assert_has(css(".transactions__link--long-hash", text: "0xrazerscooter"))
|> refute_has(css(".transactions__link--long-hash", text: "0xSk8"))

Loading…
Cancel
Save