don't show extra tag info if there is no extra info

This commit is contained in:
byte[] 2019-12-07 18:53:24 -05:00
parent c3f745ddee
commit 16d9282246
3 changed files with 38 additions and 35 deletions

View file

@ -25,45 +25,46 @@
= Enum.map_join(@tag.implied_tags, ", ", & &1.name)
br
br
= link "Toggle detailed information", to: "#", data: [click_toggle: ".tag-info__more"]
= if present?(@tag.public_links) or present?(@tag.implied_by_tags) or present?(@tag.description) do
br
= link "Toggle detailed information", to: "#", data: [click_toggle: ".tag-info__more"]
.tag-info__more
hr
.tag-info__more
hr
= if Enum.any?(@tag.public_links) do
strong> Associated links:
= if Enum.any?(@tag.public_links) do
strong> Associated links:
= for link <- @tag.public_links do
a> href=link.uri = link.uri
= for link <- @tag.public_links do
a> href=link.uri = link.uri
br
br
= if Enum.any?(@tag.public_links) do
strong> Associated users:
- users = Enum.map(@tag.public_links, & &1.user) |> Enum.uniq()
= if Enum.any?(@tag.public_links) do
strong> Associated users:
- users = Enum.map(@tag.public_links, & &1.user) |> Enum.uniq()
= for user <- users do
=> link user.name, to: Routes.profile_path(@conn, :show, user)
= for user <- users do
=> link user.name, to: Routes.profile_path(@conn, :show, user)
br
br
= if Enum.any?(@tag.implied_by_tags) do
input.toggle-box id="implied_by" type="checkbox" checked="false"
label for="implied_by"
' Implied by (warning: unfiltered)
= if Enum.any?(@tag.implied_by_tags) do
input.toggle-box id="implied_by" type="checkbox" checked="false"
label for="implied_by"
' Implied by (warning: unfiltered)
.toggle-box-container
.toggle-box-container__content
= for tag <- @tag.implied_by_tags do
=> link tag.name, to: Routes.tag_path(@conn, :show, tag)
.toggle-box-container
.toggle-box-container__content
= for tag <- @tag.implied_by_tags do
=> link tag.name, to: Routes.tag_path(@conn, :show, tag)
br
br
= if @tag.description not in [nil, ""] do
strong> Detailed description:
br
== @body
= if @tag.description not in [nil, ""] do
strong> Detailed description:
br
== @body
= if Enum.any?(@dnp_entries) do
hr

View file

@ -126,4 +126,13 @@ defmodule PhilomenaWeb.AppView do
def link_to_fingerprint(fp) do
link(String.slice(text_or_na(fp), 0..6), to: "#")
end
def blank?(nil), do: true
def blank?(""), do: true
def blank?([]), do: true
def blank?(map) when is_map(map), do: map == %{}
def blank?(str) when is_binary(str), do: String.trim(str) == ""
def blank?(_object), do: false
def present?(object), do: not blank?(object)
end

View file

@ -123,13 +123,6 @@ defmodule PhilomenaWeb.DuplicateReportView do
|> Enum.any?()
end
defp blank?(nil), do: true
defp blank?(""), do: true
defp blank?(str) when is_binary(str), do: String.trim(str) == ""
defp blank?(_object), do: false
defp present?(object), do: not blank?(object)
defp proper_subset?(set1, set2),
do: MapSet.subset?(set1, set2) and not MapSet.equal?(set1, set2)
end