add deleted toggle to main search form

This commit is contained in:
byte[] 2019-12-30 18:32:24 -05:00
parent 907e030b3a
commit 0c7f13932b
3 changed files with 14 additions and 3 deletions

View file

@ -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

View file

@ -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"]

View file

@ -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