Add creating and basic editing of translation
This commit is contained in:
28
lib/outlook_web/live/translation_live/edit.ex
Normal file
28
lib/outlook_web/live/translation_live/edit.ex
Normal file
@ -0,0 +1,28 @@
|
||||
defmodule OutlookWeb.TranslationLive.Edit do
|
||||
use OutlookWeb, :live_view
|
||||
|
||||
alias Outlook.Articles
|
||||
alias Outlook.Translations
|
||||
|
||||
@impl true
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<.live_component
|
||||
module={OutlookWeb.TranslationLive.FormComponent}
|
||||
id={:new}
|
||||
title="New Translation"
|
||||
action={@live_action}
|
||||
translation={@translation}
|
||||
translation_content={@translation_content}
|
||||
navigate={~p"/translations"}
|
||||
/>
|
||||
"""
|
||||
end
|
||||
|
||||
@impl true
|
||||
def mount(%{"id" => id} = _params, _session, socket) do
|
||||
socket = socket
|
||||
|> assign_new(:translation, fn -> Translations.get_translation!(id) end)
|
||||
{:ok, assign_new(socket, :translation_content, fn -> socket.assigns.translation.content end)}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user