From add2b2c213f3b943b7a7520b7bce4af24275b343 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Ferreira Date: Mon, 17 Dec 2018 15:19:52 -0200 Subject: [PATCH] add a modal fo the validator info --- .../_validator_metadata_modal.html.eex | 41 +++++++++++++++++++ .../templates/address/overview.html.eex | 14 ++++++- .../lib/block_scout_web/views/address_view.ex | 28 +++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex new file mode 100644 index 0000000000..60a022f32d --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex @@ -0,0 +1,41 @@ + diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex index d5b61a06c8..4f665cf09f 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex @@ -14,6 +14,13 @@ + <%= if validator_metadata = primary_validator_metadata(@address) do %> + + + + <% end %>

<%= address_title(@address) %> <%= gettext "Details" %>

<%= @address.hash %>

@@ -65,7 +72,7 @@ - + + + +<%= if validator_metadata do %> + <%= render BlockScoutWeb.AddressView, "_validator_metadata_modal.html", address_name: address_name, validator_metadata: validator_metadata %> +<% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/views/address_view.ex b/apps/block_scout_web/lib/block_scout_web/views/address_view.ex index f769ceebaf..f0f3c3ab63 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/address_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/address_view.ex @@ -148,6 +148,34 @@ defmodule BlockScoutWeb.AddressView do def primary_name(%Address{names: _}), do: nil + def primary_validator_metadata(%Address{names: [_ | _] = address_names}) do + case Enum.find(address_names, &(&1.primary == true)) do + %Address.Name{ + metadata: + metadata = %{ + "license_id" => _, + "address" => _, + "state" => _, + "zipcode" => _, + "expiration_date" => _, + "created_date" => _ + } + } -> + metadata + + _ -> + nil + end + end + + def primary_validator_metadata(%Address{names: _}), do: nil + + def format_datetime_string(unix_date) do + unix_date + |> DateTime.from_unix!() + |> Timex.format!("{M}-{D}-{YYYY}") + end + def qr_code(%Address{hash: hash}) do hash |> to_string()