diff --git a/lib/outlook/translations/translation.ex b/lib/outlook/translations/translation.ex index 2b35889..e735a08 100644 --- a/lib/outlook/translations/translation.ex +++ b/lib/outlook/translations/translation.ex @@ -15,6 +15,7 @@ defmodule Outlook.Translations.Translation do field :public_content, :string field :title, :string field :unauthorized, :boolean, default: false + field :remarks, :string belongs_to :user, User belongs_to :article, Article @@ -24,7 +25,7 @@ defmodule Outlook.Translations.Translation do @doc false def changeset(translation, attrs) do translation - |> cast(attrs, [:language, :title, :teaser, :date, :public, :unauthorized, :article_id, :public_content]) + |> cast(attrs, [:language, :title, :teaser, :date, :public, :unauthorized, :article_id, :public_content, :remarks]) |> cast(attrs, [:content]) |> validate_required([:language, :title, :content, :date, :public, :unauthorized, :article_id]) |> unique_constraint([:language, :article_id], diff --git a/lib/outlook_web/live/translation_live/form_component.ex b/lib/outlook_web/live/translation_live/form_component.ex index 9ff8f0d..45c347a 100644 --- a/lib/outlook_web/live/translation_live/form_component.ex +++ b/lib/outlook_web/live/translation_live/form_component.ex @@ -32,6 +32,7 @@ defmodule OutlookWeb.TranslationLive.FormComponent do <.input field={{f, :public}} type="checkbox" label="public" /> <.input field={{f, :unauthorized}} type="checkbox" label="unauthorized" /> + <.input field={{f, :remarks}} type="textarea" label="remarks" class="h-28" /> <:actions> diff --git a/lib/outlook_web/live/translation_live/show.html.heex b/lib/outlook_web/live/translation_live/show.html.heex index 9818d43..7983e77 100644 --- a/lib/outlook_web/live/translation_live/show.html.heex +++ b/lib/outlook_web/live/translation_live/show.html.heex @@ -11,11 +11,12 @@ <.list> <:item title="Language"><%= @translation.language %> <:item title="Title"><%= @translation.title %> - <:item title="Teaser"><%= @translation.teaser %> + <:item title="Teaser"><%= @translation.teaser |> tidy_raw %> <%!-- <:item title="Content"><%= @translation.content %> --%> <:item title="Date"><%= @translation.date %> <:item title="Public"><%= @translation.public %> <:item title="Unauthorized"><%= @translation.unauthorized %> + <:item title="Remarks"><%= @translation.remarks |> tidy_raw %>
diff --git a/priv/repo/migrations/20230504144912_add_remarks_to_translations.exs b/priv/repo/migrations/20230504144912_add_remarks_to_translations.exs new file mode 100644 index 0000000..37c46fb --- /dev/null +++ b/priv/repo/migrations/20230504144912_add_remarks_to_translations.exs @@ -0,0 +1,9 @@ +defmodule Outlook.Repo.Migrations.AddRemarksToTranslations do + use Ecto.Migration + + def change do + alter table(:translations) do + add :remarks, :text + end + end +end