Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Ecto 3, hardened HTML handling #462

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
15 changes: 6 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ before_script:
- nohup phantomjs --wd &
language: elixir
elixir:
- 1.4
- 1.3
- "1.7"
- "1.8"
- "1.9"
otp_release:
- 20.0
- 19.3
- 18.3
matrix:
exclude:
- elixir: 1.3
otp_release: 20.0
- "20.3"
- "21.3"
- "22.1"
sudo: false
script: mix test --include integration:true
notification:
Expand Down
3 changes: 1 addition & 2 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ use Mix.Config
# Nested.ExAdmin.Dashboard,
# ]
config :ex_admin,
repo: MyProject.Repo,
module: MyProject,
repo: ExAdmin.Repo,
modules: [],
module: ExAdmin

Expand Down
19 changes: 10 additions & 9 deletions lib/ex_admin.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ defmodule ExAdmin do
## Other Types

To support other Ecto Types, implement the ExAdmin.Render protocol for the
desired type. Here is an example from the ExAdmin code for the `Ecto.Date` type:
desired type. Here is an example from the ExAdmin code for the `Date` type:

defimpl ExAdmin.Render, for: Ecto.Date do
defimpl ExAdmin.Render, for: Date do
def to_string(dt) do
Ecto.Date.to_string dt
Date.to_string dt
end
end

Expand Down Expand Up @@ -386,12 +386,13 @@ defmodule ExAdmin do
end

defp action_link(conn, name, :delete, _id) do
{name, [
href: admin_resource_path(conn, :destroy),
"data-confirm": Utils.confirm_message(),
"data-method": :delete,
rel: :nofollow
]}
{name,
[
href: admin_resource_path(conn, :destroy),
"data-confirm": Utils.confirm_message(),
"data-method": :delete,
rel: :nofollow
]}
end

defp action_link(conn, name, action, _id) do
Expand Down
18 changes: 8 additions & 10 deletions lib/ex_admin/ecto_form_mappers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ defmodule ExAdmin.EctoFormMappers do

defp filter_checkboxes(params) do
# convert to array of id's
Enum.filter_map(
params,
fn x ->
elem(x, 1) == "on"
end,
fn
{item, _} when is_atom(item) -> Atom.to_string(item)
{item, _} -> item
end
)
params
|> Enum.filter(fn x ->
elem(x, 1) == "on"
end)
|> Enum.map(fn
{item, _} when is_atom(item) -> Atom.to_string(item)
{item, _} -> item
end)
end
end
Loading