Fix redirects for import/edit in wishlist index
This commit is contained in:
@@ -154,6 +154,15 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
|
|||||||
String.to_integer(value)
|
String.to_integer(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp back_path(record_list_params) do
|
||||||
|
qs =
|
||||||
|
record_list_params
|
||||||
|
|> Map.take([:query, :page, :page_size])
|
||||||
|
|> Enum.filter(fn {_, v} -> v not in ["", nil] end)
|
||||||
|
|
||||||
|
~p"/wishlist?#{qs}"
|
||||||
|
end
|
||||||
|
|
||||||
defp musicbrainz_url(record) do
|
defp musicbrainz_url(record) do
|
||||||
"https://musicbrainz.org/release-group/#{record.musicbrainz_id}"
|
"https://musicbrainz.org/release-group/#{record.musicbrainz_id}"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -171,7 +171,12 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<.modal :if={@live_action == :edit} id="record-modal" show on_cancel={JS.patch(~p"/wishlist")}>
|
<.modal
|
||||||
|
:if={@live_action == :edit}
|
||||||
|
id="record-modal"
|
||||||
|
show
|
||||||
|
on_cancel={JS.patch(back_path(@record_list_params))}
|
||||||
|
>
|
||||||
<.live_component
|
<.live_component
|
||||||
module={MusicLibraryWeb.RecordLive.FormComponent}
|
module={MusicLibraryWeb.RecordLive.FormComponent}
|
||||||
id={@record.id}
|
id={@record.id}
|
||||||
@@ -179,18 +184,23 @@
|
|||||||
action={@live_action}
|
action={@live_action}
|
||||||
show_purchased_at={false}
|
show_purchased_at={false}
|
||||||
record={@record}
|
record={@record}
|
||||||
patch={~p"/wishlist"}
|
patch={back_path(@record_list_params)}
|
||||||
/>
|
/>
|
||||||
</.modal>
|
</.modal>
|
||||||
|
|
||||||
<.modal :if={@live_action == :import} id="record-modal" show on_cancel={JS.patch(~p"/wishlist")}>
|
<.modal
|
||||||
|
:if={@live_action == :import}
|
||||||
|
id="record-modal"
|
||||||
|
show
|
||||||
|
on_cancel={JS.patch(back_path(@record_list_params))}
|
||||||
|
>
|
||||||
<.live_component
|
<.live_component
|
||||||
module={MusicLibraryWeb.RecordLive.ImportComponent}
|
module={MusicLibraryWeb.RecordLive.ImportComponent}
|
||||||
id={:search}
|
id={:search}
|
||||||
title={@page_title}
|
title={@page_title}
|
||||||
action={@live_action}
|
action={@live_action}
|
||||||
record={@record}
|
record={@record}
|
||||||
patch={~p"/wishlist"}
|
patch={back_path(@record_list_params)}
|
||||||
initial_query=""
|
initial_query=""
|
||||||
/>
|
/>
|
||||||
</.modal>
|
</.modal>
|
||||||
|
|||||||
Reference in New Issue
Block a user