ash-project / ash_admin

A super-admin UI dashboard for Ash Framework applications, built with Phoenix LiveView.
https://hexdocs.pm/ash_admin
MIT License
106 stars 48 forks source link

support for {:array, UnionType} #152

Closed revati closed 6 months ago

revati commented 6 months ago

Caveat I believe this is ash_phoenix library fix rather than ash_admin

Describe the bug

Support {:array, Union}

To Reproduce

Make tickmet metadata as array: https://github.com/revati/ash_admin/commit/e1678a897877cff9c2efd7448bb1116a7d64df0c#diff-c8a6a1598f51e1ee927e6577d8fc5b4895ad054ea71d7f886d88f2410261af81R175

Expected behavior

Work fine. :D

Runtime

Additional context

Add any other context about the problem here.

revati commented 6 months ago

There is also issue with union types being in nested schema.

[error] GenServer #PID<0.5947.0> terminating
** (RuntimeError) Got no "_union_type" parameter, and no union type had a tag & tag_value pair matching the params.

If you are adding a form, select a type using `params: %{"_union_type" => "type_name"}`, or if one
or more of your types is using a tag you can set that tag with `params: %{"tag" => "tag_value"}`.

Params:

%{"_new_union_type" => "integer", "value" => "1"}

Available types:

[
  integer: [type: :integer, tag: :type, tag_value: :integer],
  atom: [
    type: :atom,
    constraints: [one_of: [:result, :param, :state, :static]],
    tag: :type,
    tag_value: :atom
  ],
  string: [type: :string, tag: :type, tag_value: :string]
]

    (ash_phoenix 2.0.1) lib/ash_phoenix/form/auto.ex:287: AshPhoenix.Form.Auto.determine_type/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/auto.ex:156: anonymous fn/5 in AshPhoenix.Form.Auto.unions/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:3156: AshPhoenix.Form.update_opts/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1331: anonymous fn/7 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1066: AshPhoenix.Form.validate/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1287: anonymous fn/9 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1218: anonymous fn/7 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1066: AshPhoenix.Form.validate/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1287: anonymous fn/9 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1218: anonymous fn/7 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1066: AshPhoenix.Form.validate/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1287: anonymous fn/9 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.1) lib/ash_phoenix/form/form.ex:1218: anonymous fn/7 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3