mirror of
https://github.com/ash-project/ash_admin.git
synced 2024-09-19 21:03:52 +12:00
fix: Binary data display (#25)
This commit is contained in:
parent
b8858a933e
commit
4a502c2ced
3 changed files with 28 additions and 2 deletions
|
@ -553,6 +553,12 @@ defmodule AshAdmin.Components.Resource.Form do
|
|||
"""
|
||||
end
|
||||
|
||||
def render_attribute_input(assigns, %{type: Ash.Type.Binary}, _form, _value, _name) do
|
||||
~F"""
|
||||
<span class="italic">(binary fields cannot be edited)</span>
|
||||
"""
|
||||
end
|
||||
|
||||
def render_attribute_input(
|
||||
assigns,
|
||||
%{
|
||||
|
|
|
@ -315,6 +315,18 @@ defmodule AshAdmin.Components.Resource.Show do
|
|||
end
|
||||
end
|
||||
|
||||
defp render_attribute(assigns, _resource, record, %{name: name, type: Ash.Type.Binary}, _) do
|
||||
if Map.get(record, name) do
|
||||
~F"""
|
||||
<span class="italic">(binary data)</span>
|
||||
"""
|
||||
else
|
||||
~F"""
|
||||
(empty)
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
||||
defp render_attribute(assigns, resource, record, attribute, nested?) do
|
||||
if Ash.Type.embedded_type?(attribute.type) do
|
||||
both_classes = "ml-1 pl-2 pr-2"
|
||||
|
|
|
@ -134,14 +134,22 @@ defmodule AshAdmin.Components.Resource.Table do
|
|||
|> Map.get(attribute.name)
|
||||
|> (&apply(mod, func, [&1] ++ args)).()
|
||||
|
||||
format_attribute_value(data)
|
||||
format_attribute_value(data, attribute)
|
||||
end
|
||||
|
||||
defp process_attribute(_api, _record, _attr, _formats) do
|
||||
"..."
|
||||
end
|
||||
|
||||
defp format_attribute_value(data) do
|
||||
defp format_attribute_value(data, %{type: Ash.Type.Binary}) when data not in [[], nil, ""] do
|
||||
assigns = %{}
|
||||
|
||||
~F"""
|
||||
<span class='italic'>(binary)</span>
|
||||
"""
|
||||
end
|
||||
|
||||
defp format_attribute_value(data, _attribute) do
|
||||
if is_binary(data) and !String.valid?(data) do
|
||||
"..."
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue