Add individual permission checks in dropdowns

Closes SCI-258.
This commit is contained in:
Luka Murn 2016-08-25 13:48:37 +02:00
parent 8592c13ed4
commit 6d86a02d7c
4 changed files with 72 additions and 56 deletions

View file

@ -14,21 +14,25 @@
</a>
<ul class="dropdown-menu dropdown-menu-fixed" aria-labelledby="comment-<%= comment.id %>-dropdown">
<li class="dropdown-header"><%= I18n.t('comments.options_dropdown.header') %></li>
<li>
<a href="#"
data-action="edit-comment"
data-url="<%= edit_my_module_my_module_comment_path(comment.my_module_comment.my_module, comment, format: :json) %>">
<%= t('comments.options_dropdown.edit') %>
</a>
<% if can_edit_module_comment(comment) %>
<li>
<a href="#"
data-action="edit-comment"
data-url="<%= edit_my_module_my_module_comment_path(comment.my_module_comment.my_module, comment, format: :json) %>">
<%= t('comments.options_dropdown.edit') %>
</a>
</li>
<li>
<a href="#"
data-action="delete-comment"
data-url="<%= my_module_my_module_comment_path(comment.my_module_comment.my_module, comment, format: :json) %>"
data-confirm-message="<%= t('comments.delete_confirm') %>">
<%= t('comments.options_dropdown.delete') %>
</a>
</li>
<% end %>
<% if can_delete_module_comment(comment) %>
<li>
<a href="#"
data-action="delete-comment"
data-url="<%= my_module_my_module_comment_path(comment.my_module_comment.my_module, comment, format: :json) %>"
data-confirm-message="<%= t('comments.delete_confirm') %>">
<%= t('comments.options_dropdown.delete') %>
</a>
</li>
<% end %>
</ul>
</div>
<% end %>

View file

@ -14,21 +14,25 @@
</a>
<ul class="dropdown-menu dropdown-menu-fixed" aria-labelledby="comment-<%= comment.id %>-dropdown">
<li class="dropdown-header"><%= I18n.t('comments.options_dropdown.header') %></li>
<li>
<a href="#"
data-action="edit-comment"
data-url="<%= edit_project_project_comment_path(comment.project_comment.project, comment, format: :json) %>">
<%= t('comments.options_dropdown.edit') %>
</a>
<% if can_edit_project_comment(comment) %>
<li>
<a href="#"
data-action="edit-comment"
data-url="<%= edit_project_project_comment_path(comment.project_comment.project, comment, format: :json) %>">
<%= t('comments.options_dropdown.edit') %>
</a>
</li>
<li>
<a href="#"
data-action="delete-comment"
data-url="<%= project_project_comment_path(comment.project_comment.project, comment, format: :json) %>"
data-confirm-message="<%= t('comments.delete_confirm') %>">
<%= t('comments.options_dropdown.delete') %>
</a>
</li>
<% end %>
<% if can_delete_project_comment(comment) %>
<li>
<a href="#"
data-action="delete-comment"
data-url="<%= project_project_comment_path(comment.project_comment.project, comment, format: :json) %>"
data-confirm-message="<%= t('comments.delete_confirm') %>">
<%= t('comments.options_dropdown.delete') %>
</a>
</li>
<% end %>
</ul>
</div>
<% end %>

View file

@ -16,21 +16,25 @@
</a>
<ul class="dropdown-menu dropdown-menu-fixed" aria-labelledby="comment-<%= comment.id %>-dropdown">
<li class="dropdown-header"><%= I18n.t('comments.options_dropdown.header') %></li>
<li>
<a href="#"
data-action="edit-comment"
data-url="<%= edit_result_result_comment_path(comment.result_comment.result, comment, format: :json) %>">
<%= t('comments.options_dropdown.edit') %>
</a>
<% if can_edit_result_comment_in_module(comment) %>
<li>
<a href="#"
data-action="edit-comment"
data-url="<%= edit_result_result_comment_path(comment.result_comment.result, comment, format: :json) %>">
<%= t('comments.options_dropdown.edit') %>
</a>
</li>
<li>
<a href="#"
data-action="delete-comment"
data-url="<%= result_result_comment_path(comment.result_comment.result, comment, format: :json) %>"
data-confirm-message="<%= t('comments.delete_confirm') %>">
<%= t('comments.options_dropdown.delete') %>
</a>
</li>
<% end %>
<% if can_delete_result_comment_in_module(comment) %>
<li>
<a href="#"
data-action="delete-comment"
data-url="<%= result_result_comment_path(comment.result_comment.result, comment, format: :json) %>"
data-confirm-message="<%= t('comments.delete_confirm') %>">
<%= t('comments.options_dropdown.delete') %>
</a>
</li>
<% end %>
</ul>
</div>
<% end %>

View file

@ -16,21 +16,25 @@
</a>
<ul class="dropdown-menu dropdown-menu-fixed" aria-labelledby="comment-<%= comment.id %>-dropdown">
<li class="dropdown-header"><%= I18n.t('comments.options_dropdown.header') %></li>
<li>
<a href="#"
data-action="edit-comment"
data-url="<%= edit_step_step_comment_path(comment.step_comment.step, comment, format: :json) %>">
<%= t('comments.options_dropdown.edit') %>
</a>
<% if can_edit_step_comment_in_protocol(comment) %>
<li>
<a href="#"
data-action="edit-comment"
data-url="<%= edit_step_step_comment_path(comment.step_comment.step, comment, format: :json) %>">
<%= t('comments.options_dropdown.edit') %>
</a>
</li>
<li>
<a href="#"
data-action="delete-comment"
data-url="<%= step_step_comment_path(comment.step_comment.step, comment, format: :json) %>"
data-confirm-message="<%= t('comments.delete_confirm') %>">
<%= t('comments.options_dropdown.delete') %>
</a>
</li>
<% end %>
<% if can_delete_step_comment_in_protocol(comment) %>
<li>
<a href="#"
data-action="delete-comment"
data-url="<%= step_step_comment_path(comment.step_comment.step, comment, format: :json) %>"
data-confirm-message="<%= t('comments.delete_confirm') %>">
<%= t('comments.options_dropdown.delete') %>
</a>
</li>
<% end %>
</ul>
</div>
<% end %>