bones73k/lib/real_estate_web/live/property_live/index.html.leex
2020-09-14 20:45:56 -03:00

40 lines
1.2 KiB
Text

<h1>Listing Properties</h1>
<%= if @live_action in [:new, :edit] do %>
<%= live_modal @socket, RealEstateWeb.PropertyLive.FormComponent,
id: @property.id || :new,
title: @page_title,
action: @live_action,
property: @property,
current_user: @current_user,
return_to: Routes.property_index_path(@socket, :index) %>
<% end %>
<table>
<thead>
<tr>
<th>Name</th>
<th>Price</th>
<th>Description</th>
<th></th>
</tr>
</thead>
<tbody id="properties">
<%= for property <- @properties do %>
<tr id="property-<%= property.id %>">
<td><%= property.name %></td>
<td><%= property.price %></td>
<td><%= property.description %></td>
<td>
<span><%= live_redirect "Show", to: Routes.property_show_path(@socket, :show, property) %></span>
<span><%= live_patch "Edit", to: Routes.property_index_path(@socket, :edit, property) %></span>
<span><%= link "Delete", to: "#", phx_click: "delete", phx_value_id: property.id, data: [confirm: "Are you sure?"] %></span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= live_patch "New Property", to: Routes.property_index_path(@socket, :new) %></span>