mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
prevent params drop on admin user pagination (derpibooru/philomena#153)
This commit is contained in:
parent
ff5c01ce07
commit
218607b208
2 changed files with 16 additions and 1 deletions
|
@ -10,7 +10,7 @@ h1 Users
|
|||
=> link "2FA users", to: Routes.admin_user_path(@conn, :index, twofactor: 1)
|
||||
|
||||
- route = fn p -> Routes.admin_user_path(@conn, :index, p) end
|
||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @users, route: route, conn: @conn, params: [q: @conn.params["q"]]
|
||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @users, route: route, conn: @conn, params: page_params(@conn.params)
|
||||
|
||||
.block
|
||||
.block__header
|
||||
|
|
|
@ -1,6 +1,21 @@
|
|||
defmodule PhilomenaWeb.Admin.UserView do
|
||||
use PhilomenaWeb, :view
|
||||
|
||||
def page_params(params) do
|
||||
[]
|
||||
|> page_param(params, "q", :q)
|
||||
|> page_param(params, "staff", :staff)
|
||||
|> page_param(params, "twofactor", :twofactor)
|
||||
end
|
||||
|
||||
defp page_param(list, params, key, key_atom) do
|
||||
case params[key] do
|
||||
nil -> list
|
||||
"" -> list
|
||||
val -> [{key_atom, val} | list]
|
||||
end
|
||||
end
|
||||
|
||||
def checkbox_mapper(form, field, input_opts, role, _label_opts, _opts) do
|
||||
input_id = "user_roles_#{role.id}"
|
||||
label_opts = [for: input_id]
|
||||
|
|
Loading…
Reference in a new issue