Hide from users actions he/she cannot do
This commit is contained in:
parent
50fdc5f6f3
commit
9d1f86972d
2 changed files with 15 additions and 5 deletions
|
@ -28,9 +28,15 @@
|
||||||
<td><%= property.description %></td>
|
<td><%= property.description %></td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
<%= if Roles.can?(@current_user, property, :show) do %>
|
||||||
<span><%= live_redirect "Show", to: Routes.property_show_path(@socket, :show, property) %></span>
|
<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>
|
<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>
|
<span><%= link "Delete", to: "#", phx_click: "delete", phx_value_id: property.id, data: [confirm: "Are you sure?"] %></span>
|
||||||
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -28,5 +28,9 @@
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<%= if Roles.can?(@current_user, @property, :edit) do %>
|
||||||
<span><%= live_patch "Edit", to: Routes.property_show_path(@socket, :edit, @property), class: "button" %></span>
|
<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>
|
<span><%= live_redirect "Back", to: Routes.property_index_path(@socket, :index) %></span>
|
||||||
|
<% end %>
|
||||||
|
|
Loading…
Reference in a new issue