bones73k/lib/bones73k_web/live/property_live/index.html.leex

47 lines
1.6 KiB
Text
Raw Normal View History

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,
current_user: @current_user %>
2020-09-14 12:22:25 -04:00
<% end %>
<div class="d-flex justify-content-between d-flex align-items-end">
<h2>Listing Properties</h2>
<span><%= live_patch "New Property", to: Routes.property_index_path(@socket, :new), class: "btn btn-primary" %></span>
</div>
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>
<%= if Roles.can?(@current_user, property, :show) do %>
2021-03-03 10:16:11 -05:00
<%= live_redirect "Show", to: Routes.property_show_path(@socket, :show, property), class: "link-secondary mx-1" %>
<% end %>
<%= if Roles.can?(@current_user, property, :edit) do %>
2021-03-03 10:16:11 -05:00
<%= live_patch "Edit", to: Routes.property_index_path(@socket, :edit, property), class: "mx-1" %>
<% end %>
<%= if Roles.can?(@current_user, property, :delete) do %>
2021-03-03 10:16:11 -05:00
<%= link "Delete", to: "#", phx_click: "delete", phx_value_id: property.id, data: [confirm: "Are you sure?"], class: "link-danger mx-1" %>
<% end %>
2020-09-14 12:22:25 -04:00
</td>
</tr>
<% end %>
</tbody>
</table>