mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
add deleted toggle to main search form
This commit is contained in:
parent
907e030b3a
commit
0c7f13932b
3 changed files with 14 additions and 3 deletions
|
@ -1,10 +1,10 @@
|
|||
defmodule Philomena.Schema.Search do
|
||||
alias Philomena.Images.Query
|
||||
import Search.String
|
||||
alias Search.String
|
||||
import Ecto.Changeset
|
||||
|
||||
def validate_search(changeset, field, user, watched \\ false) do
|
||||
query = changeset |> get_field(field) |> normalize()
|
||||
query = changeset |> get_field(field) |> String.normalize()
|
||||
output = Query.compile(user, query, watched)
|
||||
|
||||
case output do
|
||||
|
|
|
@ -129,5 +129,15 @@ h1 Search
|
|||
"Ascending": :asc
|
||||
]
|
||||
|
||||
sort_hidden = [
|
||||
"Exclude Deleted": "",
|
||||
"Include Deleted/Merged": "1",
|
||||
"Deleted Only": "deleted",
|
||||
"Deleted/Merged Only": "only"
|
||||
]
|
||||
|
||||
= select f, :sf, sort_fields, class: "input input--separate-left", name: "sf", autocomplete: "off", selected: @conn.params["sf"]
|
||||
= select f, :sd, sort_directions, class: "input input--separate-left", name: "sd", autocomplete: "off", selected: @conn.params["sd"]
|
||||
|
||||
= if hides_images?(@conn) do
|
||||
= select f, :del, sort_hidden, class: "input input--separate-left", name: "del", autocomplete: "off", selected: @conn.params["del"]
|
||||
|
|
|
@ -2,4 +2,5 @@ defmodule PhilomenaWeb.SearchView do
|
|||
use PhilomenaWeb, :view
|
||||
|
||||
def scope(conn), do: Philomena.ImageScope.scope(conn)
|
||||
def hides_images?(conn), do: can?(conn, :hide, %Philomena.Images.Image{})
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue