Fix edit actions to allow create new data.

dev
KKlochko 2 months ago
parent c96aac44cd
commit 40a19b9c35

@ -34,7 +34,6 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Edit do
socket socket
|> assign(:params, params) |> assign(:params, params)
|> apply_action(socket.assigns.live_action, params) |> apply_action(socket.assigns.live_action, params)
|> redirect_if_not_editable()
{:noreply, socket} {:noreply, socket}
end end
@ -46,6 +45,7 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Edit do
:author, :author,
Ash.get!(Metadata.Author, id, load: [:dbi_server], actor: socket.assigns.current_user) Ash.get!(Metadata.Author, id, load: [:dbi_server], actor: socket.assigns.current_user)
) )
|> redirect_if_not_editable()
end end
defp apply_action(socket, :new, _params) do defp apply_action(socket, :new, _params) do

@ -31,7 +31,6 @@ defmodule DecentralisedBookIndexWeb.BookLive.Edit do
socket = socket =
socket socket
|> apply_action(socket.assigns.live_action, params) |> apply_action(socket.assigns.live_action, params)
|> redirect_if_not_editable()
{:noreply, socket} {:noreply, socket}
end end
@ -43,6 +42,7 @@ defmodule DecentralisedBookIndexWeb.BookLive.Edit do
:book, :book,
Ash.get!(DecentralisedBookIndex.Metadata.Book, id, load: [:dbi_server], actor: socket.assigns.current_user) Ash.get!(DecentralisedBookIndex.Metadata.Book, id, load: [:dbi_server], actor: socket.assigns.current_user)
) )
|> redirect_if_not_editable()
end end
defp apply_action(socket, :new, _params) do defp apply_action(socket, :new, _params) do

@ -30,7 +30,6 @@ defmodule DecentralisedBookIndexWeb.PublisherLive.Edit do
socket socket
|> assign(:params, params) |> assign(:params, params)
|> apply_action(socket.assigns.live_action, params) |> apply_action(socket.assigns.live_action, params)
|> redirect_if_not_editable()
{:noreply, socket} {:noreply, socket}
end end
@ -42,6 +41,7 @@ defmodule DecentralisedBookIndexWeb.PublisherLive.Edit do
:publisher, :publisher,
Ash.get!(Metadata.Publisher, id, load: [:dbi_server], actor: socket.assigns.current_user) Ash.get!(Metadata.Publisher, id, load: [:dbi_server], actor: socket.assigns.current_user)
) )
|> redirect_if_not_editable()
end end
defp apply_action(socket, :new, _params) do defp apply_action(socket, :new, _params) do

Loading…
Cancel
Save