diff --git a/config/config.exs b/config/config.exs index 40c986bd..228486c4 100644 --- a/config/config.exs +++ b/config/config.exs @@ -34,7 +34,6 @@ use Mix.Config # ] config :ex_admin, repo: MyProject.Repo, - module: MyProject, modules: [], module: ExAdmin diff --git a/lib/ex_admin/filter.ex b/lib/ex_admin/filter.ex index 84233246..2a1276b6 100644 --- a/lib/ex_admin/filter.ex +++ b/lib/ex_admin/filter.ex @@ -161,7 +161,7 @@ defmodule ExAdmin.Filter do end) end - def string_selected_name(name, nil), do: "#{name}_equals" + def string_selected_name(name, nil), do: "#{name}_contains" def string_selected_name(name, q) do Enum.reduce(string_options(), "#{name}_eq", fn {k, _}, acc -> diff --git a/lib/ex_admin/form.ex b/lib/ex_admin/form.ex index 1c8c3714..6cb40f89 100644 --- a/lib/ex_admin/form.ex +++ b/lib/ex_admin/form.ex @@ -1608,7 +1608,9 @@ defmodule ExAdmin.Form do val = Integer.to_string(x) {val, val} end) - _ -> value + + _ -> + value end select "", [{:class, "form-control date-time"} | opts] do diff --git a/lib/ex_admin/index.ex b/lib/ex_admin/index.ex index d51a4c21..9f7d95aa 100644 --- a/lib/ex_admin/index.ex +++ b/lib/ex_admin/index.ex @@ -113,6 +113,7 @@ defmodule ExAdmin.Index do import ExAdmin.Gettext import Kernel, except: [div: 2, to_string: 1] use Xain + # alias ExAdmin.Schema @doc false diff --git a/lib/ex_admin/render.ex b/lib/ex_admin/render.ex index af6bafe8..b1b88a27 100644 --- a/lib/ex_admin/render.ex +++ b/lib/ex_admin/render.ex @@ -1,3 +1,4 @@ +import Phoenix.HTML defprotocol ExAdmin.Render do # @fallback_to_any true @@ -10,7 +11,7 @@ defimpl ExAdmin.Render, for: Atom do end defimpl ExAdmin.Render, for: BitString do - def to_string(data), do: data + def to_string(data), do: data |> html_escape |> Phoenix.HTML.safe_to_string() end defimpl ExAdmin.Render, for: Integer do diff --git a/lib/ex_admin/schema.ex b/lib/ex_admin/schema.ex index e6c85af1..3ac4f0a1 100644 --- a/lib/ex_admin/schema.ex +++ b/lib/ex_admin/schema.ex @@ -26,6 +26,7 @@ defmodule ExAdmin.Schema do end def type(%Ecto.Query{from: %Ecto.Query.FromExpr{source: {_, mod}}}, key), do: type(mod, key) + def type(module, key) when is_atom(module) do module.__schema__(:type, key) end diff --git a/lib/ex_admin/show.ex b/lib/ex_admin/show.ex index 64e520dd..696e1500 100644 --- a/lib/ex_admin/show.ex +++ b/lib/ex_admin/show.ex @@ -65,7 +65,8 @@ defmodule ExAdmin.Show do import ExAdmin.Utils import ExAdmin.ViewHelpers _ = var!(resource) - _ = unquote(resource) # allow others downstream to not have warnings of not using + # allow others downstream to not have warnings of not using + _ = unquote(resource) markup safe: true do unquote(contents) diff --git a/lib/ex_admin/table.ex b/lib/ex_admin/table.ex index e7c1a425..7a0a52c4 100644 --- a/lib/ex_admin/table.ex +++ b/lib/ex_admin/table.ex @@ -2,15 +2,17 @@ Code.ensure_compiled(ExAdmin.Utils) defmodule ExAdmin.Table do @moduledoc false - require Integer use Xain import ExAdmin.Helpers import ExAdmin.Utils import ExAdmin.Render import ExAdmin.Theme.Helpers import Kernel, except: [to_string: 1] + alias ExAdmin.Schema + require Integer + def attributes_table(conn, resource, schema) do theme_module(conn, Table).theme_attributes_table(conn, resource, schema, model_name(resource)) end @@ -90,8 +92,7 @@ defmodule ExAdmin.Table do build_field(resource, conn, {f_name, Enum.into(opts, %{})}, fn contents, f_name -> td ".td-#{parameterize(f_name)}" do contents - |> HtmlSanitizeEx.html5() - # |> Phoenix.HTML.raw() + |> Phoenix.HTML.raw() end end) end @@ -122,11 +123,13 @@ defmodule ExAdmin.Table do def do_panel(conn, columns \\ [], table_opts \\ [], output \\ []) - def do_panel(_conn, [], _table_opts, output), - do: - output - |> Enum.reverse() - |> Enum.join() + def do_panel(_conn, [] = columns, table_opts, output) do + output + |> Enum.reverse() + |> Enum.map(fn x -> x |> Phoenix.HTML.html_escape() |> Phoenix.HTML.safe_to_string() end) + |> Enum.join() + |> Phoenix.HTML.raw() + end def do_panel( conn, @@ -156,8 +159,11 @@ defmodule ExAdmin.Table do def do_panel(conn, [{:contents, %{contents: content}} | tail], table_opts, output) do output = [ case content do - {:safe, _} -> Phoenix.HTML.safe_to_string(content) - content -> content + {:safe, _} -> + Phoenix.HTML.safe_to_string(content) + + content -> + content end |> Xain.raw() | output @@ -309,8 +315,7 @@ defmodule ExAdmin.Table do td to_class(".td-", field_name) do contents |> text() - |> HtmlSanitizeEx.html5() - # |> Phoenix.HTML.raw() + |> Phoenix.HTML.raw() end end end @@ -320,26 +325,27 @@ defmodule ExAdmin.Table do end def handle_contents(contents, field_name) when is_list(contents) do - content = contents - |> Enum.map(fn(content) -> - content - |> HtmlSanitizeEx.html5() - # |> Phoenix.HTML.raw() - end) - |> Enum.join(" ") - _res = markup do - td to_class(".td-", field_name) do + content = + contents + |> Enum.map(fn content -> content + |> Phoenix.HTML.raw() + end) + |> Enum.join(" ") + + _res = + markup do + td to_class(".td-", field_name) do + content + end end - end end def handle_contents(contents, field_name) do markup do td to_class(".td-", field_name) do contents - |> HtmlSanitizeEx.html5() - # |> Phoenix.HTML.raw() + |> Phoenix.HTML.raw() end end end diff --git a/lib/ex_admin/themes/active_admin/filter.ex b/lib/ex_admin/themes/active_admin/filter.ex index 12757fb8..69a12d83 100644 --- a/lib/ex_admin/themes/active_admin/filter.ex +++ b/lib/ex_admin/themes/active_admin/filter.ex @@ -59,9 +59,9 @@ defmodule ExAdmin.Theme.ActiveAdmin.Filter do def build_field({name, type}, q, defn) when type in [ - # Ecto.DateTime, - # Ecto.Date, - # Ecto.Time, + # Ecto.DateTime, + # Ecto.Date, + # Ecto.Time, Date, Time, Timex.Ecto.DateTime, diff --git a/lib/ex_admin/themes/admin_lte2/form.ex b/lib/ex_admin/themes/admin_lte2/form.ex index 401a7874..200c26f8 100644 --- a/lib/ex_admin/themes/admin_lte2/form.ex +++ b/lib/ex_admin/themes/admin_lte2/form.ex @@ -187,8 +187,10 @@ defmodule ExAdmin.Theme.AdminLte2.Form do case item do bin when is_binary(bin) -> {htmls <> bin, chgs} + {:safe, change} -> {htmls, [change | chgs]} + {bin, change} -> {htmls <> bin, [change | chgs]} end diff --git a/lib/ex_admin/view_helpers.ex b/lib/ex_admin/view_helpers.ex index 6a0f9165..08694a0f 100644 --- a/lib/ex_admin/view_helpers.ex +++ b/lib/ex_admin/view_helpers.ex @@ -116,6 +116,7 @@ defmodule ExAdmin.ViewHelpers do ], %{} ) + # {~S(\"), ~S(\\")}, def escape_javascript(unescaped) do diff --git a/lib/mix/tasks/admin.gen.resource.ex b/lib/mix/tasks/admin.gen.resource.ex index 04025ef1..f82c46c3 100644 --- a/lib/mix/tasks/admin.gen.resource.ex +++ b/lib/mix/tasks/admin.gen.resource.ex @@ -29,17 +29,22 @@ defmodule Mix.Tasks.Admin.Gen.Resource do defp copy_file(%Config{module: module, package_path: package_path} = config) do filename = Path.basename(Macro.underscore(module)) <> ".ex" - web_dir = Path.wildcard("lib/*_web") |> hd # TODO: use app_web_path - - dest_path = case Macro.underscore(Blog.Post) |> Path.dirname do #Path.join(~w(web admin)) - "." -> - Path.join([web_dir, "admin"]) - dir -> - if !File.exists? Path.join([web_dir, "admin", dir]) do - Path.join([web_dir, "admin", dir])|> File.mkdir - end - Path.join([web_dir, "admin", dir]) - end + # TODO: use app_web_path + web_dir = Path.wildcard("lib/*_web") |> hd + + # Path.join(~w(web admin)) + dest_path = + case Macro.underscore(Blog.Post) |> Path.dirname() do + "." -> + Path.join([web_dir, "admin"]) + + dir -> + if !File.exists?(Path.join([web_dir, "admin", dir])) do + Path.join([web_dir, "admin", dir]) |> File.mkdir() + end + + Path.join([web_dir, "admin", dir]) + end dest_file_path = Path.join(dest_path, filename) source_file = Path.join([package_path | ~w(priv templates admin.gen.resource resource.exs)]) diff --git a/lib/mix/tasks/admin.install.ex b/lib/mix/tasks/admin.install.ex index fdfd84bc..df375fc8 100644 --- a/lib/mix/tasks/admin.install.ex +++ b/lib/mix/tasks/admin.install.ex @@ -282,7 +282,13 @@ defmodule Mix.Tasks.Admin.Install do defp copy_vendor(from_path, path, filename) do dest = Path.join([File.cwd!(), "assets", "static", path]) File.mkdir_p(dest) - IO.puts("copying #{Path.join([get_package_path(), from_path, path, filename])} -> #{Path.join([dest, filename])}") + + IO.puts( + "copying #{Path.join([get_package_path(), from_path, path, filename])} -> #{ + Path.join([dest, filename]) + }" + ) + File.cp( Path.join([get_package_path(), from_path, path, filename]), Path.join([dest, filename]) @@ -292,9 +298,10 @@ defmodule Mix.Tasks.Admin.Install do defp copy_vendor_r(base_path, path) do dest_dir = Path.join([File.cwd!(), "assets", "static", path]) File.mkdir_p(dest_dir) + Path.join([get_package_path(), base_path, path]) - |> File.ls! - |> Enum.each(fn(file) -> + |> File.ls!() + |> Enum.each(fn file -> dest = Path.join([dest_dir, file]) IO.puts("Copying #{Path.join([get_package_path(), base_path, path, file])} -> #{dest}") File.cp_r(Path.join([get_package_path(), base_path, path, file]), dest) diff --git a/mix.exs b/mix.exs index 9ba032ad..a3c19443 100644 --- a/mix.exs +++ b/mix.exs @@ -60,7 +60,7 @@ defmodule ExAdmin.Mixfile do [ {:decimal, "~> 1.0"}, {:phoenix, "~> 1.4"}, - {:phoenix_html, "~> 2.6"}, + {:phoenix_html, "~> 2.12"}, {:ecto, "~> 3.0"}, {:phoenix_ecto, "~> 4.0"}, {:postgrex, "~> 0.14", only: :test}, @@ -69,7 +69,7 @@ defmodule ExAdmin.Mixfile do {:plug_cowboy, "~> 2.0"}, {:inflex, "~> 1.7"}, {:scrivener_ecto, "~> 2.0"}, - {:xain, "0.6.1"}, #TODO: https://github.com/smpallen99/xain/issues/20 + {:xain, "0.6.2"}, {:csvlixir, "~> 1.0.0"}, {:exactor, "~> 2.2.0"}, {:ex_doc, "~> 0.16.2", only: :dev}, diff --git a/mix.lock b/mix.lock index bbc92739..811ba354 100644 --- a/mix.lock +++ b/mix.lock @@ -1,53 +1,53 @@ %{ - "certifi": {:hex, :certifi, "2.4.2", "75424ff0f3baaccfd34b1214184b6ef616d89e420b258bb0a5ea7d7bc628f7f0", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, - "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"}, - "cowboy": {:hex, :cowboy, "2.5.0", "4ef3ae066ee10fe01ea3272edc8f024347a0d3eb95f6fbb9aed556dacbfc1337", [:rebar3], [{:cowlib, "~> 2.6.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.6.2", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"}, - "cowlib": {:hex, :cowlib, "2.6.0", "8aa629f81a0fc189f261dc98a42243fa842625feea3c7ec56c48f4ccdb55490f", [:rebar3], [], "hexpm"}, - "csvlixir": {:hex, :csvlixir, "1.0.0", "e9fd30abfca2d312390060e86bb7ec52487c813824dcccad45bb13e85ecad6b1", [:mix], [], "hexpm"}, - "db_connection": {:hex, :db_connection, "2.1.0", "122e2f62c4906bf2e49554f1e64db5030c19229aa40935f33088e7d543aa79d0", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"}, - "decimal": {:hex, :decimal, "1.7.0", "30d6b52c88541f9a66637359ddf85016df9eb266170d53105f02e4a67e00c5aa", [:mix], [], "hexpm"}, - "earmark": {:hex, :earmark, "1.3.2", "b840562ea3d67795ffbb5bd88940b1bed0ed9fa32834915125ea7d02e35888a5", [:mix], [], "hexpm"}, - "ecto": {:hex, :ecto, "3.1.6", "e890bf66c1d4d8e2b8e010f7cba092a08139b55437bc3382371f72a6ee40757e", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, - "ex_doc": {:hex, :ex_doc, "0.20.2", "1bd0dfb0304bade58beb77f20f21ee3558cc3c753743ae0ddbb0fd7ba2912331", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, + "certifi": {:hex, :certifi, "2.4.2", "75424ff0f3baaccfd34b1214184b6ef616d89e420b258bb0a5ea7d7bc628f7f0", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "01d479edba0569a7b7a2c8bf923feeb6dc6a358edc2965ef69aea9ba288bb243"}, + "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"}, + "cowboy": {:hex, :cowboy, "2.5.0", "4ef3ae066ee10fe01ea3272edc8f024347a0d3eb95f6fbb9aed556dacbfc1337", [:rebar3], [{:cowlib, "~> 2.6.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.6.2", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "07763d253314bd76017157e3a33e2cd32c1500e0ecf7ceb4e80aa09d2939aa30"}, + "cowlib": {:hex, :cowlib, "2.6.0", "8aa629f81a0fc189f261dc98a42243fa842625feea3c7ec56c48f4ccdb55490f", [:rebar3], [], "hexpm", "45a1a08e05e4c66f2af665295955e337d52c2d33b1f1cf24d353cadeddf34992"}, + "csvlixir": {:hex, :csvlixir, "1.0.0", "e9fd30abfca2d312390060e86bb7ec52487c813824dcccad45bb13e85ecad6b1", [:mix], [], "hexpm", "1f3a71331462ac85e962bf74d3b687b8b5e8861850e12ee02f4ef0fbdc0591f2"}, + "db_connection": {:hex, :db_connection, "2.1.0", "122e2f62c4906bf2e49554f1e64db5030c19229aa40935f33088e7d543aa79d0", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "f398f3144db606de82ed42c2ddc69767f0607abdb796e8220de5f0fcf80f5ba4"}, + "decimal": {:hex, :decimal, "1.7.0", "30d6b52c88541f9a66637359ddf85016df9eb266170d53105f02e4a67e00c5aa", [:mix], [], "hexpm", "771ea78576e5fa505ad58a834f57915c7f5f9df11c87a598a01fdf6065ccfb5d"}, + "earmark": {:hex, :earmark, "1.4.4", "4821b8d05cda507189d51f2caeef370cf1e18ca5d7dfb7d31e9cafe6688106a4", [:mix], [], "hexpm", "1f93aba7340574847c0f609da787f0d79efcab51b044bb6e242cae5aca9d264d"}, + "ecto": {:hex, :ecto, "3.1.6", "e890bf66c1d4d8e2b8e010f7cba092a08139b55437bc3382371f72a6ee40757e", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "e3056962ef9ecdfc48c195600d37e88bbc362b35da74e28ac7be1ab5347b59e1"}, + "ex_doc": {:hex, :ex_doc, "0.16.4", "4bf6b82d4f0a643b500366ed7134896e8cccdbab4d1a7a35524951b25b1ec9f0", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm", "90e39c592b4952d35eb122b70d656a8b2ffa248d7b0fa428b314ce2176c69861"}, "ex_queb": {:git, "https://github.com/iwarshak/ex_queb.git", "32bac2a5727f3a35800ddbd70b0ba7b8ce933b72", []}, - "exactor": {:hex, :exactor, "2.2.4", "5efb4ddeb2c48d9a1d7c9b465a6fffdd82300eb9618ece5d34c3334d5d7245b1", [:mix], [], "hexpm"}, - "excoveralls": {:hex, :excoveralls, "0.10.3", "b090a3fbcb3cfa136f0427d038c92a9051f840953ec11b40ee74d9d4eac04d1e", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, + "exactor": {:hex, :exactor, "2.2.4", "5efb4ddeb2c48d9a1d7c9b465a6fffdd82300eb9618ece5d34c3334d5d7245b1", [:mix], [], "hexpm", "1222419f706e01bfa1095aec9acf6421367dcfab798a6f67c54cf784733cd6b5"}, + "excoveralls": {:hex, :excoveralls, "0.10.3", "b090a3fbcb3cfa136f0427d038c92a9051f840953ec11b40ee74d9d4eac04d1e", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "14d618681225c7bd230403402cbfd19bbc7dd91d9ad8f2145cf2daac9976ccd5"}, "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"}, "factory_girl_elixir": {:hex, :factory_girl_elixir, "0.1.1", "2c2b41111a409cf74131cd0f651fe65d77eb60d4b45775192ecde9820dc59ac5", [:mix], []}, - "floki": {:hex, :floki, "0.20.4", "be42ac911fece24b4c72f3b5846774b6e61b83fe685c2fc9d62093277fb3bc86", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}, {:mochiweb, "~> 2.15", [hex: :mochiweb, repo: "hexpm", optional: false]}], "hexpm"}, - "gettext": {:hex, :gettext, "0.16.1", "e2130b25eebcbe02bb343b119a07ae2c7e28bd4b146c4a154da2ffb2b3507af2", [:mix], [], "hexpm"}, - "hackney": {:hex, :hackney, "1.14.3", "b5f6f5dcc4f1fba340762738759209e21914516df6be440d85772542d4a5e412", [:rebar3], [{:certifi, "2.4.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, - "hound": {:hex, :hound, "1.0.4", "31db3c013f0ed321b5eb4c573bf3fbc0b74e12fc8da134f9f616527bf0906431", [:mix], [{:hackney, "~> 1.5", [hex: :hackney, repo: "hexpm", optional: false]}, {:poison, ">= 1.4.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, - "html_entities": {:hex, :html_entities, "0.4.0", "f2fee876858cf6aaa9db608820a3209e45a087c5177332799592142b50e89a6b", [:mix], [], "hexpm"}, + "floki": {:hex, :floki, "0.20.4", "be42ac911fece24b4c72f3b5846774b6e61b83fe685c2fc9d62093277fb3bc86", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}, {:mochiweb, "~> 2.15", [hex: :mochiweb, repo: "hexpm", optional: false]}], "hexpm", "2e7e21cd417c4b13523dd8b97379a33e5f432d4d1b149cf5ab496a4a29bdd7ab"}, + "gettext": {:hex, :gettext, "0.16.1", "e2130b25eebcbe02bb343b119a07ae2c7e28bd4b146c4a154da2ffb2b3507af2", [:mix], [], "hexpm", "dd3a7ea5e3e87ee9df29452dd9560709b4c7cc8141537d0b070155038d92bdf1"}, + "hackney": {:hex, :hackney, "1.14.3", "b5f6f5dcc4f1fba340762738759209e21914516df6be440d85772542d4a5e412", [:rebar3], [{:certifi, "2.4.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "ed15491f324aa0e95647dca8ef4340418dac479d1204d57e455d52dcfba3f705"}, + "hound": {:hex, :hound, "1.0.4", "31db3c013f0ed321b5eb4c573bf3fbc0b74e12fc8da134f9f616527bf0906431", [:mix], [{:hackney, "~> 1.5", [hex: :hackney, repo: "hexpm", optional: false]}, {:poison, ">= 1.4.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm", "b833fd951d5b2d145aa7c307b1e8e7469dc393621458e3867e95e84f77835700"}, + "html_entities": {:hex, :html_entities, "0.4.0", "f2fee876858cf6aaa9db608820a3209e45a087c5177332799592142b50e89a6b", [:mix], [], "hexpm", "3e3d7156a272950373ce5a4018b1490bea26676f8d6a7d409f6fac8568b8cb9a"}, "html_sanitize_ex": {:git, "https://github.com/sublimecoder/html_sanitize_ex.git", "30282178751750e88418b23483be79d5d01a8047", []}, "httpoison": {:hex, :httpoison, "0.10.0", "4727b3a5e57e9a4ff168a3c2883e20f1208103a41bccc4754f15a9366f49b676", [:mix], [{:hackney, "~> 1.6.3", [hex: :hackney, optional: false]}]}, - "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, - "inflex": {:hex, :inflex, "1.10.0", "8366a7696e70e1813aca102e61274addf85d99f4a072b2f9c7984054ea1b9d29", [:mix], [], "hexpm"}, - "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, + "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"}, + "inflex": {:hex, :inflex, "1.10.0", "8366a7696e70e1813aca102e61274addf85d99f4a072b2f9c7984054ea1b9d29", [:mix], [], "hexpm", "7b5ccb9b720c26516f5962dc4565fc26f083ca107b0f6c167048506a125d2df3"}, + "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fdf843bca858203ae1de16da2ee206f53416bbda5dc8c9e78f43243de4bc3afe"}, "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm"}, "makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, "makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, - "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, - "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"}, - "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, - "mochiweb": {:hex, :mochiweb, "2.18.0", "eb55f1db3e6e960fac4e6db4e2db9ec3602cc9f30b86cd1481d56545c3145d2e", [:rebar3], [], "hexpm"}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, + "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm", "6cbe761d6a0ca5a31a0931bf4c63204bceb64538e664a8ecf784a9a6f3b875f1"}, + "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm", "7a4c8e1115a2732a67d7624e28cf6c9f30c66711a9e92928e745c255887ba465"}, + "mochiweb": {:hex, :mochiweb, "2.18.0", "eb55f1db3e6e960fac4e6db4e2db9ec3602cc9f30b86cd1481d56545c3145d2e", [:rebar3], [], "hexpm", "b93e2b1e564bdbadfecc297277f9e6d0902da645b417d6c9210f6038ac63489a"}, "mochiweb_html": {:hex, :mochiweb_html, "2.15.0", "d7402e967d7f9f2912f8befa813c37be62d5eeeddbbcb6fe986c44e01460d497", [:rebar3], []}, "nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"}, - "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, - "phoenix": {:hex, :phoenix, "1.4.0", "56fe9a809e0e735f3e3b9b31c1b749d4b436e466d8da627b8d82f90eaae714d2", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"}, - "phoenix_ecto": {:hex, :phoenix_ecto, "4.0.0", "c43117a136e7399ea04ecaac73f8f23ee0ffe3e07acfcb8062fe5f4c9f0f6531", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_html": {:hex, :phoenix_html, "2.13.3", "850e292ff6e204257f5f9c4c54a8cb1f6fbc16ed53d360c2b780a3d0ba333867", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm"}, - "plug": {:hex, :plug, "1.8.2", "0bcce1daa420f189a6491f3940cc77ea7fb1919761175c9c3b59800d897440fc", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm"}, - "plug_cowboy": {:hex, :plug_cowboy, "2.0.0", "ab0c92728f2ba43c544cce85f0f220d8d30fc0c90eaa1e6203683ab039655062", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"}, - "poison": {:hex, :poison, "4.0.1", "bcb755a16fac91cad79bfe9fc3585bb07b9331e50cfe3420a24bcc2d735709ae", [:mix], [], "hexpm"}, + "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, + "phoenix": {:hex, :phoenix, "1.4.0", "56fe9a809e0e735f3e3b9b31c1b749d4b436e466d8da627b8d82f90eaae714d2", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm", "22da8f659cf13d3ba73b767f66b8c389113ddf0ef7b94225cc84e94b85eac90e"}, + "phoenix_ecto": {:hex, :phoenix_ecto, "4.0.0", "c43117a136e7399ea04ecaac73f8f23ee0ffe3e07acfcb8062fe5f4c9f0f6531", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "fe15d9fee5b82f5e64800502011ffe530650d42e1710ae9b14bc4c9be38bf303"}, + "phoenix_html": {:hex, :phoenix_html, "2.13.3", "850e292ff6e204257f5f9c4c54a8cb1f6fbc16ed53d360c2b780a3d0ba333867", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "8b01b3d6d39731ab18aa548d928b5796166d2500755f553725cfe967bafba7d9"}, + "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm", "a3d890aaa3156d51056179dcaaadaf32b844f71656bb27c58756f2b97875c36c"}, + "plug": {:hex, :plug, "1.8.2", "0bcce1daa420f189a6491f3940cc77ea7fb1919761175c9c3b59800d897440fc", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "54c8bbd5062cb32880aa1afc9894a823b1c18a47a1821a552887310b561cd418"}, + "plug_cowboy": {:hex, :plug_cowboy, "2.0.0", "ab0c92728f2ba43c544cce85f0f220d8d30fc0c90eaa1e6203683ab039655062", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "fa9087d93f4962d099b9c4246dbea97c2f2e6aab1029e8b8206e733a1274cecc"}, + "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm", "73c1682f0e414cfb5d9b95c8e8cd6ffcfdae699e3b05e1db744e58b7be857759"}, + "poison": {:hex, :poison, "4.0.1", "bcb755a16fac91cad79bfe9fc3585bb07b9331e50cfe3420a24bcc2d735709ae", [:mix], [], "hexpm", "ba8836feea4b394bb718a161fc59a288fe0109b5006d6bdf97b6badfcf6f0f25"}, "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"}, - "postgrex": {:hex, :postgrex, "0.14.3", "5754dee2fdf6e9e508cbf49ab138df964278700b764177e8f3871e658b345a1e", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, - "ranch": {:hex, :ranch, "1.6.2", "6db93c78f411ee033dbb18ba8234c5574883acb9a75af0fb90a9b82ea46afa00", [:rebar3], [], "hexpm"}, - "scrivener": {:hex, :scrivener, "2.7.0", "fa94cdea21fad0649921d8066b1833d18d296217bfdf4a5389a2f45ee857b773", [:mix], [], "hexpm"}, - "scrivener_ecto": {:hex, :scrivener_ecto, "2.2.0", "53d5f1ba28f35f17891cf526ee102f8f225b7024d1cdaf8984875467158c9c5e", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:scrivener, "~> 2.4", [hex: :scrivener, repo: "hexpm", optional: false]}], "hexpm"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"}, - "xain": {:hex, :xain, "0.6.1", "46af90d3c7055d8c35ac1983040236efdaeed786c99fc61834bc987bbc7e35aa", [:mix], [], "hexpm"}, + "postgrex": {:hex, :postgrex, "0.14.3", "5754dee2fdf6e9e508cbf49ab138df964278700b764177e8f3871e658b345a1e", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "0ec1f09319f29b4dfc2d0e08c776834d219faae0da3536f3d9460f6793e6af1f"}, + "ranch": {:hex, :ranch, "1.6.2", "6db93c78f411ee033dbb18ba8234c5574883acb9a75af0fb90a9b82ea46afa00", [:rebar3], [], "hexpm", "0b65d1de7f1ebe96feb57803c8d698f7776b663ba10b6dcff34527e4a4f8ff43"}, + "scrivener": {:hex, :scrivener, "2.7.0", "fa94cdea21fad0649921d8066b1833d18d296217bfdf4a5389a2f45ee857b773", [:mix], [], "hexpm", "30da36a427f2519cf75993271fb7c5aad1759682a70f90d880a85c3d743d2c57"}, + "scrivener_ecto": {:hex, :scrivener_ecto, "2.2.0", "53d5f1ba28f35f17891cf526ee102f8f225b7024d1cdaf8984875467158c9c5e", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:scrivener, "~> 2.4", [hex: :scrivener, repo: "hexpm", optional: false]}], "hexpm", "3eadfc0a762db4ba8acceee3450404f6ce5e710e52ccf04aae69fca5afe0cd2f"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm", "603561dc0fd62f4f2ea9b890f4e20e1a0d388746d6e20557cafb1b16950de88c"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"}, + "xain": {:hex, :xain, "0.6.2", "c43e3f30dc500ee4ed1146e1d6ec2440652d8e7b076f23dd5599fc251b0d84b2", [:mix], [{:phoenix_html, "~> 2.12", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm", "c67435ac8ca90e242cc44e97be1631f9e920e5c4ca64db60cf97eda441aca58e"}, } diff --git a/test/register_test.exs b/test/register_test.exs index c411ee2f..6b565fdb 100644 --- a/test/register_test.exs +++ b/test/register_test.exs @@ -151,7 +151,7 @@ defmodule TestExAdmin.RegisterTest do {:<<>>, [line: 79], [ "/admin/users/lock/", - {:::, [line: 79], + {:"::", [line: 79], [ {{:., [line: 79], [Kernel, :to_string]}, [line: 79], [ diff --git a/test/themes/filter_test.exs b/test/themes/filter_test.exs index acb646d0..f4b8f264 100644 --- a/test/themes/filter_test.exs +++ b/test/themes/filter_test.exs @@ -47,8 +47,7 @@ defmodule ExAdmin.ThemeFilterTest do test "AdminLte2 build_field datetime" do defn = %TestExAdmin.ExAdmin.Simple{index_filters: []} - html = - AdminLte2.Filter.build_field({:inserted_at, DateTime}, nil, defn) |> get_clean_html() + html = AdminLte2.Filter.build_field({:inserted_at, DateTime}, nil, defn) |> get_clean_html() assert Floki.find(html, "label.label") |> Floki.text() == "Inserted At" end @@ -62,8 +61,7 @@ defmodule ExAdmin.ThemeFilterTest do test "AdminLte2 build_field datetime with label option" do defn = %TestExAdmin.ExAdmin.Simple{index_filters: [inserted_at: [label: "Created On"]]} - html = - AdminLte2.Filter.build_field({:inserted_at, DateTime}, nil, defn) |> get_clean_html() + html = AdminLte2.Filter.build_field({:inserted_at, DateTime}, nil, defn) |> get_clean_html() assert Floki.find(html, "label.label") |> Floki.text() == "Created On" end @@ -142,8 +140,7 @@ defmodule ExAdmin.ThemeFilterTest do test "ActiveAdmin build_field datetime" do defn = %TestExAdmin.ExAdmin.Simple{index_filters: []} - html = - ActiveAdmin.Filter.build_field({:inserted_at, DateTime}, nil, defn) |> get_clean_html() + html = ActiveAdmin.Filter.build_field({:inserted_at, DateTime}, nil, defn) |> get_clean_html() assert Floki.find(html, "label.label") |> Floki.text() == "Inserted At" end @@ -157,8 +154,7 @@ defmodule ExAdmin.ThemeFilterTest do test "ActiveAdmin build_field datetime with label option" do defn = %TestExAdmin.ExAdmin.Simple{index_filters: [inserted_at: [label: "Created On"]]} - html = - ActiveAdmin.Filter.build_field({:inserted_at, DateTime}, nil, defn) |> get_clean_html() + html = ActiveAdmin.Filter.build_field({:inserted_at, DateTime}, nil, defn) |> get_clean_html() assert Floki.find(html, "label.label") |> Floki.text() == "Created On" end diff --git a/web/ex_admin/errors_helper.ex b/web/ex_admin/errors_helper.ex index f77fe916..288909c2 100644 --- a/web/ex_admin/errors_helper.ex +++ b/web/ex_admin/errors_helper.ex @@ -26,65 +26,83 @@ defmodule ExAdmin.ErrorsHelper do """ def create_errors(changeset, schema) do assoc_prefixes = create_prefix_map(schema) + flatten_errors(changeset, assoc_prefixes) - |> List.flatten - |> Enum.filter(fn(x) -> x != nil end) + |> List.flatten() + |> Enum.filter(fn x -> x != nil end) end defp flatten_errors(errors_array, assoc_prefixes, prefix \\ nil) - defp flatten_errors(%Ecto.Changeset{changes: changes, errors: errors}, assoc_prefixes, prefix) when errors == [] or is_nil(prefix) do - changes = Enum.reject(changes, fn({_,v}) -> is_struct(v) end) - |> Enum.into(%{}) + + defp flatten_errors(%Ecto.Changeset{changes: changes, errors: errors}, assoc_prefixes, prefix) + when errors == [] or is_nil(prefix) do + changes = + Enum.reject(changes, fn {_, v} -> is_struct(v) end) + |> Enum.into(%{}) + errors ++ flatten_errors(changes, assoc_prefixes, prefix) end - defp flatten_errors(%Ecto.Changeset{changes: changes, errors: errors}, assoc_prefixes, prefix) do - Enum.map(errors, fn({k, v}) -> {concat_atoms(prefix, k), v} end) ++ + defp flatten_errors(%Ecto.Changeset{changes: changes, errors: errors}, assoc_prefixes, prefix) do + Enum.map(errors, fn {k, v} -> {concat_atoms(prefix, k), v} end) ++ flatten_errors(changes, assoc_prefixes, prefix) end defp flatten_errors(errors_array, assoc_prefixes, prefix) when is_list(errors_array) do Enum.with_index(errors_array) - |> Enum.map(fn({x, i}) -> - prefix = concat_atoms(prefix, String.to_atom(Integer.to_string(i))) - flatten_errors(x, assoc_prefixes, prefix) + |> Enum.map(fn {x, i} -> + prefix = concat_atoms(prefix, String.to_atom(Integer.to_string(i))) + flatten_errors(x, assoc_prefixes, prefix) end) end defp flatten_errors(%{__struct__: _struct}, _, _), do: nil defp flatten_errors(%{} = errors_map, assoc_prefixes, prefix) do - Enum.map(errors_map, fn({k, x}) -> + Enum.map(errors_map, fn {k, x} -> with k <- if(not is_atom(k), do: String.to_atom(k), else: k), - k <- if(Keyword.has_key?(assoc_prefixes, k), do: concat_atoms(k, assoc_prefixes[k]), else: k), - k <- if(prefix != nil, do: concat_atoms(prefix, k), else: k), - do: flatten_errors(x, assoc_prefixes, k) + k <- + if(Keyword.has_key?(assoc_prefixes, k), + do: concat_atoms(k, assoc_prefixes[k]), + else: k + ), + k <- if(prefix != nil, do: concat_atoms(prefix, k), else: k), + do: flatten_errors(x, assoc_prefixes, k) end) end defp flatten_errors(_, _, _), do: nil defp concat_atoms(first, second) do - "#{first}_#{second}" |> String.to_atom + "#{first}_#{second}" |> String.to_atom() end defp create_prefix_map(schema) do schema.__schema__(:associations) - |> Enum.map(&(schema.__schema__(:association, &1))) - |> Enum.map(fn(a) -> + |> Enum.map(&schema.__schema__(:association, &1)) + |> Enum.map(fn a -> case a do %Ecto.Association.HasThrough{field: field} -> - { field, :attributes } + {field, :attributes} + %Ecto.Association.Has{field: field} -> - { field, :attributes } + {field, :attributes} + %Ecto.Association.ManyToMany{field: field} -> - { field, :attributes } + {field, :attributes} + _ -> nil end end) end - defp is_struct(%{__struct__: _}), do: true - defp is_struct(_), do: false + case Version.compare(System.version(), "1.10.0") do + :lt -> + defp is_struct(%{__struct__: _}), do: true + defp is_struct(_), do: false + + _ -> + :ok + end end diff --git a/web/templates/layout/active_admin.html.eex b/web/templates/layout/active_admin.html.eex index fbbb28a1..d03da1ad 100644 --- a/web/templates/layout/active_admin.html.eex +++ b/web/templates/layout/active_admin.html.eex @@ -10,10 +10,10 @@ <%= favicon() %> <%= site_title() %> - "> + "> - + <%= case Application.get_env(:ex_admin, :head_template) do {layout, template} -> @@ -55,7 +55,7 @@ - + + @@ -69,8 +69,8 @@ $.widget.bridge('uibutton', $.ui.button); - - + +