Add initial project
This commit is contained in:
11
lib/wish_web/live/home_live/index.ex
Normal file
11
lib/wish_web/live/home_live/index.ex
Normal file
@@ -0,0 +1,11 @@
|
||||
defmodule WishWeb.HomeLive.Index do
|
||||
use WishWeb, :live_view
|
||||
|
||||
alias Wish.Wishlist
|
||||
alias Wish.Wishlist.Item
|
||||
|
||||
@impl true
|
||||
def mount(_params, _session, socket) do
|
||||
{:ok, stream(socket, :items, Wishlist.list_items())}
|
||||
end
|
||||
end
|
||||
39
lib/wish_web/live/home_live/index.html.heex
Normal file
39
lib/wish_web/live/home_live/index.html.heex
Normal file
@@ -0,0 +1,39 @@
|
||||
<.header>
|
||||
Listing Items
|
||||
</.header>
|
||||
|
||||
<.table
|
||||
id="items"
|
||||
rows={@streams.items}
|
||||
row_click={fn {_id, item} -> JS.navigate(~p"/items/#{item}") end}
|
||||
>
|
||||
<:col :let={{_id, item}} label="Title"><%= item.title %></:col>
|
||||
<:col :let={{_id, item}} label="Description"><%= item.description %></:col>
|
||||
<:col :let={{_id, item}} label="Url"><%= item.url %></:col>
|
||||
<:col :let={{_id, item}} label="Desire"><%= item.desire %></:col>
|
||||
<:action :let={{_id, item}}>
|
||||
<div class="sr-only">
|
||||
<.link navigate={~p"/items/#{item}"}>Show</.link>
|
||||
</div>
|
||||
<.link patch={~p"/items/#{item}/edit"}>Edit</.link>
|
||||
</:action>
|
||||
<:action :let={{id, item}}>
|
||||
<.link
|
||||
phx-click={JS.push("delete", value: %{id: item.id}) |> hide("##{id}")}
|
||||
data-confirm="Are you sure?"
|
||||
>
|
||||
Delete
|
||||
</.link>
|
||||
</:action>
|
||||
</.table>
|
||||
|
||||
<.modal :if={@live_action in [:new, :edit]} id="item-modal" show on_cancel={JS.patch(~p"/items")}>
|
||||
<.live_component
|
||||
module={WishWeb.ItemLive.FormComponent}
|
||||
id={@item.id || :new}
|
||||
title={@page_title}
|
||||
action={@live_action}
|
||||
item={@item}
|
||||
patch={~p"/items"}
|
||||
/>
|
||||
</.modal>
|
||||
Reference in New Issue
Block a user