Add remarks to articles
This commit is contained in:
@ -12,6 +12,7 @@ defmodule Outlook.Articles.Article do
|
|||||||
field :language, :string, default: "EN"
|
field :language, :string, default: "EN"
|
||||||
field :title, :string
|
field :title, :string
|
||||||
field :url, :string
|
field :url, :string
|
||||||
|
field :remarks, :string
|
||||||
belongs_to :author, Author
|
belongs_to :author, Author
|
||||||
has_many :translations, Translation, on_delete: :delete_all
|
has_many :translations, Translation, on_delete: :delete_all
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ defmodule Outlook.Articles.Article do
|
|||||||
@doc false
|
@doc false
|
||||||
def changeset(article, attrs) do
|
def changeset(article, attrs) do
|
||||||
article
|
article
|
||||||
|> cast(attrs, [:title, :content, :url, :language, :date, :author_id])
|
|> cast(attrs, [:title, :content, :url, :language, :date, :author_id, :remarks])
|
||||||
|> validate_required([:title, :content, :url, :language, :date, :author_id])
|
|> validate_required([:title, :content, :url, :language, :date, :author_id])
|
||||||
|> foreign_key_constraint(:author_id)
|
|> foreign_key_constraint(:author_id)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -26,6 +26,7 @@ defmodule OutlookWeb.ArticleLive.FormComponent do
|
|||||||
<.input field={{f, :language}} type="select" label="language"
|
<.input field={{f, :language}} type="select" label="language"
|
||||||
options={Application.get_env(:outlook,:deepl)[:source_langs]} />
|
options={Application.get_env(:outlook,:deepl)[:source_langs]} />
|
||||||
<.input field={{f, :date}} type="datetime-local" label="date" />
|
<.input field={{f, :date}} type="datetime-local" label="date" />
|
||||||
|
<.input field={{f, :remarks}} type="textarea" label="remarks" class="h-28" />
|
||||||
<:actions>
|
<:actions>
|
||||||
<.button phx-disable-with="Saving...">Save Article</.button>
|
<.button phx-disable-with="Saving...">Save Article</.button>
|
||||||
</:actions>
|
</:actions>
|
||||||
|
|||||||
@ -40,6 +40,10 @@
|
|||||||
<a href="#" class="hide-link" phx-click={JS.remove_class("show-boundary", to: ".article")}>hide boundaries</a>
|
<a href="#" class="hide-link" phx-click={JS.remove_class("show-boundary", to: ".article")}>hide boundaries</a>
|
||||||
<.render_doc tree={@article_content} />
|
<.render_doc tree={@article_content} />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="my-4">
|
||||||
|
<div>Remarks:</div>
|
||||||
|
<%= @article.remarks |> tidy_raw %>
|
||||||
|
</div>
|
||||||
<div class="h-10" />
|
<div class="h-10" />
|
||||||
|
|
||||||
<.link class="text-sm font-semibold" navigate={~p"/translations/new?article_id=#{@article.id}"}>New Translation</.link>
|
<.link class="text-sm font-semibold" navigate={~p"/translations/new?article_id=#{@article.id}"}>New Translation</.link>
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
defmodule Outlook.Repo.Migrations.AddRemarksToArticles do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
alter table(:articles) do
|
||||||
|
add :remarks, :text
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user