Feature #35616 » 0002-Show-the-Delete-item-in-the-context-menu-only-when-o.patch
| app/controllers/context_menus_controller.rb | ||
|---|---|---|
|
@priorities = IssuePriority.active.reverse
|
||
|
@back = back_url
|
||
|
begin
|
||
|
# Recognize the controller and action from the back_url to determine
|
||
|
# which view triggered the context menu.
|
||
|
route = Rails.application.routes.recognize_path(@back)
|
||
|
@include_delete =
|
||
|
[
|
||
|
{controller: 'issues', action: 'index'},
|
||
|
{controller: 'gantts', action: 'show'},
|
||
|
{controller: 'calendars', action: 'show'}
|
||
|
].any?(route.slice(:controller, :action))
|
||
|
rescue ActionController::RoutingError
|
||
|
@include_delete = false
|
||
|
end
|
||
|
@columns = params[:c]
|
||
| app/views/context_menus/issues.html.erb | ||
|---|---|---|
|
<li><%= context_menu_link sprite_icon('copy', l(:button_copy)), bulk_edit_issues_path(:ids => @issue_ids, :copy => '1'),
|
||
|
:class => 'icon icon-copy', :disabled => !@can[:copy] %></li>
|
||
|
<% end %>
|
||
|
<li><%= context_menu_link sprite_icon('del', l(:button_delete_object, object_name: (@issue_ids.size > 1 ? l(:label_issue_plural) : l(:label_issue))).capitalize), issues_path(:ids => @issue_ids, :back_url => @back),
|
||
|
:method => :delete, :data => {:confirm => issues_destroy_confirmation_message(@issues)}, :class => 'icon icon-del', :disabled => !@can[:delete] %></li>
|
||
|
<% if @include_delete %>
|
||
|
<li><%= context_menu_link sprite_icon('del', l(:button_delete_object, object_name: (@issue_ids.size > 1 ? l(:label_issue_plural) : l(:label_issue))).capitalize), issues_path(:ids => @issue_ids, :back_url => @back),
|
||
|
:method => :delete, :data => {:confirm => issues_destroy_confirmation_message(@issues)}, :class => 'icon icon-del', :disabled => !@can[:delete] %></li>
|
||
|
<% end %>
|
||
|
<%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
|
||
|
</ul>
|
||