+ Delete image +
@@ -50,6 +50,7 @@ defmodule ChiyaWeb.NoteShowLive dodiff --git a/lib/chiya/notes.ex b/lib/chiya/notes.ex index 5fd7cb4..1119b45 100644 --- a/lib/chiya/notes.ex +++ b/lib/chiya/notes.ex @@ -131,7 +131,12 @@ defmodule Chiya.Notes do end @doc """ - Creates a note image and attaches it to a note + Gets a single note image. + """ + def get_note_image!(id), do: Repo.get!(NoteImage, id) + + @doc """ + Creates a note image and attaches it to a note. """ def create_note_image(attrs) do case %NoteImage{} @@ -147,6 +152,12 @@ defmodule Chiya.Notes do end end + def delete_note_image(%NoteImage{} = note_image) do + {:ok, _} = Repo.delete(note_image) + :ok = Chiya.Uploaders.NoteImage.delete({note_image.path, note_image}) + :ok + end + @doc """ Returns an `%Ecto.Changeset{}` for tracking note_image changes. """ diff --git a/lib/chiya_web/live/note_show_live.ex b/lib/chiya_web/live/note_show_live.ex index 1aa044d..73af776 100644 --- a/lib/chiya_web/live/note_show_live.ex +++ b/lib/chiya_web/live/note_show_live.ex @@ -5,6 +5,8 @@ defmodule ChiyaWeb.NoteShowLive do @impl true def render(assigns) do + channels = Enum.map_join(assigns.note.channels, ", ", fn c -> c.name end) + ~H""" <.header> Note <%= @note.id %> @@ -23,16 +25,12 @@ defmodule ChiyaWeb.NoteShowLive do <:item title="Published at"><%= @note.published_at %> <:item title="Kind"><%= @note.kind %> <:item title="Url"><%= @note.url %> + <:item title="Channels"><%= channels %> -
+ Delete image +
@@ -50,6 +50,7 @@ defmodule ChiyaWeb.NoteShowLive do