Add importing html and save it to Article
Additionally defines a wizard logic which is partially unused yet.
This commit is contained in:
29
lib/outlook/internal_tree/raw_internal_tree_schema.ex
Normal file
29
lib/outlook/internal_tree/raw_internal_tree_schema.ex
Normal file
@ -0,0 +1,29 @@
|
||||
defmodule Outlook.Articles.RawInternalTreeSchema do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Outlook.Articles.RawInternalTree
|
||||
|
||||
embedded_schema do
|
||||
field :tree, RawInternalTree
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(raw_tree, attrs) do
|
||||
raw_tree
|
||||
|> check_sibling_collocation(:tree)
|
||||
end
|
||||
|
||||
def check_sibling_collocation(changeset, field) when is_atom(field) do
|
||||
validate_change(changeset, field, fn field, value ->
|
||||
case value do
|
||||
true ->
|
||||
[]
|
||||
|
||||
false ->
|
||||
[{field, "html should be useful"}]
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user