I’m having a bad time here and just posting to see if anyone can see what I’m doing wrong.
I’m using Flop Phoenix with streams. When I go to sort fields by clicking the header, the URL updates properly but nothing re-renders. Refreshing the page gives the desired results, so I figure there is nothing wrong with my business code. I’ve set it up according to the docs and no matter what I do, nothing seems to work. I’ve tried simplifying the table, configuring the stream with a different id function, and ore or less randomly changing the order of things, adding a mount function, removing the table opts, and so on. I’m sort of at my wit’s end for now so going to walk away for a bit, but I wanted to post here just in case someone can see what I’m doing wrong. I’m assuming it’s something really stupid.
Thanks in advance (and no problem if no one wants to help, lol).
Here is my whole liveview minus event handlers:
defmodule DesjWeb.Admin.Requests.IndexLive do
@moduledoc false
use DesjWeb, :live_view
@impl true
def handle_params(params, _uri, socket) do
case Desj.Requests.list_open_requests(params) do
{:ok, {requests, meta}} ->
socket =
socket
|> stream(:requests, requests, reset: true)
|> assign(:meta, meta)
{:noreply, socket}
{:error, _meta} ->
{:noreply, push_navigate(socket, to: ~p"/admin/requests")}
end
end
@impl true
def render(assigns) do
~H"""
<div :if={@meta.total_count == 0}>
There are no requests at this time.
</div>
<Flop.Phoenix.table
:if={@meta.total_count > 0}
items={@streams.requests}
meta={@meta}
path={~p"/admin/requests"}
opts={flop_table_opts(image?: true)}
>
<:col :let={{_, request}}>
<.artwork artwork={request.artwork} />
</:col>
<:col :let={{_, request}} label="Artwork" field={:artwork_title}>
<%= request.artwork.title %>
</:col>
<:col :let={{_, request}} label="User" field={:user_name}>
<%= request.user.name %>
</:col>
<:col :let={{_, request}} label="Exclusivity?" field={:request_exclusivity}>
<%= request.request_exclusivity %>
</:col>
<:col :let={{_, request}}>
<div :if={request.status == :open} class="flex items-center gap-2">
<form id={"reject-form-#{request.id}"} phx-submit="REJECT">
<input type="hidden" name="request_id" value={request.id} />
<.button kind={:reject}>Reject</.button>
</form>
<form id={"accept-form-#{request.id}"} phx-submit="ACCEPT">
<input type="hidden" name="request_id" value={request.id} />
<.button kind={:go}>Accept</.button>
</form>
</div>
<div>
<form
:if={request.status == :rejected}
id={"undo-reject-form-#{request.id}"}
phx-submit="UNDO_REJECT"
>
<input type="hidden" name="request_id" value={request.id} /> Rejected
<.button>Undo</.button>
</form>
</div>
</:col>
</Flop.Phoenix.table>
"""
end
end