fix tags with descriptions

This commit is contained in:
byte[] 2019-12-05 17:01:09 -05:00
parent 8b6fef83e2
commit 0adfe58ab2
3 changed files with 11 additions and 8 deletions

View file

@ -45,7 +45,7 @@ defmodule PhilomenaWeb.ImageLoader do
body
|> search_tag_names()
|> load_tags()
|> render_dnp_entries(conn)
|> render_bodies(conn)
{records, tags}
end
@ -82,15 +82,18 @@ defmodule PhilomenaWeb.ImageLoader do
|> Repo.all()
end
defp render_dnp_entries([], _conn), do: []
defp render_dnp_entries([tag], conn) do
defp render_bodies([], _conn), do: []
defp render_bodies([tag], conn) do
dnp_bodies =
Renderer.render_collection(Enum.map(tag.dnp_entries, &%{body: &1.conditions || ""}), conn)
dnp_entries =
Enum.zip(dnp_bodies, tag.dnp_entries)
[{tag, dnp_entries}]
description =
Renderer.render_one(%{body: tag.description || ""})
[{tag, description, dnp_entries}]
end
defp render_dnp_entries(tags, _conn), do: tags
defp render_bodies(tags, _conn), do: tags
end

View file

@ -1,3 +1,3 @@
= render PhilomenaWeb.ImageView, "index.html", conn: @conn, tags: [{@tag, @dnp_entries}], images: @images, scope: [q: @search_query]
= render PhilomenaWeb.ImageView, "index.html", conn: @conn, tags: [{@tag, @body, @dnp_entries}], images: @images, scope: [q: @search_query]
= render PhilomenaWeb.SearchView, "_form.html", conn: @conn

View file

@ -137,8 +137,8 @@ defmodule PhilomenaWeb.ImageView do
end
def info_row(_conn, []), do: []
def info_row(conn, [{tag, dnp_entries}]) do
render PhilomenaWeb.TagView, "_tag_info_row.html", conn: conn, tag: tag, dnp_entries: dnp_entries
def info_row(conn, [{tag, description, dnp_entries}]) do
render PhilomenaWeb.TagView, "_tag_info_row.html", conn: conn, tag: tag, body: description, dnp_entries: dnp_entries
end
def info_row(conn, tags) do
render PhilomenaWeb.TagView, "_tags_row.html", conn: conn, tags: tags