/
index.html.heex
44 lines (42 loc) · 1.08 KB
/
index.html.heex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<.header>
Listing Products
<:actions>
<.link patch={~p"/products/new"}>
<.button>New Product</.button>
</.link>
</:actions>
</.header>
<.table id="products" rows={@products} row_click={&JS.navigate(~p"/products/#{&1}")}>
<:col :let={product} label="Name">
<%= product.name %>
</:col>
<:col :let={product} label="Price">
<%= product.price %>
</:col>
<:action :let={product}>
<div class="sr-only">
<.link navigate={~p"/products/#{product}"}>Show</.link>
</div>
<.link patch={~p"/products/#{product}/edit?#{%{foo: "bar"}}"}>Edit</.link>
</:action>
<:action :let={product}>
<.link phx-click={JS.push("delete", value: %{id: product.id})} data-confirm="Are you sure?">
Delete
</.link>
</:action>
</.table>
<.modal
:if={@live_action in [:new, :edit]}
id="product-modal"
show
on_cancel={JS.navigate(~p"/products")}
>
<.live_component
module={ExampleWeb.ProductLive.FormComponent}
id={@product.id || :new}
title={@page_title}
action={@live_action}
product={@product}
navigate={~p"/products"}
/>
</.modal>