After "mix phx.gen.live Biddings Bidding biddings bidding_round:integer amount:integer depot_wish_one:string depot_wish_two:string".
This commit is contained in:
67
lib/beet_round_server_web/live/bidding_live/show.ex
Normal file
67
lib/beet_round_server_web/live/bidding_live/show.ex
Normal file
@ -0,0 +1,67 @@
|
||||
defmodule BeetRoundServerWeb.BiddingLive.Show do
|
||||
use BeetRoundServerWeb, :live_view
|
||||
|
||||
alias BeetRoundServer.Biddings
|
||||
|
||||
@impl true
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<Layouts.app flash={@flash} current_scope={@current_scope}>
|
||||
<.header>
|
||||
Bidding {@bidding.id}
|
||||
<:subtitle>This is a bidding record from your database.</:subtitle>
|
||||
<:actions>
|
||||
<.button navigate={~p"/biddings"}>
|
||||
<.icon name="hero-arrow-left" />
|
||||
</.button>
|
||||
<.button variant="primary" navigate={~p"/biddings/#{@bidding}/edit?return_to=show"}>
|
||||
<.icon name="hero-pencil-square" /> Edit bidding
|
||||
</.button>
|
||||
</:actions>
|
||||
</.header>
|
||||
|
||||
<.list>
|
||||
<:item title="Bidding round">{@bidding.bidding_round}</:item>
|
||||
<:item title="Amount">{@bidding.amount}</:item>
|
||||
<:item title="Depot wish one">{@bidding.depot_wish_one}</:item>
|
||||
<:item title="Depot wish two">{@bidding.depot_wish_two}</:item>
|
||||
</.list>
|
||||
</Layouts.app>
|
||||
"""
|
||||
end
|
||||
|
||||
@impl true
|
||||
def mount(%{"id" => id}, _session, socket) do
|
||||
if connected?(socket) do
|
||||
Biddings.subscribe_biddings(socket.assigns.current_scope)
|
||||
end
|
||||
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(:page_title, "Show Bidding")
|
||||
|> assign(:bidding, Biddings.get_bidding!(socket.assigns.current_scope, id))}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info(
|
||||
{:updated, %BeetRoundServer.Biddings.Bidding{id: id} = bidding},
|
||||
%{assigns: %{bidding: %{id: id}}} = socket
|
||||
) do
|
||||
{:noreply, assign(socket, :bidding, bidding)}
|
||||
end
|
||||
|
||||
def handle_info(
|
||||
{:deleted, %BeetRoundServer.Biddings.Bidding{id: id}},
|
||||
%{assigns: %{bidding: %{id: id}}} = socket
|
||||
) do
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:error, "The current bidding was deleted.")
|
||||
|> push_navigate(to: ~p"/biddings")}
|
||||
end
|
||||
|
||||
def handle_info({type, %BeetRoundServer.Biddings.Bidding{}}, socket)
|
||||
when type in [:created, :updated, :deleted] do
|
||||
{:noreply, socket}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user