Added BiddingRoundServer "CurrentRoundServer" with a facade to control it. "Listing Biddings" page shows information which round is currently running.
This commit is contained in:
@ -2,6 +2,7 @@ defmodule BeetRoundServerWeb.BiddingLive.Index do
|
||||
use BeetRoundServerWeb, :live_view
|
||||
|
||||
alias BeetRoundServer.Biddings
|
||||
alias BeetRoundServer.BiddingRounds.BiddingRoundFacade
|
||||
|
||||
@impl true
|
||||
def render(assigns) do
|
||||
@ -16,6 +17,12 @@ defmodule BeetRoundServerWeb.BiddingLive.Index do
|
||||
</:actions>
|
||||
</.header>
|
||||
|
||||
<%= if @bidding_round == 0 do %>
|
||||
<p>Keine Bietrunde aktiv.</p>
|
||||
<% else %>
|
||||
<p>Aktive Bietrunde: {@bidding_round}</p>
|
||||
<% end %>
|
||||
|
||||
<.table
|
||||
id="biddings"
|
||||
rows={@streams.biddings}
|
||||
@ -50,9 +57,12 @@ defmodule BeetRoundServerWeb.BiddingLive.Index do
|
||||
Biddings.subscribe_biddings(socket.assigns.current_scope)
|
||||
end
|
||||
|
||||
current_round = BiddingRoundFacade.get_current_round()
|
||||
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(:page_title, "Listing Biddings")
|
||||
|> assign(bidding_round: current_round)
|
||||
|> stream(:biddings, list_biddings(socket.assigns.current_scope))}
|
||||
end
|
||||
|
||||
@ -67,7 +77,8 @@ defmodule BeetRoundServerWeb.BiddingLive.Index do
|
||||
@impl true
|
||||
def handle_info({type, %BeetRoundServer.Biddings.Bidding{}}, socket)
|
||||
when type in [:created, :updated, :deleted] do
|
||||
{:noreply, stream(socket, :biddings, list_biddings(socket.assigns.current_scope), reset: true)}
|
||||
{:noreply,
|
||||
stream(socket, :biddings, list_biddings(socket.assigns.current_scope), reset: true)}
|
||||
end
|
||||
|
||||
defp list_biddings(current_scope) do
|
||||
|
||||
Reference in New Issue
Block a user