2021-03-03 08:15:14 -05:00
|
|
|
<h2>Listing Properties</h2>
|
2020-09-14 12:22:25 -04:00
|
|
|
|
|
|
|
<%= if @live_action in [:new, :edit] do %>
|
2021-02-24 07:49:39 -05:00
|
|
|
<%= live_modal @socket, Bones73kWeb.PropertyLive.FormComponent,
|
2020-09-14 12:22:25 -04:00
|
|
|
id: @property.id || :new,
|
|
|
|
title: @page_title,
|
|
|
|
action: @live_action,
|
|
|
|
property: @property,
|
2020-09-14 19:45:56 -04:00
|
|
|
current_user: @current_user,
|
2020-09-14 12:22:25 -04:00
|
|
|
return_to: Routes.property_index_path(@socket, :index) %>
|
|
|
|
<% end %>
|
|
|
|
|
2021-03-03 08:15:14 -05:00
|
|
|
<table class="table">
|
2020-09-14 12:22:25 -04:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2021-03-03 08:15:14 -05:00
|
|
|
<th scope="col">Name</th>
|
|
|
|
<th scope="col">Price</th>
|
|
|
|
<th scope="col">Description</th>
|
2020-09-14 12:22:25 -04:00
|
|
|
|
|
|
|
<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>
|
2020-09-15 04:47:19 -04:00
|
|
|
<%= 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 %>
|
2020-09-14 12:22:25 -04:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<% end %>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<span><%= live_patch "New Property", to: Routes.property_index_path(@socket, :new) %></span>
|