Make page_title/2 private in all LiveViews
The Index modules were calling Show.page_title/2 for modal edit routes. Inlined the logic as private functions in each Index module and removed the now-unused Show aliases. Closes #104
This commit is contained in:
@@ -8,7 +8,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
|||||||
|
|
||||||
alias MusicLibrary.Collection
|
alias MusicLibrary.Collection
|
||||||
alias MusicLibrary.Records
|
alias MusicLibrary.Records
|
||||||
alias MusicLibraryWeb.CollectionLive.Show
|
|
||||||
alias MusicLibraryWeb.ErrorMessages
|
alias MusicLibraryWeb.ErrorMessages
|
||||||
|
|
||||||
@default_records_list_params %{
|
@default_records_list_params %{
|
||||||
@@ -220,7 +220,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
|||||||
|
|
||||||
socket
|
socket
|
||||||
|> apply_fallback_index(params, :records, &apply_action/3)
|
|> apply_fallback_index(params, :records, &apply_action/3)
|
||||||
|> assign(:page_title, Show.page_title(socket.assigns.live_action, record))
|
|> assign(:page_title, page_title(:edit, record))
|
||||||
|> assign(:record, record)
|
|> assign(:record, record)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -337,4 +337,21 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
|||||||
|
|
||||||
~p"/collection?#{qs}"
|
~p"/collection?#{qs}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp page_title(action, record) do
|
||||||
|
Enum.join(
|
||||||
|
[
|
||||||
|
Records.Record.artist_names(record),
|
||||||
|
"-",
|
||||||
|
record.title,
|
||||||
|
"·",
|
||||||
|
title_segment(action),
|
||||||
|
"·",
|
||||||
|
gettext("Collection")
|
||||||
|
],
|
||||||
|
" "
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp title_segment(:edit), do: gettext("Edit")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -474,7 +474,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
|||||||
|> assign_embedding_text()}
|
|> assign_embedding_text()}
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_title(:show, record) do
|
defp page_title(:show, record) do
|
||||||
Enum.join(
|
Enum.join(
|
||||||
[
|
[
|
||||||
Records.Record.artist_names(record),
|
Records.Record.artist_names(record),
|
||||||
@@ -489,7 +489,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_title(action, record) do
|
defp page_title(action, record) do
|
||||||
Enum.join(
|
Enum.join(
|
||||||
[
|
[
|
||||||
Records.Record.artist_names(record),
|
Records.Record.artist_names(record),
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
|
|||||||
alias MusicLibrary.Records
|
alias MusicLibrary.Records
|
||||||
alias MusicLibrary.Wishlist
|
alias MusicLibrary.Wishlist
|
||||||
alias MusicLibraryWeb.ErrorMessages
|
alias MusicLibraryWeb.ErrorMessages
|
||||||
alias MusicLibraryWeb.WishlistLive.Show
|
|
||||||
|
|
||||||
@default_records_list_params %{
|
@default_records_list_params %{
|
||||||
query: "",
|
query: "",
|
||||||
@@ -191,7 +190,7 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
|
|||||||
|
|
||||||
socket
|
socket
|
||||||
|> apply_fallback_index(params, :records, &apply_action/3)
|
|> apply_fallback_index(params, :records, &apply_action/3)
|
||||||
|> assign(:page_title, Show.page_title(socket.assigns.live_action, record))
|
|> assign(:page_title, page_title(:edit, record))
|
||||||
|> assign(:record, record)
|
|> assign(:record, record)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -321,4 +320,21 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
|
|||||||
|
|
||||||
~p"/wishlist?#{qs}"
|
~p"/wishlist?#{qs}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp page_title(action, record) do
|
||||||
|
Enum.join(
|
||||||
|
[
|
||||||
|
Records.Record.artist_names(record),
|
||||||
|
"-",
|
||||||
|
record.title,
|
||||||
|
"·",
|
||||||
|
title_segment(action),
|
||||||
|
"·",
|
||||||
|
gettext("Wishlist")
|
||||||
|
],
|
||||||
|
" "
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp title_segment(:edit), do: gettext("Edit")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
|||||||
|> assign_embedding_text()}
|
|> assign_embedding_text()}
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_title(action, record) do
|
defp page_title(action, record) do
|
||||||
Enum.join(
|
Enum.join(
|
||||||
[
|
[
|
||||||
Records.Record.artist_names(record),
|
Records.Record.artist_names(record),
|
||||||
|
|||||||
@@ -52,12 +52,14 @@ msgstr ""
|
|||||||
#: lib/music_library_web/components/notes.ex
|
#: lib/music_library_web/components/notes.ex
|
||||||
#: lib/music_library_web/components/record_components.ex
|
#: lib/music_library_web/components/record_components.ex
|
||||||
#: lib/music_library_web/live/artist_live/show.ex
|
#: lib/music_library_web/live/artist_live/show.ex
|
||||||
|
#: lib/music_library_web/live/collection_live/index.ex
|
||||||
#: lib/music_library_web/live/collection_live/show.ex
|
#: lib/music_library_web/live/collection_live/show.ex
|
||||||
#: lib/music_library_web/live/online_store_template_live/index.ex
|
#: lib/music_library_web/live/online_store_template_live/index.ex
|
||||||
#: lib/music_library_web/live/record_set_live/index.ex
|
#: lib/music_library_web/live/record_set_live/index.ex
|
||||||
#: lib/music_library_web/live/record_set_live/show.ex
|
#: lib/music_library_web/live/record_set_live/show.ex
|
||||||
#: lib/music_library_web/live/scrobble_rules_live/index.ex
|
#: lib/music_library_web/live/scrobble_rules_live/index.ex
|
||||||
#: lib/music_library_web/live/scrobbled_tracks_live/index.ex
|
#: lib/music_library_web/live/scrobbled_tracks_live/index.ex
|
||||||
|
#: lib/music_library_web/live/wishlist_live/index.ex
|
||||||
#: lib/music_library_web/live/wishlist_live/show.ex
|
#: lib/music_library_web/live/wishlist_live/show.ex
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Edit"
|
msgid "Edit"
|
||||||
|
|||||||
@@ -52,12 +52,14 @@ msgstr ""
|
|||||||
#: lib/music_library_web/components/notes.ex
|
#: lib/music_library_web/components/notes.ex
|
||||||
#: lib/music_library_web/components/record_components.ex
|
#: lib/music_library_web/components/record_components.ex
|
||||||
#: lib/music_library_web/live/artist_live/show.ex
|
#: lib/music_library_web/live/artist_live/show.ex
|
||||||
|
#: lib/music_library_web/live/collection_live/index.ex
|
||||||
#: lib/music_library_web/live/collection_live/show.ex
|
#: lib/music_library_web/live/collection_live/show.ex
|
||||||
#: lib/music_library_web/live/online_store_template_live/index.ex
|
#: lib/music_library_web/live/online_store_template_live/index.ex
|
||||||
#: lib/music_library_web/live/record_set_live/index.ex
|
#: lib/music_library_web/live/record_set_live/index.ex
|
||||||
#: lib/music_library_web/live/record_set_live/show.ex
|
#: lib/music_library_web/live/record_set_live/show.ex
|
||||||
#: lib/music_library_web/live/scrobble_rules_live/index.ex
|
#: lib/music_library_web/live/scrobble_rules_live/index.ex
|
||||||
#: lib/music_library_web/live/scrobbled_tracks_live/index.ex
|
#: lib/music_library_web/live/scrobbled_tracks_live/index.ex
|
||||||
|
#: lib/music_library_web/live/wishlist_live/index.ex
|
||||||
#: lib/music_library_web/live/wishlist_live/show.ex
|
#: lib/music_library_web/live/wishlist_live/show.ex
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Edit"
|
msgid "Edit"
|
||||||
|
|||||||
Reference in New Issue
Block a user