Hide from users actions he/she cannot do

This commit is contained in:
Joao Gilberto Balsini Moura 2020-09-15 05:47:19 -03:00
parent 50fdc5f6f3
commit 9d1f86972d
2 changed files with 15 additions and 5 deletions

View file

@ -28,9 +28,15 @@
<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 %>

View file

@ -28,5 +28,9 @@
</ul>
<%= if Roles.can?(@current_user, @property, :edit) do %>
<span><%= live_patch "Edit", to: Routes.property_show_path(@socket, :edit, @property), class: "button" %></span>
<% end %>
<%= if Roles.can?(@current_user, @property, :index) do %>
<span><%= live_redirect "Back", to: Routes.property_index_path(@socket, :index) %></span>
<% end %>