Skip to content

Commit

Permalink
chore: get build passing
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Jun 25, 2024
1 parent a935578 commit 4c31983
Show file tree
Hide file tree
Showing 2 changed files with 194 additions and 157 deletions.
74 changes: 29 additions & 45 deletions lib/ash_admin/components/resource/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1084,36 +1084,37 @@ defmodule AshAdmin.Components.Resource.Form do
name: @name || @form.name <> "[#{@attribute.name}]"
}
) %>
<% end %>
<button
:if={can_append_embed?(@form.source, @attribute.name, @attribute.type)}
type="button"
phx-click="add_form"
phx-target={@myself}
phx-value-union-type={@union_type}
phx-value-pkey={embedded_type_pkey(@attribute.type)}
phx-value-path={@form.name <> "[#{@attribute.name}]"}
class="flex h-6 w-6 mt-2 border-gray-600 hover:bg-gray-400 rounded-md justify-center items-center"
>
<.icon name="hero-plus" class="h-4 w-4 text-gray-500" />
</button>
<% end %>
<button
:if={can_append_embed?(@form.source, @attribute.name, @attribute.type)}
type="button"
phx-click="add_form"
phx-target={@myself}
phx-value-union-type={@union_type}
phx-value-pkey={embedded_type_pkey(@attribute.type)}
phx-value-path={@form.name <> "[#{@attribute.name}]"}
class="flex h-6 w-6 mt-2 border-gray-600 hover:bg-gray-400 rounded-md justify-center items-center"
>
<.icon name="hero-plus" class="h-4 w-4 text-gray-500" />
</button>
<% Ash.Type.embedded_type?(@attribute.type) && match?(%AshPhoenix.Form{}, @value) -> %>
<% inner_form = to_form(@value) %>
<.input
:for={kv <- inner_form.hidden}
name={inner_form.name <> "[#{elem(kv, 0)}]"}
value={elem(kv, 1)}
type="hidden"
/>
<%= render_attributes(
assigns,
inner_form.source.resource,
inner_form.source.source.action,
%{ inner_form |
id: @id || @form.id <> "_#{@attribute.name}",
name: @name || @form.name <> "[#{@attribute.name}]"
}
) %>
<.input
:for={kv <- inner_form.hidden}
name={inner_form.name <> "[#{elem(kv, 0)}]"}
value={elem(kv, 1)}
type="hidden"
/>
<%= render_attributes(
assigns,
inner_form.source.resource,
inner_form.source.source.action,
%{
inner_form
| id: @id || @form.id <> "_#{@attribute.name}",
name: @name || @form.name <> "[#{@attribute.name}]"
}
) %>
<% Ash.Type.embedded_type?(@attribute.type) -> %>
<.inputs_for :let={inner_form} field={@form[@attribute.name]}>
<.input
Expand Down Expand Up @@ -1196,7 +1197,6 @@ defmodule AshAdmin.Components.Resource.Form do
id,
union_type
) do

name = name || form.name <> "[#{attribute.name}]"
id = id || form.id <> "_#{attribute.name}"

Expand Down Expand Up @@ -1573,7 +1573,6 @@ defmodule AshAdmin.Components.Resource.Form do
other ->
other
end)
|> indexed_list()
|> append_to_and_map(to_append)

params =
Expand All @@ -1583,8 +1582,6 @@ defmodule AshAdmin.Components.Resource.Form do
list
)

IO.inspect(params)

form = AshPhoenix.Form.validate(socket.assigns.form, params)

{:noreply,
Expand Down Expand Up @@ -1694,19 +1691,6 @@ defmodule AshAdmin.Components.Resource.Form do
|> Map.update!(key, &put_in_creating(&1, rest, value))
end

defp indexed_list(map) when is_map(map) do
map
|> Map.keys()
|> Enum.map(&String.to_integer/1)
|> Enum.sort()
|> Enum.map(&map[to_string(&1)])
rescue
_ ->
List.wrap(map)
end

defp indexed_list(other), do: List.wrap(other)

defp remove_value(form, field, index) do
current_value =
form
Expand Down
Loading

0 comments on commit 4c31983

Please sign in to comment.