diff --git a/lib/music_library/notes/note.ex b/lib/music_library/notes/note.ex index 7028b29e..45e96dd1 100644 --- a/lib/music_library/notes/note.ex +++ b/lib/music_library/notes/note.ex @@ -6,7 +6,7 @@ defmodule MusicLibrary.Notes.Note do @primary_key {:id, :binary_id, autogenerate: true} schema "notes" do field :entity, Ecto.Enum, values: [:record, :artist] - field :content, :string + field :content, :string, default: "" field :musicbrainz_id, Ecto.UUID timestamps(type: :utc_datetime) @@ -19,6 +19,6 @@ defmodule MusicLibrary.Notes.Note do :content, :musicbrainz_id ]) - |> validate_required([:entity, :content, :musicbrainz_id]) + |> validate_required([:entity, :musicbrainz_id]) end end diff --git a/lib/music_library_web/components/notes_component.ex b/lib/music_library_web/components/notes_component.ex index 510a405f..1ee636a0 100644 --- a/lib/music_library_web/components/notes_component.ex +++ b/lib/music_library_web/components/notes_component.ex @@ -25,7 +25,7 @@ defmodule MusicLibraryWeb.NotesComponent do defp find_or_initialize_note(%{entity: entity, musicbrainz_id: musicbrainz_id}) do case Notes.get_note(entity, musicbrainz_id) do nil -> - %Note{entity: entity, musicbrainz_id: musicbrainz_id, content: ""} + %Note{entity: entity, musicbrainz_id: musicbrainz_id} note -> note @@ -52,7 +52,7 @@ defmodule MusicLibraryWeb.NotesComponent do <.tabs_panel active={@mode == "read"} name="read">
- {render_notes(@form[:content].value)} + {render_content(@form[:content].value)}
<.tabs_panel active={@mode == "edit"} name="edit"> @@ -156,8 +156,8 @@ defmodule MusicLibraryWeb.NotesComponent do end end - defp render_notes(notes) do - (notes || "") + defp render_content(content) do + content |> Markdown.to_html() |> raw() end