Refactor translation form_component
This commit is contained in:
@ -2,7 +2,7 @@ defmodule OutlookWeb.TranslationLive.FormComponent do
|
|||||||
use OutlookWeb, :live_component
|
use OutlookWeb, :live_component
|
||||||
|
|
||||||
alias Outlook.{Translations,InternalTree}
|
alias Outlook.{Translations,InternalTree}
|
||||||
alias Outlook.InternalTree.TranslationUnit
|
alias Outlook.InternalTree.{TranslationUnit,Html}
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
@ -195,10 +195,8 @@ defmodule OutlookWeb.TranslationLive.FormComponent do
|
|||||||
defp publish(translation_params, %{"publish" => "true"}, socket) do
|
defp publish(translation_params, %{"publish" => "true"}, socket) do
|
||||||
translation_params
|
translation_params
|
||||||
|> Map.put("public_content",
|
|> Map.put("public_content",
|
||||||
OutlookWeb.HtmlDocComponent.render_doc(%{tree: InternalTree.render_translation(socket.assigns.translation.article.content,
|
InternalTree.render_translation(socket.assigns.translation.article.content, translation_params["content"])
|
||||||
translation_params["content"]), tunit_tag: "span"})
|
|> Html.render_doc())
|
||||||
|> Phoenix.HTML.Safe.to_iodata()
|
|
||||||
|> IO.iodata_to_binary())
|
|
||||||
end
|
end
|
||||||
defp publish(translation_params, %{"publish" => "false"}, _) do
|
defp publish(translation_params, %{"publish" => "false"}, _) do
|
||||||
translation_params
|
translation_params
|
||||||
|
|||||||
Reference in New Issue
Block a user