Fix issue with "Save and edit"
This commit is contained in:
@ -24,7 +24,7 @@ defmodule OutlookWeb.TranslationLive.NewEdit do
|
||||
end
|
||||
|
||||
@impl true
|
||||
def mount(%{"article_id" => article_id} = _params, _session, socket) when socket.assigns.live_action == :new do
|
||||
def handle_params(%{"article_id" => article_id} = _params, _session, socket) when socket.assigns.live_action == :new do
|
||||
socket = socket
|
||||
|> assign_new(:translation, fn ->
|
||||
%Translation{
|
||||
@ -33,15 +33,15 @@ defmodule OutlookWeb.TranslationLive.NewEdit do
|
||||
}
|
||||
end)
|
||||
|> common_assigns()
|
||||
{:ok, assign_new(socket, :translation_content, fn ->
|
||||
{:noreply, assign_new(socket, :translation_content, fn ->
|
||||
Basic.internal_tree_to_tunit_map(socket.assigns.translation.article.content) end)}
|
||||
end
|
||||
|
||||
def mount(%{"id" => id} = _params, _session, socket) when socket.assigns.live_action == :edit do
|
||||
def handle_params(%{"id" => id} = _params, _session, socket) when socket.assigns.live_action == :edit do
|
||||
socket = socket
|
||||
|> assign_new(:translation, fn -> Translations.get_translation!(id) end)
|
||||
|> common_assigns()
|
||||
{:ok, assign_new(socket, :translation_content, fn -> socket.assigns.translation.content end)}
|
||||
|> assign(:translation, Translations.get_translation!(id))
|
||||
|> common_assigns()
|
||||
{:noreply, assign(socket, :translation_content, socket.assigns.translation.content)}
|
||||
end
|
||||
|
||||
defp get_article(article_id) do
|
||||
|
||||
Reference in New Issue
Block a user