diff --git a/lib/philomena_web/templates/admin/report/_reports.html.slime b/lib/philomena_web/templates/admin/report/_reports.html.slime index 66bac4d9..5d83ea48 100644 --- a/lib/philomena_web/templates/admin/report/_reports.html.slime +++ b/lib/philomena_web/templates/admin/report/_reports.html.slime @@ -31,7 +31,7 @@ table.table td class=report_row_class(report) => pretty_state(report) - = user_abbrv report.admin + = user_abbrv @conn, report.admin td = link "Show", to: Routes.admin_report_path(@conn, :show, report) /- if report.open diff --git a/lib/philomena_web/views/admin/report_view.ex b/lib/philomena_web/views/admin/report_view.ex index a254328a..3fd66947 100644 --- a/lib/philomena_web/views/admin/report_view.ex +++ b/lib/philomena_web/views/admin/report_view.ex @@ -2,7 +2,7 @@ defmodule PhilomenaWeb.Admin.ReportView do use PhilomenaWeb, :view import PhilomenaWeb.ReportView, only: [link_to_reported_thing: 2, report_row_class: 1, pretty_state: 1] - import PhilomenaWeb.ProfileView, only: [user_abbrv: 1, current?: 2] + import PhilomenaWeb.ProfileView, only: [user_abbrv: 2, current?: 2] def truncate(<>), do: string <> "..." def truncate(string), do: string diff --git a/lib/philomena_web/views/profile_view.ex b/lib/philomena_web/views/profile_view.ex index 1db81795..ddc19785 100644 --- a/lib/philomena_web/views/profile_view.ex +++ b/lib/philomena_web/views/profile_view.ex @@ -50,10 +50,13 @@ defmodule PhilomenaWeb.ProfileView do Enum.map_join(tags, " || ", & &1.name) end - def user_abbrv(%{name: name}) do - String.upcase(initials_abbrv(name) || uppercase_abbrv(name) || first_letters_abbrv(name)) + def user_abbrv(conn, %{name: name} = user) do + abbrv = String.upcase(initials_abbrv(name) || uppercase_abbrv(name) || first_letters_abbrv(name)) + abbrv = "(" <> abbrv <> ")" + + link(abbrv, to: Routes.profile_path(conn, :show, user)) end - def user_abbrv(_user), do: content_tag(:span, "(n/a)") + def user_abbrv(_conn, _user), do: content_tag(:span, "(n/a)") defp initials_abbrv(name) do case String.split(name, " ", parts: 4) do @@ -72,7 +75,7 @@ defmodule PhilomenaWeb.ProfileView do end defp uppercase_abbrv(name) do - case Regex.scan(~r/[A-Z]/, name, capture: :all_but_first) do + case Regex.scan(~r/([A-Z])/, name, capture: :all_but_first) do [] -> nil