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{}
|
||||||
|> Note.changeset(attrs)
|
|> Note.changeset(attrs)
|
||||||
|> Repo.insert()
|
|> Repo.insert()
|
||||||
|
|> Chiya.Tags.TagUpdater.update_tags(attrs)
|
||||||
|
|> Chiya.Notes.References.update_references(attrs)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
|
@ -9,7 +9,9 @@ defmodule Chiya.Tags.TagUpdater do
|
||||||
alias Chiya.Notes.Note
|
alias Chiya.Notes.Note
|
||||||
|
|
||||||
def update_tags({:ok, %Note{} = note}, attrs) do
|
def update_tags({:ok, %Note{} = note}, attrs) do
|
||||||
update_tags(note, attrs)
|
note
|
||||||
|
|> Notes.preload_note()
|
||||||
|
|> update_tags(attrs)
|
||||||
|
|
||||||
{:ok, note}
|
{:ok, note}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<.header>
|
<.header>
|
||||||
<%= @note.name %>
|
Edit Note “<%= @note.name %>”
|
||||||
<:actions>
|
<:actions>
|
||||||
<.link href={~p"/admin/notes/#{@note.id}"}>
|
<.link href={~p"/admin/notes/#{@note.id}"}>
|
||||||
<.button><.icon name="hero-arrow-left" /> Back to Note</.button>
|
<.button><.icon name="hero-arrow-left" /> Back to Note</.button>
|
||||||
|
@ -7,8 +7,6 @@
|
||||||
</:actions>
|
</:actions>
|
||||||
</.header>
|
</.header>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<.note_form
|
<.note_form
|
||||||
changeset={@changeset}
|
changeset={@changeset}
|
||||||
action={~p"/admin/notes/#{@note}"}
|
action={~p"/admin/notes/#{@note}"}
|
||||||
|
@ -16,5 +14,3 @@
|
||||||
selected_channels={@selected_channels}
|
selected_channels={@selected_channels}
|
||||||
tags={@tags}
|
tags={@tags}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<.back navigate={~p"/admin/notes/#{@note.id}"}>Back to note</.back>
|
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
<.header>
|
<.header>
|
||||||
New Note
|
New Note
|
||||||
<:subtitle>Use this form to manage note records in your database.</:subtitle>
|
<: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>
|
</.header>
|
||||||
|
|
||||||
<.note_form
|
<.note_form
|
||||||
|
@ -10,5 +15,3 @@
|
||||||
tags={@tags}
|
tags={@tags}
|
||||||
selected_channels={@selected_channels}
|
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>
|
<.button phx-disable-with="Changing...">Add Images</.button>
|
||||||
</:actions>
|
</:actions>
|
||||||
</.simple_form>
|
</.simple_form>
|
||||||
|
|
||||||
<.back navigate={~p"/admin/notes"}>Back to notes</.back>
|
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue