Sort collection records by release
This commit is contained in:
@@ -83,6 +83,13 @@ defmodule MusicLibrary.Records do
|
|||||||
{:desc, r.inserted_at},
|
{:desc, r.inserted_at},
|
||||||
order_alphabetically()
|
order_alphabetically()
|
||||||
])
|
])
|
||||||
|
|
||||||
|
:release ->
|
||||||
|
initial_search
|
||||||
|
|> order_by([r], [
|
||||||
|
{:desc, r.release_date},
|
||||||
|
order_alphabetically()
|
||||||
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
Enum.reduce(parsed_query, search_with_order, fn
|
Enum.reduce(parsed_query, search_with_order, fn
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
|||||||
|
|
||||||
defp parse_order("alphabetical"), do: :alphabetical
|
defp parse_order("alphabetical"), do: :alphabetical
|
||||||
defp parse_order("purchase"), do: :purchase
|
defp parse_order("purchase"), do: :purchase
|
||||||
|
defp parse_order("release"), do: :release
|
||||||
|
|
||||||
defp order_path(record_list_params, order) do
|
defp order_path(record_list_params, order) do
|
||||||
qs =
|
qs =
|
||||||
|
|||||||
@@ -51,6 +51,16 @@
|
|||||||
<.icon name="hero-user-solid" class="icon" aria-hidden="true" data-slot="icon" />
|
<.icon name="hero-user-solid" class="icon" aria-hidden="true" data-slot="icon" />
|
||||||
<span class="hidden sm:inline">{gettext("A->Z")}</span>
|
<span class="hidden sm:inline">{gettext("A->Z")}</span>
|
||||||
</.button>
|
</.button>
|
||||||
|
<.button
|
||||||
|
patch={order_path(@record_list_params, :release)}
|
||||||
|
size="sm"
|
||||||
|
class={[
|
||||||
|
@record_list_params.order == :release && "bg-zinc-100! dark:bg-zinc-700!"
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<.icon name="hero-calendar-days" class="icon" aria-hidden="true" data-slot="icon" />
|
||||||
|
<span class="hidden sm:inline">{gettext("Release")}</span>
|
||||||
|
</.button>
|
||||||
</.button_group>
|
</.button_group>
|
||||||
|
|
||||||
<.button_group>
|
<.button_group>
|
||||||
|
|||||||
@@ -1641,3 +1641,8 @@ msgstr[1] ""
|
|||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Never"
|
msgid "Never"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: lib/music_library_web/live/collection_live/index.html.heex
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
msgid "Release"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -1641,3 +1641,8 @@ msgstr[1] ""
|
|||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Never"
|
msgid "Never"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: lib/music_library_web/live/collection_live/index.html.heex
|
||||||
|
#, elixir-autogen, elixir-format, fuzzy
|
||||||
|
msgid "Release"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
Reference in New Issue
Block a user