fix: use push_patch instead of push_redirect

This commit is contained in:
Zach Daniel 2023-08-02 18:27:52 -04:00
parent dcf9b288a2
commit 21924d35a5
2 changed files with 19 additions and 33 deletions

View file

@ -111,7 +111,7 @@ defmodule AshAdmin.Components.Resource.Form do
<label for="action">Action</label> <label for="action">Action</label>
<%= Phoenix.HTML.Form.select(form, :action, actions(@resource, @type), <%= Phoenix.HTML.Form.select(form, :action, actions(@resource, @type),
disabled: Enum.count(actions(@resource, @type)) <= 1, disabled: Enum.count(actions(@resource, @type)) <= 1,
select: to_string(@action.name) selected: to_string(@action.name)
) %> ) %>
</.form> </.form>
</div> </div>
@ -1101,19 +1101,19 @@ defmodule AshAdmin.Components.Resource.Form do
case socket.assigns.action.type do case socket.assigns.action.type do
:create -> :create ->
{:noreply, {:noreply,
push_redirect(socket, push_patch(socket,
to: self_path(socket.assigns.url_path, socket.assigns.params, %{"table" => table}) to: self_path(socket.assigns.url_path, socket.assigns.params, %{"table" => table})
)} )}
:update -> :update ->
{:noreply, {:noreply,
push_redirect(socket, push_patch(socket,
to: self_path(socket.assigns.url_path, socket.assigns.params, %{"table" => table}) to: self_path(socket.assigns.url_path, socket.assigns.params, %{"table" => table})
)} )}
:destroy -> :destroy ->
{:noreply, {:noreply,
push_redirect(socket, push_patch(socket,
to: self_path(socket.assigns.url_path, socket.assigns.params, %{"table" => table}) to: self_path(socket.assigns.url_path, socket.assigns.params, %{"table" => table})
)} )}
end end
@ -1132,28 +1132,11 @@ defmodule AshAdmin.Components.Resource.Form do
end end
) )
case action.type do {:noreply,
:create -> push_patch(socket,
{:noreply, to: self_path(socket.assigns.url_path, socket.assigns.params, %{"action" => action.name}),
push_redirect(socket, replace: true
to: )}
self_path(socket.assigns.url_path, socket.assigns.params, %{"action" => action.name})
)}
:update ->
{:noreply,
push_redirect(socket,
to:
self_path(socket.assigns.url_path, socket.assigns.params, %{"action" => action.name})
)}
:destroy ->
{:noreply,
push_redirect(socket,
to:
self_path(socket.assigns.url_path, socket.assigns.params, %{"action" => action.name})
)}
end
end end
def handle_event("change_action", _, socket) do def handle_event("change_action", _, socket) do

File diff suppressed because one or more lines are too long