improve note form, fix missing tags & refs when creating note
This commit is contained in:
parent
250091d25f
commit
e25499eac6
5 changed files with 13 additions and 12 deletions
|
@ -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 """
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,14 +7,10 @@
|
|||
</:actions>
|
||||
</.header>
|
||||
|
||||
|
||||
|
||||
<.note_form
|
||||
changeset={@changeset}
|
||||
action={~p"/admin/notes/#{@note}"}
|
||||
channels={@channels}
|
||||
selected_channels={@selected_channels}
|
||||
tags={@tags}
|
||||
/>
|
||||
|
||||
<.back navigate={~p"/admin/notes/#{@note.id}"}>Back to note</.back>
|
||||
/>
|
|
@ -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
|
||||
|
@ -9,6 +14,4 @@
|
|||
channels={@channels}
|
||||
tags={@tags}
|
||||
selected_channels={@selected_channels}
|
||||
/>
|
||||
|
||||
<.back navigate={~p"/admin/notes"}>Back to notes</.back>
|
||||
/>
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue