improve note form, fix missing tags & refs when creating note

This commit is contained in:
Inhji 2023-07-20 20:39:32 +02:00
parent 250091d25f
commit e25499eac6
5 changed files with 13 additions and 12 deletions

View file

@ -202,6 +202,8 @@ defmodule Chiya.Notes do
%Note{}
|> Note.changeset(attrs)
|> Repo.insert()
|> Chiya.Tags.TagUpdater.update_tags(attrs)
|> Chiya.Notes.References.update_references(attrs)
end
@doc """

View file

@ -9,7 +9,9 @@ defmodule Chiya.Tags.TagUpdater do
alias Chiya.Notes.Note
def update_tags({:ok, %Note{} = note}, attrs) do
update_tags(note, attrs)
note
|> Notes.preload_note()
|> update_tags(attrs)
{:ok, note}
end

View file

@ -1,5 +1,5 @@
<.header>
<%= @note.name %>
Edit Note “<%= @note.name %>
<:actions>
<.link href={~p"/admin/notes/#{@note.id}"}>
<.button><.icon name="hero-arrow-left" /> Back to Note</.button>
@ -7,8 +7,6 @@
</:actions>
</.header>
<.note_form
changeset={@changeset}
action={~p"/admin/notes/#{@note}"}
@ -16,5 +14,3 @@
selected_channels={@selected_channels}
tags={@tags}
/>
<.back navigate={~p"/admin/notes/#{@note.id}"}>Back to note</.back>

View file

@ -1,6 +1,11 @@
<.header>
New Note
<:subtitle>Use this form to manage note records in your database.</:subtitle>
<:actions>
<.link href={~p"/admin/notes"}>
<.button><.icon name="hero-arrow-left" /> Back to Notes</.button>
</.link>
</:actions>
</.header>
<.note_form
@ -10,5 +15,3 @@
tags={@tags}
selected_channels={@selected_channels}
/>
<.back navigate={~p"/admin/notes"}>Back to notes</.back>

View file

@ -102,8 +102,6 @@ defmodule ChiyaWeb.NoteShowLive do
<.button phx-disable-with="Changing...">Add Images</.button>
</:actions>
</.simple_form>
<.back navigate={~p"/admin/notes"}>Back to notes</.back>
"""
end