Merge pull request 'devel' (#58) from devel into main

Reviewed-on: #58
This commit is contained in:
inhji 2023-04-10 19:23:06 +02:00
commit d42f53e271
7 changed files with 17 additions and 15 deletions

View file

@ -31,7 +31,7 @@ defmodule Chiya.Notes.Note do
join_through: Chiya.Notes.NoteNote,
join_keys: [source_id: :id, target_id: :id]
many_to_many :tags, Chiya.Tags.Tag,
many_to_many :tags, Chiya.Tags.Tag,
join_through: Chiya.Notes.NoteTag,
join_keys: [note_id: :id, tag_id: :id]

View file

@ -128,7 +128,6 @@ defmodule Chiya.Notes.References do
else
Logger.debug("Note '#{slug}' does not exist anymore.")
end
end)
end

View file

@ -67,7 +67,7 @@ defmodule Chiya.Tags.TagUpdater do
Logger.debug("Looking up tag [#{tag}] with slug [#{slug}]")
{:ok, tag} =
case Tags.get_tag(slug) do
case Tags.get_tag_by_slug(slug) do
nil ->
Logger.debug("Tag [#{tag}] does not exist. Creating.")
Tags.create_tag(%{name: tag})
@ -96,7 +96,7 @@ defmodule Chiya.Tags.TagUpdater do
defp remove_tag(schema, tag) do
slug = Slugger.slugify_downcase(tag)
if tag = Tags.get_tag(slug) do
if tag = Tags.get_tag_by_slug(slug) do
case schema do
%Note{} ->
attrs = %{tag_id: tag.id, note_id: schema.id}

View file

@ -75,11 +75,12 @@ defmodule ChiyaWeb.NoteController do
|> redirect(to: ~p"/admin/notes/#{note}")
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, :edit,
note: note,
changeset: changeset,
channels: to_channel_options(),
tags: note.tags)
render(conn, :edit,
note: note,
changeset: changeset,
channels: to_channel_options(),
tags: note.tags
)
end
end

View file

@ -13,9 +13,7 @@ defmodule ChiyaWeb.NoteHTML do
def note_form(assigns)
def selected_channels(changeset), do:
Enum.map(changeset.data.channels, fn c -> c.id end)
def selected_channels(changeset), do: Enum.map(changeset.data.channels, fn c -> c.id end)
def tags_to_string(tags), do:
Enum.map_join(tags, ", ", fn t -> t.name end)
def tags_to_string(tags), do: Enum.map_join(tags, ", ", fn t -> t.name end)
end

View file

@ -3,6 +3,11 @@
<:subtitle>Use this form to manage note records in your database.</:subtitle>
</.header>
<.note_form changeset={@changeset} action={~p"/admin/notes/#{@note}"} channels={@channels} tags={@tags} />
<.note_form
changeset={@changeset}
action={~p"/admin/notes/#{@note}"}
channels={@channels}
tags={@tags}
/>
<.back navigate={~p"/admin/notes"}>Back to notes</.back>

View file

@ -28,4 +28,3 @@
<.button>Save Note</.button>
</:actions>
</.simple_form>