Add importing html and save it to Article

Additionally defines a wizard logic which is partially unused yet.
This commit is contained in:
Thelonius Kort
2022-12-29 16:43:52 +01:00
parent 60a22d011e
commit b7bd9195b6
24 changed files with 452 additions and 25 deletions

View File

@ -3,6 +3,7 @@ defmodule OutlookWeb.ArticleLive.New do
import OutlookWeb.ArticleLive.NewComponents
alias OutlookWeb.ArticleLive.FormComponent
alias Outlook.{Articles,Authors,HtmlPreparations}
alias Articles.{Article,RawHtmlInput}
@ -13,7 +14,6 @@ defmodule OutlookWeb.ArticleLive.New do
{:ok,
socket
|> assign(:page_title, "New Article")
|> assign(:article, %Article{})
|> assign(:raw_html_input, %RawHtmlInput{})
|> assign(:changeset, Articles.change_raw_html_input(%RawHtmlInput{}))
|> assign(:selected_els, [])
@ -23,9 +23,11 @@ defmodule OutlookWeb.ArticleLive.New do
@impl true
def handle_params(%{"author_id" => author_id}, _, socket) do
author = Authors.get_author!(author_id)
article = %Article{author_id: author.id}
{:noreply,
socket
|> assign(:author, author)}
|> assign(:author, author)
|> assign(:article, article)}
end
@impl true
@ -40,13 +42,24 @@ defmodule OutlookWeb.ArticleLive.New do
true ->
{:noreply,
socket
|> assign(:raw_internal_tree, HtmlPreparations.convert_raw_html_input(raw_html_input_params["content"]))
|> assign(:raw_internal_tree,
HtmlPreparations.convert_raw_html_input(raw_html_input_params["content"]))
|> assign(:step, :review_raw_internaltree)}
false ->
{:noreply, assign(socket, :changeset, changeset)}
end
end
@impl true
def handle_event("approve_raw_internaltree", _, socket) do
{:noreply, socket |> assign(:step, :review_translation_units)}
end
@impl true
def handle_event("approve_translation_units", _, socket) do
{:noreply, socket |> assign(:step, :final_form)}
end
defp validate_raw_html_input(raw_html_input_params, socket) do
socket.assigns.raw_html_input
|> Articles.change_raw_html_input(raw_html_input_params)