devel #167
1 changed files with 8 additions and 4 deletions
|
@ -30,14 +30,18 @@ defmodule ChiyaWeb.AdminHomeLive do
|
||||||
|> Map.put_new("published_at", NaiveDateTime.local_now())
|
|> Map.put_new("published_at", NaiveDateTime.local_now())
|
||||||
|
|
||||||
case Chiya.Notes.create_note(params) do
|
case Chiya.Notes.create_note(params) do
|
||||||
{:ok, _note} ->
|
{:ok, note} ->
|
||||||
{:noreply, socket |> put_flash(:info, "Note created!")}
|
{:noreply, socket
|
||||||
|
|> put_flash(:info, "Note created!")
|
||||||
|
|> push_navigate(to: ~p"/note/#{note.slug}")}
|
||||||
|
|
||||||
{:error, %Ecto.Changeset{} = changeset} ->
|
{:error, %Ecto.Changeset{} = changeset} ->
|
||||||
IO.inspect(changeset)
|
IO.inspect(changeset)
|
||||||
|
|
||||||
{:noreply,
|
{:noreply,
|
||||||
socket |> put_flash(:error, "Could not create note!") |> assign(form: to_form(changeset))}
|
socket
|
||||||
|
|> put_flash(:error, "Could not create note!")
|
||||||
|
|> assign(form: to_form(changeset))}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,7 +62,7 @@ defmodule ChiyaWeb.AdminHomeLive do
|
||||||
<.simple_form for={@form} phx-change="validate" phx-submit="save">
|
<.simple_form for={@form} phx-change="validate" phx-submit="save">
|
||||||
<.input field={@form[:content]} type="textarea" />
|
<.input field={@form[:content]} type="textarea" />
|
||||||
<:actions>
|
<:actions>
|
||||||
<.button>Save</.button>
|
<.button>Publish</.button>
|
||||||
</:actions>
|
</:actions>
|
||||||
</.simple_form>
|
</.simple_form>
|
||||||
</section>
|
</section>
|
||||||
|
|
Loading…
Reference in a new issue