Update add_phx_click_event making :target option optional

This commit is contained in:
Thelonius Kort
2023-05-02 21:59:27 +02:00
parent 7e085f5202
commit 4a8f1c3c80

View File

@ -26,9 +26,12 @@ defmodule Outlook.InternalTree do
def add_phx_click_event(tree, opts) do def add_phx_click_event(tree, opts) do
phx_opts = %{ phx_opts = %{
"phx-click": Keyword.get(opts, :click), "phx-click": Keyword.get(opts, :click),
"phx-target": Keyword.get(opts, :target) |> to_string,
"phx-value-nid": fn n -> n.nid end "phx-value-nid": fn n -> n.nid end
} }
phx_opts = case Keyword.has_key?(opts, :target) do
true -> Map.put(phx_opts, "phx-target", Keyword.get(opts, :target) |> to_string)
false -> phx_opts
end
options = Map.put(%{}, Keyword.get(opts, :nodes, :elements), phx_opts) options = Map.put(%{}, Keyword.get(opts, :nodes, :elements), phx_opts)
garnish(tree, options) garnish(tree, options)
end end
@ -74,4 +77,8 @@ defmodule Outlook.InternalTree do
def modify_tunits(tree, modifier, tu_ids) do def modify_tunits(tree, modifier, tu_ids) do
TunitModifications.apply_modifier(tree, modifier, tu_ids) TunitModifications.apply_modifier(tree, modifier, tu_ids)
end end
def tunit_modifiers() do
TunitModifications.modifiers()
end
end end