46 lines
1.5 KiB
Text
46 lines
1.5 KiB
Text
<h1>Listing Properties</h1>
|
|
|
|
<%= if @live_action in [:new, :edit] do %>
|
|
<%= live_modal @socket, Bones73kWeb.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>
|
|
<%= if Roles.can?(@current_user, property, :show) do %>
|
|
<span><%= live_redirect "Show", to: Routes.property_show_path(@socket, :show, property) %></span>
|
|
<% end %>
|
|
<%= if Roles.can?(@current_user, property, :edit) do %>
|
|
<span><%= live_patch "Edit", to: Routes.property_index_path(@socket, :edit, property) %></span>
|
|
<% end %>
|
|
<%= if Roles.can?(@current_user, property, :delete) do %>
|
|
<span><%= link "Delete", to: "#", phx_click: "delete", phx_value_id: property.id, data: [confirm: "Are you sure?"] %></span>
|
|
<% end %>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
|
|
<span><%= live_patch "New Property", to: Routes.property_index_path(@socket, :new) %></span>
|