Save and use previous query when filtering items
This commit is contained in:
parent
699cd61e0e
commit
2781748626
1 changed files with 4 additions and 3 deletions
|
@ -54,7 +54,7 @@ defmodule FreediveWeb.LiliformLive do
|
||||||
)
|
)
|
||||||
|
|
||||||
searched_items = search(filtered_items, query)
|
searched_items = search(filtered_items, query)
|
||||||
socket = assign(socket, :items, searched_items)
|
socket = assign(socket, %{items: searched_items, query: query})
|
||||||
|
|
||||||
socket =
|
socket =
|
||||||
case Kernel.length(Map.keys(searched_items)) == 1 do
|
case Kernel.length(Map.keys(searched_items)) == 1 do
|
||||||
|
@ -73,8 +73,9 @@ defmodule FreediveWeb.LiliformLive do
|
||||||
|
|
||||||
def(handle_event("filter", %{"key" => key}, socket)) do
|
def(handle_event("filter", %{"key" => key}, socket)) do
|
||||||
key = String.to_existing_atom(key)
|
key = String.to_existing_atom(key)
|
||||||
items = FreediveWeb.LiliformLive.filter(socket.assigns.items_all, key)
|
filtered_items = FreediveWeb.LiliformLive.filter(socket.assigns.items_all, key)
|
||||||
socket = assign(socket, :items, items)
|
searched_items = search(filtered_items, socket.assigns.query)
|
||||||
|
socket = assign(socket, :items, searched_items)
|
||||||
|
|
||||||
socket =
|
socket =
|
||||||
assign(
|
assign(
|
||||||
|
|
Loading…
Reference in a new issue