mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 06:37:59 +01:00
sort tags on image page
This commit is contained in:
parent
2cfd5d2f19
commit
5c209146a7
2 changed files with 18 additions and 2 deletions
|
@ -35,4 +35,20 @@ defmodule Philomena.Tags.Tag do
|
|||
|> cast(attrs, [])
|
||||
|> validate_required([])
|
||||
end
|
||||
|
||||
def display_order do
|
||||
Philomena.Tags.Tag
|
||||
|> order_by(
|
||||
[t],
|
||||
asc: t.category == "spoiler",
|
||||
asc: t.category == "content-official",
|
||||
asc: t.category == "content-fanmade",
|
||||
asc: t.category == "species",
|
||||
asc: t.category == "oc",
|
||||
asc: t.category == "character",
|
||||
asc: t.category == "origin",
|
||||
asc: t.category == "rating",
|
||||
asc: t.name
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
defmodule PhilomenaWeb.ImageController do
|
||||
use PhilomenaWeb, :controller
|
||||
|
||||
alias Philomena.{Images.Image, Comments.Comment, Textile.Renderer}
|
||||
alias Philomena.{Images.Image, Comments.Comment, Tags.Tag, Textile.Renderer}
|
||||
alias Philomena.Repo
|
||||
import Ecto.Query
|
||||
|
||||
plug :load_and_authorize_resource, model: Image, only: :show, preload: [:tags, :user]
|
||||
plug :load_and_authorize_resource, model: Image, only: :show, preload: [:user, tags: Tag.display_order()]
|
||||
|
||||
def index(conn, _params) do
|
||||
query = conn.assigns.compiled_filter
|
||||
|
|
Loading…
Reference in a new issue